Reconnect websocket on e164 change

This commit is contained in:
Fedor Indutny 2021-09-02 14:47:42 -07:00 committed by GitHub
parent 30075f18fc
commit c7873dd7ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -515,7 +515,7 @@ export async function startApp(): Promise<void> {
accountManager = new window.textsecure.AccountManager(server);
accountManager.addEventListener('registration', () => {
window.Whisper.events.trigger('userChanged');
window.Whisper.events.trigger('userChanged', false);
window.Signal.Util.Registration.markDone();
window.log.info('dispatching registration event');
@ -1057,7 +1057,7 @@ export async function startApp(): Promise<void> {
});
convoCollection.on('reset', removeAllConversations);
window.Whisper.events.on('userChanged', () => {
window.Whisper.events.on('userChanged', (reconnect = false) => {
const newDeviceId = window.textsecure.storage.user.getDeviceId();
const newNumber = window.textsecure.storage.user.getNumber();
const newUuid = window.textsecure.storage.user.getUuid();
@ -1074,6 +1074,11 @@ export async function startApp(): Promise<void> {
ourUuid: newUuid,
regionCode: window.storage.get('regionCode'),
});
if (reconnect) {
window.log.info('background: reconnecting websocket on user change');
enqueueReconnectToWebSocket();
}
});
let shortcutGuideView: WhatIsThis | null = null;

View File

@ -47,7 +47,7 @@ export class User {
]);
// Notify redux about phone number change
window.Whisper.events.trigger('userChanged');
window.Whisper.events.trigger('userChanged', true);
}
public getNumber(): string | undefined {