Only update content when navigating in a wiki

This commit is contained in:
Jori Lallo
2016-07-06 23:27:06 -07:00
parent 7fc711c6f2
commit 4f86ea0a59
2 changed files with 11 additions and 5 deletions

View File

@@ -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 }
<Flex flex={ true } justify={ 'center' }>
<CenteredContent>
<Document document={ doc } />
{ this.store.updatingContent ? (
<AtlasPreviewLoading />
) : (
<Document document={ doc } />
) }
</CenteredContent>
</Flex>
</Flex>

View File

@@ -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 () => {