1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00

Mobile: Fixes #114: Update geolocation in metadata after it has been set

This commit is contained in:
Laurent Cozic 2018-01-28 18:42:43 +00:00
parent 08cb518c25
commit 138ad9fcad

View File

@ -67,7 +67,28 @@ shared.saveNoteButton_press = async function(comp) {
comp.setState(newState);
if (isNew) Note.updateGeolocation(note.id);
if (isNew) {
Note.updateGeolocation(note.id).then((geoNote) => {
const stateNote = comp.state.note;
if (stateNote.id !== geoNote.id) return; // Another note has been loaded while geoloc was being retrieved
// Geo-location for this note has been saved to the database however the properties
// are is not in the state so set them now.
const geoInfo = {
longitude: geoNote.longitude,
latitude: geoNote.latitude,
altitude: geoNote.altitude,
}
const modNote = Object.assign({}, stateNote, geoInfo);
const modLastSavedNote = Object.assign({}, comp.state.lastSavedNote, geoInfo);
comp.setState({ note: modNote, lastSavedNote: modLastSavedNote });
comp.refreshNoteMetadata();
});
}
comp.refreshNoteMetadata();
if (isNew) {