From 553095692cbd8e6358ed1a82187cebf2500dce40 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Tue, 5 Dec 2017 00:15:34 -0800 Subject: [PATCH] Clear active collection if navigating out of it directly Fixes #474 --- app/scenes/Collection/Collection.js | 4 ++++ app/scenes/Document/Document.js | 2 +- app/stores/UiStore.js | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/scenes/Collection/Collection.js b/app/scenes/Collection/Collection.js index 9375ac37a..74bc1b4a5 100644 --- a/app/scenes/Collection/Collection.js +++ b/app/scenes/Collection/Collection.js @@ -49,6 +49,10 @@ class CollectionScene extends Component { } } + componentWillUnmount() { + this.props.ui.clearActiveCollection(); + } + loadContent = async (id: string) => { const { collections } = this.props; diff --git a/app/scenes/Document/Document.js b/app/scenes/Document/Document.js index 084d96f68..da430b8ef 100644 --- a/app/scenes/Document/Document.js +++ b/app/scenes/Document/Document.js @@ -63,7 +63,7 @@ class DocumentScene extends Component { @observable notFound = false; @observable moveModalOpen: boolean = false; - componentWillMount() { + componentDidMount() { this.loadDocument(this.props); } diff --git a/app/stores/UiStore.js b/app/stores/UiStore.js index 3fc05269d..09e42feb9 100644 --- a/app/stores/UiStore.js +++ b/app/stores/UiStore.js @@ -35,6 +35,11 @@ class UiStore { this.activeCollectionId = collection.id; }; + @action + clearActiveCollection = (): void => { + this.activeCollectionId = undefined; + }; + @action clearActiveDocument = (): void => { this.activeDocumentId = undefined;