move all logic, make bar more generic

pass through actual errors
and tidy
needs testing

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2017-06-11 19:19:17 +01:00
parent c4fd139586
commit a520f0bfed
6 changed files with 138 additions and 96 deletions

View File

@@ -19,12 +19,13 @@ limitations under the License.
import BasePlatform from 'matrix-react-sdk/lib/BasePlatform';
import { _t } from 'matrix-react-sdk/lib/languageHandler';
import dis from 'matrix-react-sdk/lib/dispatcher';
import Favico from 'favico.js';
export const updateStateEnum = {
export const updateCheckStatusEnum = {
CHECKING: 'CHECKING',
ERROR: 'ERROR',
TIMEOUT: 'TIMEOUT',
NOTAVAILABLE: 'NOTAVAILABLE',
DOWNLOADING: 'DOWNLOADING',
READY: 'READY',
@@ -42,8 +43,12 @@ export default class VectorBasePlatform extends BasePlatform {
// and we set the state each time, even if the value hasn't changed,
// so we'd need to fix that if enabling the animation.
this.favicon = new Favico({animation: 'none'});
this.showUpdateCheck = false;
this._updateFavicon();
this.updatable = true;
this.startUpdateCheck = this.startUpdateCheck.bind(this);
this.stopUpdateCheck = this.stopUpdateCheck.bind(this);
}
getHumanReadableName(): string {
@@ -96,14 +101,30 @@ export default class VectorBasePlatform extends BasePlatform {
return this.updatable;
}
startUpdateCheck() {
this.showUpdateCheck = true;
dis.dispatch({
action: 'check_updates',
value: { status: updateCheckStatusEnum.CHECKING },
});
}
stopUpdateCheck() {
this.showUpdateCheck = false;
dis.dispatch({
action: 'check_updates',
value: false,
})
}
/**
* Check for the availability of an update to the version of the
* app that's currently running.
* If an update is available, this function should dispatch the
* 'new_version' action.
* @returns Promise<updateStateEnum>
* @returns Promise<updateCheckStatusEnum>
*/
checkForUpdate(): Promise<number> {
pollForUpdate(): Promise<number> {
}
/**