From 9e672b3e58ae76ca7b3c8ee002541b241c66fac2 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Mon, 18 Sep 2017 00:20:51 -0700 Subject: [PATCH] Fixed lag in toggling documents --- frontend/scenes/Document/Document.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/scenes/Document/Document.js b/frontend/scenes/Document/Document.js index 4a2a077f4..a1866aa1e 100644 --- a/frontend/scenes/Document/Document.js +++ b/frontend/scenes/Document/Document.js @@ -93,7 +93,7 @@ type Props = { }); this.newDocument = newDocument; } else { - let document = this.document; + let document = this.getDocument(props.match.params.documentSlug); if (document) { this.props.ui.setActiveDocument(document); } @@ -124,13 +124,17 @@ type Props = { ); } - get document() { + getDocument(documentSlug: ?string) { if (this.newDocument) return this.newDocument; return this.props.documents.getByUrl( - `/doc/${this.props.match.params.documentSlug}` + `/doc/${documentSlug || this.props.match.params.documentSlug}` ); } + get document() { + return this.getDocument(); + } + onClickEdit = () => { if (!this.document) return; const url = `${this.document.url}/edit`;