Ensure we register messageReceiver only after setup is complete
This commit is contained in:
parent
8e59a660ce
commit
1a98d50948
1 changed files with 6 additions and 6 deletions
|
@ -1554,14 +1554,11 @@ export async function startApp(): Promise<void> {
|
|||
|
||||
window.Whisper.events.on('online', () => {
|
||||
log.info('background: online');
|
||||
|
||||
strictAssert(server !== undefined, 'WebAPI not initialized');
|
||||
strictAssert(
|
||||
messageReceiver !== undefined,
|
||||
'MessageReceiver not initialized'
|
||||
);
|
||||
messageReceiver.reset();
|
||||
server.registerRequestHandler(messageReceiver);
|
||||
|
||||
// The first call to connect should be done via start(), ensuring that the app is
|
||||
// ready first
|
||||
|
@ -1577,9 +1574,6 @@ export async function startApp(): Promise<void> {
|
|||
drop(AttachmentDownloads.stop());
|
||||
drop(messageReceiver?.drain());
|
||||
|
||||
if (messageReceiver) {
|
||||
server?.unregisterRequestHandler(messageReceiver);
|
||||
}
|
||||
if (connectCount === 0) {
|
||||
log.info('background: offline, never connected, showing inbox');
|
||||
|
||||
|
@ -1675,6 +1669,12 @@ export async function startApp(): Promise<void> {
|
|||
|
||||
void window.Signal.Services.initializeGroupCredentialFetcher();
|
||||
|
||||
strictAssert(
|
||||
messageReceiver !== undefined,
|
||||
'MessageReceiver not initialized'
|
||||
);
|
||||
server.registerRequestHandler(messageReceiver);
|
||||
|
||||
drop(
|
||||
AttachmentDownloads.start({
|
||||
logger: log,
|
||||
|
|
Loading…
Reference in a new issue