mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
Give contextual feedback for manual update check instead of banner
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
c68f35060a
commit
1fd74f22c8
@ -18,18 +18,19 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import VectorBasePlatform, {updateCheckStatusEnum} from './VectorBasePlatform';
|
||||
import VectorBasePlatform from './VectorBasePlatform';
|
||||
import {UpdateCheckStatus} from "matrix-react-sdk/src/BasePlatform";
|
||||
import BaseEventIndexManager, {
|
||||
MatrixEvent,
|
||||
MatrixProfile,
|
||||
SearchResult,
|
||||
CrawlerCheckpoint,
|
||||
EventAndProfile,
|
||||
IndexStats,
|
||||
MatrixEvent,
|
||||
MatrixProfile,
|
||||
SearchArgs,
|
||||
IndexStats
|
||||
SearchResult
|
||||
} from 'matrix-react-sdk/src/indexing/BaseEventIndexManager';
|
||||
import dis from 'matrix-react-sdk/src/dispatcher/dispatcher';
|
||||
import { _t, _td } from 'matrix-react-sdk/src/languageHandler';
|
||||
import {_t, _td} from 'matrix-react-sdk/src/languageHandler';
|
||||
import * as rageshake from 'matrix-react-sdk/src/rageshake/rageshake';
|
||||
import {MatrixClient} from "matrix-js-sdk/src/client";
|
||||
import {Room} from "matrix-js-sdk/src/models/room";
|
||||
@ -41,8 +42,9 @@ import {Key} from "matrix-react-sdk/src/Keyboard";
|
||||
import React from "react";
|
||||
import {randomString} from "matrix-js-sdk/src/randomstring";
|
||||
import {Action} from "matrix-react-sdk/src/dispatcher/actions";
|
||||
import { ActionPayload } from "matrix-react-sdk/src/dispatcher/payloads";
|
||||
import { showToast as showUpdateToast } from "matrix-react-sdk/src/toasts/UpdateToast";
|
||||
import {ActionPayload} from "matrix-react-sdk/src/dispatcher/payloads";
|
||||
import {showToast as showUpdateToast} from "matrix-react-sdk/src/toasts/UpdateToast";
|
||||
import { CheckUpdatesPayload } from 'matrix-react-sdk/src/dispatcher/payloads/CheckUpdatesPayload';
|
||||
|
||||
const ipcRenderer = window.ipcRenderer;
|
||||
const isMac = navigator.platform.toUpperCase().includes('MAC');
|
||||
@ -73,14 +75,14 @@ function _onAction(payload: ActionPayload) {
|
||||
}
|
||||
}
|
||||
|
||||
function getUpdateCheckStatus(status) {
|
||||
function getUpdateCheckStatus(status: boolean | string) {
|
||||
if (status === true) {
|
||||
return { status: updateCheckStatusEnum.DOWNLOADING };
|
||||
return { status: UpdateCheckStatus.Downloading };
|
||||
} else if (status === false) {
|
||||
return { status: updateCheckStatusEnum.NOTAVAILABLE };
|
||||
return { status: UpdateCheckStatus.NotAvailable };
|
||||
} else {
|
||||
return {
|
||||
status: updateCheckStatusEnum.ERROR,
|
||||
status: UpdateCheckStatus.Error,
|
||||
detail: status,
|
||||
};
|
||||
}
|
||||
@ -214,12 +216,10 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||
or the error if one is encountered
|
||||
*/
|
||||
ipcRenderer.on('check_updates', (event, status) => {
|
||||
if (!this.showUpdateCheck) return;
|
||||
dis.dispatch({
|
||||
action: 'check_updates',
|
||||
value: getUpdateCheckStatus(status),
|
||||
dis.dispatch<CheckUpdatesPayload>({
|
||||
action: Action.CheckUpdates,
|
||||
...getUpdateCheckStatus(status),
|
||||
});
|
||||
this.showUpdateCheck = false;
|
||||
});
|
||||
|
||||
// try to flush the rageshake logs to indexeddb before quit.
|
||||
@ -385,9 +385,7 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
||||
}
|
||||
|
||||
startUpdateCheck() {
|
||||
if (this.showUpdateCheck) return;
|
||||
super.startUpdateCheck();
|
||||
|
||||
ipcRenderer.send('check_updates');
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
import BasePlatform from 'matrix-react-sdk/src/BasePlatform';
|
||||
import { _t } from 'matrix-react-sdk/src/languageHandler';
|
||||
import dis from 'matrix-react-sdk/src/dispatcher/dispatcher';
|
||||
import {_t} from 'matrix-react-sdk/src/languageHandler';
|
||||
import {getVectorConfig} from "../getconfig";
|
||||
|
||||
import Favicon from "../../favicon";
|
||||
@ -36,14 +35,12 @@ export const updateCheckStatusEnum = {
|
||||
* Vector-specific extensions to the BasePlatform template
|
||||
*/
|
||||
export default abstract class VectorBasePlatform extends BasePlatform {
|
||||
protected showUpdateCheck: boolean = false;
|
||||
protected _favicon: Favicon;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.startUpdateCheck = this.startUpdateCheck.bind(this);
|
||||
this.stopUpdateCheck = this.stopUpdateCheck.bind(this);
|
||||
}
|
||||
|
||||
async getConfig(): Promise<{}> {
|
||||
@ -96,33 +93,6 @@ export default abstract class VectorBasePlatform extends BasePlatform {
|
||||
startUpdater() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether we can call checkForUpdate on this platform build
|
||||
*/
|
||||
async canSelfUpdate(): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
|
||||
startUpdateCheck() {
|
||||
this.showUpdateCheck = true;
|
||||
dis.dispatch({
|
||||
action: 'check_updates',
|
||||
value: { status: updateCheckStatusEnum.CHECKING },
|
||||
});
|
||||
}
|
||||
|
||||
stopUpdateCheck() {
|
||||
this.showUpdateCheck = false;
|
||||
dis.dispatch({
|
||||
action: 'check_updates',
|
||||
value: false,
|
||||
});
|
||||
}
|
||||
|
||||
getUpdateCheckStatusEnum() {
|
||||
return updateCheckStatusEnum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the currently running app to the latest available
|
||||
* version and replace this instance of the app with the
|
||||
|
@ -16,12 +16,15 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import VectorBasePlatform, {updateCheckStatusEnum} from './VectorBasePlatform';
|
||||
import VectorBasePlatform from './VectorBasePlatform';
|
||||
import {UpdateCheckStatus} from "matrix-react-sdk/src/BasePlatform";
|
||||
import request from 'browser-request';
|
||||
import dis from 'matrix-react-sdk/src/dispatcher/dispatcher';
|
||||
import { _t } from 'matrix-react-sdk/src/languageHandler';
|
||||
import {_t} from 'matrix-react-sdk/src/languageHandler';
|
||||
import {Room} from "matrix-js-sdk/src/models/room";
|
||||
import { showToast as showUpdateToast, hideToast as hideUpdateToast } from "matrix-react-sdk/src/toasts/UpdateToast";
|
||||
import {hideToast as hideUpdateToast, showToast as showUpdateToast} from "matrix-react-sdk/src/toasts/UpdateToast";
|
||||
import {Action} from "matrix-react-sdk/src/dispatcher/actions";
|
||||
import { CheckUpdatesPayload } from 'matrix-react-sdk/src/dispatcher/payloads/CheckUpdatesPayload';
|
||||
|
||||
import url from 'url';
|
||||
import UAParser from 'ua-parser-js';
|
||||
@ -136,36 +139,29 @@ export default class WebPlatform extends VectorBasePlatform {
|
||||
return this._getVersion().then((ver) => {
|
||||
if (this.runningVersion === null) {
|
||||
this.runningVersion = ver;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.runningVersion !== ver) {
|
||||
} else if (this.runningVersion !== ver) {
|
||||
showUpdateToast(this.runningVersion, ver);
|
||||
// Return to skip a MatrixChat state update
|
||||
return;
|
||||
return { status: UpdateCheckStatus.Ready };
|
||||
} else {
|
||||
hideUpdateToast();
|
||||
}
|
||||
|
||||
return { status: updateCheckStatusEnum.NOTAVAILABLE };
|
||||
return { status: UpdateCheckStatus.NotAvailable };
|
||||
}, (err) => {
|
||||
console.error("Failed to poll for update", err);
|
||||
return {
|
||||
status: updateCheckStatusEnum.ERROR,
|
||||
status: UpdateCheckStatus.Error,
|
||||
detail: err.message || err.status ? err.status.toString() : 'Unknown Error',
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
startUpdateCheck() {
|
||||
if (this.showUpdateCheck) return;
|
||||
super.startUpdateCheck();
|
||||
this.pollForUpdate().then((updateState) => {
|
||||
if (!this.showUpdateCheck) return;
|
||||
if (!updateState) return;
|
||||
dis.dispatch({
|
||||
action: 'check_updates',
|
||||
value: updateState,
|
||||
dis.dispatch<CheckUpdatesPayload>({
|
||||
action: Action.CheckUpdates,
|
||||
...updateState,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user