Fix issues with mapping old app states

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent 3d5fcc8169
commit 25a64623f4

@ -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;
}

@ -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);
}

Loading…
Cancel
Save