Merge pull request #563 from vector-im/bwindels/exportlogsonsessionloadfail
add export logs button when session fails to load
This commit is contained in:
commit
d9ecf38e42
2 changed files with 20 additions and 3 deletions
|
@ -102,8 +102,7 @@ export class SessionLoadViewModel extends ViewModel {
|
|||
|
||||
get loadLabel() {
|
||||
const sc = this._sessionContainer;
|
||||
const error = this._error || (sc && sc.loadError);
|
||||
|
||||
const error = this._getError();
|
||||
if (error || (sc && sc.loadStatus.get() === LoadStatus.Error)) {
|
||||
return `Something went wrong: ${error && error.message}.`;
|
||||
}
|
||||
|
@ -124,4 +123,17 @@ export class SessionLoadViewModel extends ViewModel {
|
|||
|
||||
return `Preparing…`;
|
||||
}
|
||||
|
||||
_getError() {
|
||||
return this._error || this._sessionContainer?.loadError;
|
||||
}
|
||||
|
||||
get hasError() {
|
||||
return !!this._getError();
|
||||
}
|
||||
|
||||
async exportLogs() {
|
||||
const logExport = await this.logger.export();
|
||||
this.platform.saveFileAs(logExport.asBlob(), `hydrogen-logs-${this.platform.clock.now()}.json`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,9 +22,14 @@ to show the current state of loading the session.
|
|||
Just a spinner and a label, meant to be used as a paragraph */
|
||||
export class SessionLoadStatusView extends TemplateView {
|
||||
render(t) {
|
||||
const exportLogsButtonIfFailed = t.if(vm => vm.hasError, (t, vm) => {
|
||||
return t.button({
|
||||
onClick: () => vm.exportLogs()
|
||||
}, vm.i18n`Export logs`);
|
||||
});
|
||||
return t.div({className: "SessionLoadStatusView"}, [
|
||||
spinner(t, {hiddenWithLayout: vm => !vm.loading}),
|
||||
t.p(vm => vm.loadLabel)
|
||||
t.p([vm => vm.loadLabel, exportLogsButtonIfFailed])
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue