mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Show error, progress in view
This commit is contained in:
parent
7b173fe8eb
commit
205ecdc52e
@ -24,6 +24,8 @@ export class ForcedLogoutViewModel extends ViewModel<SegmentType, Options> {
|
|||||||
private _sessionId: string;
|
private _sessionId: string;
|
||||||
private _error?: Error;
|
private _error?: Error;
|
||||||
private _logoutPromise: Promise<void>;
|
private _logoutPromise: Promise<void>;
|
||||||
|
private _showStatus: boolean = false;
|
||||||
|
private _showSpinner: boolean = false;
|
||||||
|
|
||||||
constructor(options: Options) {
|
constructor(options: Options) {
|
||||||
super(options);
|
super(options);
|
||||||
@ -38,18 +40,35 @@ export class ForcedLogoutViewModel extends ViewModel<SegmentType, Options> {
|
|||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
this._error = err;
|
this._error = err;
|
||||||
|
this._showSpinner = false;
|
||||||
|
this._showStatus = true;
|
||||||
this.emitChange("error");
|
this.emitChange("error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async proceed(): Promise<void> {
|
async proceed(): Promise<void> {
|
||||||
|
this._showSpinner = true;
|
||||||
|
this._showStatus = true;
|
||||||
|
this.emitChange("showStatus");
|
||||||
await this._logoutPromise;
|
await this._logoutPromise;
|
||||||
|
if (!this._error) {
|
||||||
this.navigation.push("session", true);
|
this.navigation.push("session", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get error(): string | undefined {
|
get status(): string {
|
||||||
if (this._error) {
|
if (this._error) {
|
||||||
return this.i18n`Could not log out of device: ${this._error.message}`;
|
return this.i18n`Could not log out of device: ${this._error.message}`;
|
||||||
|
} else {
|
||||||
|
return this.i18n`Logging out… Please don't close the app.`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get showStatus(): boolean {
|
||||||
|
return this._showStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
get showSpinner(): boolean {
|
||||||
|
return this._showSpinner;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {TemplateView, InlineTemplateView} from "./general/TemplateView";
|
import {TemplateView, InlineTemplateView} from "./general/TemplateView";
|
||||||
|
import {spinner} from "./common.js";
|
||||||
|
|
||||||
export class ForcedLogoutView extends TemplateView {
|
export class ForcedLogoutView extends TemplateView {
|
||||||
render(t, vm) {
|
render(t, vm) {
|
||||||
@ -31,13 +32,13 @@ export class ForcedLogoutView extends TemplateView {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
const progressView = new InlineTemplateView(vm, t => {
|
const progressView = new InlineTemplateView(vm, t => {
|
||||||
return t.p({className: "status"}, [ t.span(vm => vm.error) ]);
|
return t.p({className: "status"}, [spinner(t, {hidden: vm => !vm.showSpinner}), t.span(vm => vm.status)]);
|
||||||
});
|
});
|
||||||
|
|
||||||
return t.div({className: "LogoutScreen"}, [
|
return t.div({className: "LogoutScreen"}, [
|
||||||
t.div({className: "content"},
|
t.div({className: "content"},
|
||||||
t.mapView(vm => vm.error, error => {
|
t.mapView(vm => vm.showStatus, showStatus => {
|
||||||
return error? progressView: proceedView;
|
return showStatus? progressView: proceedView;
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
Loading…
Reference in New Issue
Block a user