Refactor app initialization logic

This commit is contained in:
trevor-signal
2025-02-12 13:37:30 -05:00
committed by GitHub
parent 205c477082
commit 4c3db76bde
17 changed files with 394 additions and 582 deletions

View File

@@ -300,7 +300,6 @@ export default class MessageReceiver
#serverTrustRoot: Uint8Array;
#stoppingProcessing?: boolean;
#pniIdentityKeyCheckRequired?: boolean;
#isAppReadyForProcessing: boolean = false;
constructor({ storage, serverTrustRoot }: MessageReceiverOptions) {
super();
@@ -348,15 +347,6 @@ export default class MessageReceiver
maxSize: 30,
processBatch: this.#cacheRemoveBatch.bind(this),
});
window.Whisper.events.on('app-ready-for-processing', () => {
this.#isAppReadyForProcessing = true;
this.reset();
});
window.Whisper.events.on('online', () => {
this.reset();
});
}
public getAndResetProcessedCount(): number {
@@ -477,17 +467,12 @@ export default class MessageReceiver
);
}
public reset(): void {
log.info('MessageReceiver.reset');
public startProcessingQueue(): void {
log.info('MessageReceiver.startProcessingQueue');
this.#count = 0;
this.#isEmptied = false;
this.#stoppingProcessing = false;
if (!this.#isAppReadyForProcessing) {
log.info('MessageReceiver.reset: not ready yet, returning early');
return;
}
drop(this.#addCachedMessagesToQueue());
}
@@ -507,7 +492,6 @@ export default class MessageReceiver
public stopProcessing(): void {
log.info('MessageReceiver.stopProcessing');
this.#stoppingProcessing = true;
this.#isAppReadyForProcessing = false;
}
public hasEmptied(): boolean {