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
3 changed files with 31 additions and 67 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue