Flush last conversation message save on shutdown

This commit is contained in:
Fedor Indutny 2022-04-12 11:16:58 -07:00 committed by GitHub
parent 0ccbf5e4bd
commit 42108c9ca9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 8 deletions

View file

@ -658,6 +658,17 @@ export async function startApp(): Promise<void> {
await window.waitForAllBatchers();
}
log.info('background/shutdown: flushing conversations');
// Flush debounced updates for conversations
await Promise.all(
window.ConversationController.getAll().map(convo =>
convo.flushDebouncedUpdates()
)
);
log.info('background/shutdown: waiting for all batchers');
// A number of still-to-queue database queries might be waiting inside batchers.
// We wait for these to empty first, and then shut down the data interface.
await Promise.all([
@ -665,6 +676,8 @@ export async function startApp(): Promise<void> {
window.waitForAllWaitBatchers(),
]);
log.info('background/shutdown: closing the database');
// Shut down the data interface cleanly
await window.Signal.Data.shutdown();
},