Rely on socket connection events for message request handling registration
This commit is contained in:
parent
2fbbcdf358
commit
3c3a50a193
1 changed files with 15 additions and 9 deletions
|
@ -1554,7 +1554,18 @@ export async function startApp(): Promise<void> {
|
|||
|
||||
window.Whisper.events.on('online', () => {
|
||||
log.info('background: online');
|
||||
if (!remotelyExpired) {
|
||||
|
||||
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
|
||||
if (!remotelyExpired && connectCount > 0) {
|
||||
drop(connect());
|
||||
}
|
||||
});
|
||||
|
@ -1566,6 +1577,9 @@ 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');
|
||||
|
||||
|
@ -1661,14 +1675,6 @@ export async function startApp(): Promise<void> {
|
|||
|
||||
void window.Signal.Services.initializeGroupCredentialFetcher();
|
||||
|
||||
strictAssert(server !== undefined, 'WebAPI not initialized');
|
||||
strictAssert(
|
||||
messageReceiver !== undefined,
|
||||
'MessageReceiver not initialized'
|
||||
);
|
||||
messageReceiver.reset();
|
||||
server.registerRequestHandler(messageReceiver);
|
||||
|
||||
drop(
|
||||
AttachmentDownloads.start({
|
||||
logger: log,
|
||||
|
|
Loading…
Reference in a new issue