From fdb44c2f762bc070b59edbd9712b98cdeca49287 Mon Sep 17 00:00:00 2001 From: Mario Nebl Date: Fri, 11 May 2018 13:11:05 +0200 Subject: [PATCH] fix: handle opening files with less pages --- src/electron/renderer.ts | 1 - src/store/view-store.ts | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/electron/renderer.ts b/src/electron/renderer.ts index 93c2dc406..f037acf7b 100644 --- a/src/electron/renderer.ts +++ b/src/electron/renderer.ts @@ -32,7 +32,6 @@ Sender.receive(message => { case ServerMessageType.OpenFileResponse: { const newProject = Project.from(message.payload.contents); newProject.setPath(message.payload.path); - store.setProject(newProject); store.setActiveView(Types.AlvaView.PageDetail); break; diff --git a/src/store/view-store.ts b/src/store/view-store.ts index 7e332ccd9..0534df5b1 100644 --- a/src/store/view-store.ts +++ b/src/store/view-store.ts @@ -786,6 +786,13 @@ export class ViewStore { public setProject(project: Project): void { this.currentProject = project; + const pages = this.currentProject.getPages(); + + if (pages.length > 0) { + this.setActivePageByIndex(0); + } else { + this.unsetActivePage(); + } } /**