diff --git a/mediarepo-ui/src/app/models/TabState.ts b/mediarepo-ui/src/app/models/TabState.ts index a0f7e4f..252364e 100644 --- a/mediarepo-ui/src/app/models/TabState.ts +++ b/mediarepo-ui/src/app/models/TabState.ts @@ -71,7 +71,7 @@ export class TabState { state.sortKeys.next(sortKeys); state.mode.next(dto.mode ?? "grid"); state.selectedCD.next(dto.selectedFileHash); - state.files.next(dto.files.map(mapNew(File))); + state.files.next((dto.files ?? []).map(mapNew(File))); return state; } diff --git a/mediarepo-ui/src/app/services/state/state.service.ts b/mediarepo-ui/src/app/services/state/state.service.ts index e1ee72a..00a4738 100644 --- a/mediarepo-ui/src/app/services/state/state.service.ts +++ b/mediarepo-ui/src/app/services/state/state.service.ts @@ -42,7 +42,12 @@ export class StateService { let state; if (stateString) { - state = AppState.deserializeJson(stateString, this.fileService); + try { + state = AppState.deserializeJson(stateString, this.fileService); + } catch (err) { + console.error("could not deserialize malformed state: ", err); + state = new AppState(this.fileService); + } } else { state = new AppState(this.fileService); }