1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-23 18:53:36 +02:00

Mobile: Fixes #1975: Images were not being displayed just after having been taken or attached

This commit is contained in:
Laurent Cozic 2019-10-12 20:49:10 +02:00
parent 90bc84c010
commit 51233c2745

View File

@ -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();
}