From 51233c274577b3376ee8e02b997afbe519a806b6 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sat, 12 Oct 2019 20:49:10 +0200 Subject: [PATCH] Mobile: Fixes #1975: Images were not being displayed just after having been taken or attached --- ReactNativeClient/lib/components/screens/note.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ReactNativeClient/lib/components/screens/note.js b/ReactNativeClient/lib/components/screens/note.js index c238dc564..8c6ff4f67 100644 --- a/ReactNativeClient/lib/components/screens/note.js +++ b/ReactNativeClient/lib/components/screens/note.js @@ -164,14 +164,16 @@ class NoteScreenComponent extends BaseScreenComponent { } }; - this.refreshResource = async resource => { - if (!this.state.note || !this.state.note.body) return; - const resourceIds = await Note.linkedResourceIds(this.state.note.body); - if (resourceIds.indexOf(resource.id) >= 0 && this.refs.noteBodyViewer) { + this.refreshResource = async (resource, noteBody = null) => { + if (noteBody === null && this.state.note && this.state.note.body) noteBody = this.state.note.body; + if (noteBody === null) return; + + const resourceIds = await Note.linkedResourceIds(noteBody); + if (resourceIds.indexOf(resource.id) >= 0) { shared.clearResourceCache(); - const attachedResources = await shared.attachedResources(this.state.note.body); + const attachedResources = await shared.attachedResources(noteBody); this.setState({ noteResources: attachedResources }, () => { - this.refs.noteBodyViewer.rebuildMd(); + if (this.refs.noteBodyViewer) this.refs.noteBodyViewer.rebuildMd(); }); } }; @@ -512,7 +514,7 @@ class NoteScreenComponent extends BaseScreenComponent { newNote.body += `\n${resourceTag}`; this.setState({ note: newNote }); - this.refreshResource(resource); + this.refreshResource(resource, newNote.body); this.scheduleSave(); }