Drain jobs cleanly on shutdown

This commit is contained in:
Alvaro 2023-02-24 12:03:17 -07:00 committed by GitHub
parent a83a85d557
commit b5849f872a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 301 additions and 30 deletions

View file

@ -113,14 +113,15 @@ export class ReadSyncs extends Collection {
// TODO DESKTOP-1509: use MessageUpdater.markRead once this is TS
message.markRead(readAt, { skipSave: true });
const updateConversation = () => {
const updateConversation = async () => {
// onReadMessage may result in messages older than this one being
// marked read. We want those messages to have the same expire timer
// start time as this one, so we pass the readAt value through.
void message.getConversation()?.onReadMessage(message, readAt);
};
if (StartupQueue.isReady()) {
// only available during initialization
if (StartupQueue.isAvailable()) {
const conversation = message.getConversation();
if (conversation) {
StartupQueue.add(
@ -130,7 +131,9 @@ export class ReadSyncs extends Collection {
);
}
} else {
updateConversation();
// not awaiting since we don't want to block work happening in the
// eventHandlerQueue
void updateConversation();
}
} else {
const now = Date.now();