mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-22 19:14:52 +01:00
Navigate to UI when sync fails
This commit is contained in:
parent
216c5da386
commit
0f2b7a1ce9
@ -28,6 +28,7 @@ import {CreateRoomViewModel} from "./CreateRoomViewModel.js";
|
|||||||
import {ViewModel} from "../ViewModel";
|
import {ViewModel} from "../ViewModel";
|
||||||
import {RoomViewModelObservable} from "./RoomViewModelObservable.js";
|
import {RoomViewModelObservable} from "./RoomViewModelObservable.js";
|
||||||
import {RightPanelViewModel} from "./rightpanel/RightPanelViewModel.js";
|
import {RightPanelViewModel} from "./rightpanel/RightPanelViewModel.js";
|
||||||
|
import {SyncStatus} from "../../matrix/Sync.js";
|
||||||
|
|
||||||
export class SessionViewModel extends ViewModel {
|
export class SessionViewModel extends ViewModel {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
@ -45,6 +46,7 @@ export class SessionViewModel extends ViewModel {
|
|||||||
this._gridViewModel = null;
|
this._gridViewModel = null;
|
||||||
this._createRoomViewModel = null;
|
this._createRoomViewModel = null;
|
||||||
this._setupNavigation();
|
this._setupNavigation();
|
||||||
|
this._setupForcedLogoutOnAccessTokenInvalidation();
|
||||||
}
|
}
|
||||||
|
|
||||||
_setupNavigation() {
|
_setupNavigation() {
|
||||||
@ -93,6 +95,18 @@ export class SessionViewModel extends ViewModel {
|
|||||||
this._updateRightPanel();
|
this._updateRightPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_setupForcedLogoutOnAccessTokenInvalidation() {
|
||||||
|
this._client.sync.status.subscribe(status => {
|
||||||
|
if (status === SyncStatus.Stopped) {
|
||||||
|
const error = this._client.sync.error;
|
||||||
|
if (error.errcode === "M_UNKNOWN_TOKEN") {
|
||||||
|
// Access token is no longer valid, so force the user to log out
|
||||||
|
this.navigation.push("forced-logout", this.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
get id() {
|
get id() {
|
||||||
return this._client.sessionId;
|
return this._client.sessionId;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user