recalculate maxEntityChangeId after rollbacked transaction

This commit is contained in:
zadam 2023-01-24 09:35:00 +01:00
parent 2e9dbda077
commit a888f9aa04
3 changed files with 12 additions and 4 deletions

View File

@ -95,9 +95,9 @@ export default class RecentChangesDialog extends BasicWidget {
this.$widget.modal('hide'); this.$widget.modal('hide');
setTimeout(() => { await ws.waitForMaxKnownEntityChangeId();
appContext.tabManager.getActiveContext().setNote(change.noteId); appContext.tabManager.getActiveContext().setNote(change.noteId);
}, 1000);
} }
}); });

View File

@ -136,6 +136,10 @@ function fillAllEntityChanges() {
}); });
} }
function recalculateMaxEntityChangeId() {
maxEntityChangeId = sql.getValue("SELECT COALESCE(MAX(id), 0) FROM entity_changes");
}
module.exports = { module.exports = {
addNoteReorderingEntityChange, addNoteReorderingEntityChange,
moveEntityChangeToTop, moveEntityChangeToTop,
@ -143,5 +147,6 @@ module.exports = {
addEntityChangeWithInstanceId, addEntityChangeWithInstanceId,
fillAllEntityChanges, fillAllEntityChanges,
addEntityChangesForSector, addEntityChangesForSector,
getMaxEntityChangeId: () => maxEntityChangeId getMaxEntityChangeId: () => maxEntityChangeId,
recalculateMaxEntityChangeId
}; };

View File

@ -256,6 +256,9 @@ function transactional(func) {
require('../becca/becca_loader').load(); require('../becca/becca_loader').load();
} }
// the maxEntityChangeId has been incremented during failed transaction, need to recalculate
require('./entity_changes').recalculateMaxEntityChangeId();
throw e; throw e;
} }
} }