Wait for appView to be there in onEmpty

This commit is contained in:
Fedor Indutny 2021-04-15 11:17:28 -07:00 committed by GitHub
parent 518f3ac017
commit 1746d27b5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,6 +30,11 @@ export async function startApp(): Promise<void> {
);
}
let resolveOnAppView: (() => void) | undefined;
const onAppView = new Promise<void>(resolve => {
resolveOnAppView = resolve;
});
window.textsecure.protobuf.onLoad(() => {
window.storage.onready(() => {
senderCertificateService.initialize({
@ -1605,6 +1610,11 @@ export async function startApp(): Promise<void> {
await window.textsecure.messaging.sendRequestKeySyncMessage();
}
);
if (resolveOnAppView) {
resolveOnAppView();
resolveOnAppView = undefined;
}
}
window.getSyncRequest = (timeoutMillis?: number) => {
@ -2111,6 +2121,7 @@ export async function startApp(): Promise<void> {
window.Whisper.deliveryReceiptQueue.start();
window.Whisper.Notifications.enable();
await onAppView;
const view = window.owsDesktopApp.appView;
if (!view) {
throw new Error('Expected `appView` to be initialized');