1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-14 18:27:44 +02:00

Desktop: Regression: Fixed handling of provisional status of note

This commit is contained in:
Laurent Cozic 2021-04-07 18:57:44 +02:00
parent fbfca47ef3
commit 5667e687e9
2 changed files with 23 additions and 12 deletions

View File

@ -502,7 +502,7 @@ export default class Note extends BaseItem {
note.longitude = geoData.coords.longitude;
note.latitude = geoData.coords.latitude;
note.altitude = geoData.coords.altitude;
return Note.save(note);
return Note.save(note, { ignoreProvisionalFlag: true });
}
static filter(note: NoteEntity) {
@ -626,7 +626,16 @@ export default class Note extends BaseItem {
static async save(o: NoteEntity, options: any = null) {
const isNew = this.isNew(o, options);
// If true, this is a provisional note - it will be saved permanently
// only if the user makes changes to it.
const isProvisional = options && !!options.provisional;
// If true, saving the note will not change the provisional flag of the
// note. This is used for background processing that it not initiated by
// the user. For example when setting the geolocation of a note.
const ignoreProvisionalFlag = options && !!options.ignoreProvisionalFlag;
const dispatchUpdateAction = options ? options.dispatchUpdateAction !== false : true;
if (isNew && !o.source) o.source = Setting.value('appName');
if (isNew && !o.source_application) o.source_application = Setting.value('appId');
@ -672,6 +681,7 @@ export default class Note extends BaseItem {
type: 'NOTE_UPDATE_ONE',
note: note,
provisional: isProvisional,
ignoreProvisionalFlag: ignoreProvisionalFlag,
changedFields: changedFields,
});
}

View File

@ -833,21 +833,22 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
draft.selectedNoteIds = newIndex >= 0 ? [newNotes[newIndex].id] : [];
}
let newProvisionalNoteIds = draft.provisionalNoteIds;
if (!action.ignoreProvisionalFlag) {
let newProvisionalNoteIds = draft.provisionalNoteIds;
if (action.provisional) {
newProvisionalNoteIds = newProvisionalNoteIds.slice();
newProvisionalNoteIds.push(modNote.id);
} else {
const idx = newProvisionalNoteIds.indexOf(modNote.id);
if (idx >= 0) {
if (action.provisional) {
newProvisionalNoteIds = newProvisionalNoteIds.slice();
newProvisionalNoteIds.splice(idx, 1);
newProvisionalNoteIds.push(modNote.id);
} else {
const idx = newProvisionalNoteIds.indexOf(modNote.id);
if (idx >= 0) {
newProvisionalNoteIds = newProvisionalNoteIds.slice();
newProvisionalNoteIds.splice(idx, 1);
}
}
}
draft.provisionalNoteIds = newProvisionalNoteIds;
draft.provisionalNoteIds = newProvisionalNoteIds;
}
}
break;