Only update content when navigating in a wiki
This commit is contained in:
@@ -42,7 +42,7 @@ class DocumentScene extends React.Component {
|
|||||||
const oldId = this.props.params.id;
|
const oldId = this.props.params.id;
|
||||||
const newId = nextProps.params.id;
|
const newId = nextProps.params.id;
|
||||||
if (oldId !== newId) {
|
if (oldId !== newId) {
|
||||||
this.store.fetchDocument(newId);
|
this.store.fetchDocument(newId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scroll to anchor after loading, and only once
|
// Scroll to anchor after loading, and only once
|
||||||
@@ -137,7 +137,11 @@ class DocumentScene extends React.Component {
|
|||||||
) : null }
|
) : null }
|
||||||
<Flex flex={ true } justify={ 'center' }>
|
<Flex flex={ true } justify={ 'center' }>
|
||||||
<CenteredContent>
|
<CenteredContent>
|
||||||
<Document document={ doc } />
|
{ this.store.updatingContent ? (
|
||||||
|
<AtlasPreviewLoading />
|
||||||
|
) : (
|
||||||
|
<Document document={ doc } />
|
||||||
|
) }
|
||||||
</CenteredContent>
|
</CenteredContent>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class DocumentSceneStore {
|
|||||||
@observable document;
|
@observable document;
|
||||||
|
|
||||||
@observable isFetching = true;
|
@observable isFetching = true;
|
||||||
|
@observable updatingContent = false;
|
||||||
@observable updatingStructure = false;
|
@observable updatingStructure = false;
|
||||||
@observable isDeleting;
|
@observable isDeleting;
|
||||||
|
|
||||||
@@ -19,9 +20,9 @@ class DocumentSceneStore {
|
|||||||
|
|
||||||
/* Actions */
|
/* Actions */
|
||||||
|
|
||||||
@action fetchDocument = async (id) => {
|
@action fetchDocument = async (id, softLoad) => {
|
||||||
this.isFetching = true;
|
this.isFetching = !softLoad;
|
||||||
this.document = null;
|
this.updatingContent = softLoad;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await client.post('/documents.info', { id: id });
|
const res = await client.post('/documents.info', { id: id });
|
||||||
@@ -33,6 +34,7 @@ class DocumentSceneStore {
|
|||||||
console.error("Something went wrong");
|
console.error("Something went wrong");
|
||||||
}
|
}
|
||||||
this.isFetching = false;
|
this.isFetching = false;
|
||||||
|
this.updatingContent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@action deleteDocument = async () => {
|
@action deleteDocument = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user