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