mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Refactor app initialization logic
This commit is contained in:
32
ts/textsecure/syncRequests.ts
Normal file
32
ts/textsecure/syncRequests.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
// Copyright 2025 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { waitForEvent } from '../shims/events';
|
||||
import * as log from '../logging/log';
|
||||
import { singleProtoJobQueue } from '../jobs/singleProtoJobQueue';
|
||||
import MessageSender from './SendMessage';
|
||||
import { toLogFormat } from '../types/errors';
|
||||
|
||||
export async function sendSyncRequests(
|
||||
timeout?: number
|
||||
): Promise<{ contactSyncComplete: Promise<void> }> {
|
||||
const contactSyncComplete = waitForEvent('contactSync:complete', timeout);
|
||||
|
||||
log.info('sendSyncRequests: sending sync requests');
|
||||
try {
|
||||
await Promise.all([
|
||||
singleProtoJobQueue.add(MessageSender.getRequestContactSyncMessage()),
|
||||
singleProtoJobQueue.add(
|
||||
MessageSender.getRequestConfigurationSyncMessage()
|
||||
),
|
||||
singleProtoJobQueue.add(MessageSender.getRequestBlockSyncMessage()),
|
||||
]);
|
||||
} catch (error: unknown) {
|
||||
log.error(
|
||||
'sendSyncRequests: failed to send sync requests',
|
||||
toLogFormat(error)
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
return { contactSyncComplete };
|
||||
}
|
||||
Reference in New Issue
Block a user