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.sortKeys.next(sortKeys);
state.mode.next(dto.mode ?? "grid"); state.mode.next(dto.mode ?? "grid");
state.selectedCD.next(dto.selectedFileHash); state.selectedCD.next(dto.selectedFileHash);
state.files.next(dto.files.map(mapNew(File))); state.files.next((dto.files ?? []).map(mapNew(File)));
return state; return state;
} }

@ -42,7 +42,12 @@ export class StateService {
let state; let state;
if (stateString) { if (stateString) {
try {
state = AppState.deserializeJson(stateString, this.fileService); state = AppState.deserializeJson(stateString, this.fileService);
} catch (err) {
console.error("could not deserialize malformed state: ", err);
state = new AppState(this.fileService);
}
} else { } else {
state = new AppState(this.fileService); state = new AppState(this.fileService);
} }

Loading…
Cancel
Save