mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 19:45:05 +01:00
add logout button to session load error screen
This commit is contained in:
parent
cbccca20d0
commit
68a6113c26
@ -153,6 +153,11 @@ export class SessionLoadViewModel extends ViewModel {
|
||||
this.platform.saveFileAs(logExport.asBlob(), `hydrogen-logs-${this.platform.clock.now()}.json`);
|
||||
}
|
||||
|
||||
async logout() {
|
||||
await this._sessionContainer.logout();
|
||||
this.navigation.push("session", true);
|
||||
}
|
||||
|
||||
get accountSetupViewModel() {
|
||||
return this._accountSetupViewModel;
|
||||
}
|
||||
|
@ -57,16 +57,11 @@ export class SettingsViewModel extends ViewModel {
|
||||
return this._sessionContainer.session;
|
||||
}
|
||||
|
||||
logout() {
|
||||
return this.logger.run("logout", async log => {
|
||||
async logout() {
|
||||
this._isLoggingOut = true;
|
||||
await this._sessionContainer.logout();
|
||||
this.emitChange("isLoggingOut");
|
||||
try {
|
||||
await this._session.logout(log);
|
||||
} catch (err) {}
|
||||
await this._sessionContainer.deleteSession(log);
|
||||
this.navigation.push("session", true);
|
||||
});
|
||||
}
|
||||
|
||||
setupDehydratedDevice(key) {
|
||||
|
@ -107,6 +107,7 @@ export class Session {
|
||||
return this._sessionInfo.userId;
|
||||
}
|
||||
|
||||
/** @internal call SessionContainer.logout instead */
|
||||
async logout(log = undefined) {
|
||||
await this._hsApi.logout({log}).response();
|
||||
}
|
||||
|
@ -367,6 +367,15 @@ export class SessionContainer {
|
||||
return !this._reconnector;
|
||||
}
|
||||
|
||||
logout() {
|
||||
return this._platform.logger.run("logout", async log => {
|
||||
try {
|
||||
await this._session?.logout(log);
|
||||
} catch (err) {}
|
||||
await this.deleteSession(log);
|
||||
});
|
||||
}
|
||||
|
||||
dispose() {
|
||||
if (this._reconnectSubscription) {
|
||||
this._reconnectSubscription();
|
||||
|
@ -28,11 +28,17 @@ export class SessionLoadStatusView extends TemplateView {
|
||||
onClick: () => vm.exportLogs()
|
||||
}, vm.i18n`Export logs`);
|
||||
});
|
||||
const logoutButtonIfFailed = t.if(vm => vm.hasError, (t, vm) => {
|
||||
return t.button({
|
||||
onClick: () => vm.logout()
|
||||
}, vm.i18n`Log out`);
|
||||
});
|
||||
return t.div({className: "SessionLoadStatusView"}, [
|
||||
t.p({className: "status"}, [
|
||||
spinner(t, {hidden: vm => !vm.loading}),
|
||||
t.p(vm => vm.loadLabel),
|
||||
exportLogsButtonIfFailed
|
||||
exportLogsButtonIfFailed,
|
||||
logoutButtonIfFailed
|
||||
]),
|
||||
t.ifView(vm => vm.accountSetupViewModel, vm => new AccountSetupView(vm.accountSetupViewModel)),
|
||||
]);
|
||||
|
Loading…
Reference in New Issue
Block a user