From 4f86ea0a5936a99f6fcdadb84b4fcc47608c9343 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Wed, 6 Jul 2016 23:27:06 -0700 Subject: [PATCH] Only update content when navigating in a wiki --- src/scenes/DocumentScene/DocumentScene.js | 8 ++++++-- src/scenes/DocumentScene/DocumentSceneStore.js | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/scenes/DocumentScene/DocumentScene.js b/src/scenes/DocumentScene/DocumentScene.js index 6b1ec7282..4606f1ade 100644 --- a/src/scenes/DocumentScene/DocumentScene.js +++ b/src/scenes/DocumentScene/DocumentScene.js @@ -42,7 +42,7 @@ class DocumentScene extends React.Component { const oldId = this.props.params.id; const newId = nextProps.params.id; if (oldId !== newId) { - this.store.fetchDocument(newId); + this.store.fetchDocument(newId, true); } // Scroll to anchor after loading, and only once @@ -137,7 +137,11 @@ class DocumentScene extends React.Component { ) : null } - + { this.store.updatingContent ? ( + + ) : ( + + ) } diff --git a/src/scenes/DocumentScene/DocumentSceneStore.js b/src/scenes/DocumentScene/DocumentSceneStore.js index 5e5f59970..3a269e17b 100644 --- a/src/scenes/DocumentScene/DocumentSceneStore.js +++ b/src/scenes/DocumentScene/DocumentSceneStore.js @@ -7,6 +7,7 @@ class DocumentSceneStore { @observable document; @observable isFetching = true; + @observable updatingContent = false; @observable updatingStructure = false; @observable isDeleting; @@ -19,9 +20,9 @@ class DocumentSceneStore { /* Actions */ - @action fetchDocument = async (id) => { - this.isFetching = true; - this.document = null; + @action fetchDocument = async (id, softLoad) => { + this.isFetching = !softLoad; + this.updatingContent = softLoad; try { const res = await client.post('/documents.info', { id: id }); @@ -33,6 +34,7 @@ class DocumentSceneStore { console.error("Something went wrong"); } this.isFetching = false; + this.updatingContent = false; } @action deleteDocument = async () => {