Adjust timeouts for better performance

This commit is contained in:
Scott Nonnenberg 2021-01-11 13:59:46 -08:00 committed by GitHub
parent 172598b354
commit 3a726ad311
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 7 deletions

View file

@ -765,7 +765,15 @@ type WhatIsThis = import('./window.d').WhatIsThis;
if (!conversation) { if (!conversation) {
return; return;
} }
conversationChanged(conversation.id, conversation.format());
// This delay ensures that the .format() call isn't synchronous as a
// Backbone property is changed. Important because our _byUuid/_byE164
// lookups aren't up-to-date as the change happens; just a little bit
// after.
setTimeout(
() => conversationChanged(conversation.id, conversation.format()),
1
);
}); });
convoCollection.on('reset', removeAllConversations); convoCollection.on('reset', removeAllConversations);

View file

@ -487,7 +487,7 @@ export default class AccountManager extends EventTarget {
readReceipts?: boolean | null, readReceipts?: boolean | null,
options: { accessKey?: ArrayBuffer; uuid?: string } = {} options: { accessKey?: ArrayBuffer; uuid?: string } = {}
): Promise<void> { ): Promise<void> {
const { accessKey } = options; const { accessKey, uuid } = options;
let password = btoa( let password = btoa(
utils.getString(window.libsignal.crypto.getRandomBytes(16)) utils.getString(window.libsignal.crypto.getRandomBytes(16))
); );
@ -526,8 +526,7 @@ export default class AccountManager extends EventTarget {
); );
const numberChanged = previousNumber && previousNumber !== number; const numberChanged = previousNumber && previousNumber !== number;
const uuidChanged = const uuidChanged = previousUuid && uuid && previousUuid !== uuid;
previousUuid && response.uuid && previousUuid !== response.uuid;
if (numberChanged || uuidChanged) { if (numberChanged || uuidChanged) {
if (numberChanged) { if (numberChanged) {
@ -576,10 +575,9 @@ export default class AccountManager extends EventTarget {
deviceName deviceName
); );
const setUuid = response.uuid; if (uuid) {
if (setUuid) {
await window.textsecure.storage.user.setUuidAndDeviceId( await window.textsecure.storage.user.setUuidAndDeviceId(
setUuid, uuid,
response.deviceId || 1 response.deviceId || 1
); );
} }

View file

@ -66,6 +66,7 @@ class ProvisioningCipherInner {
const ret: ProvisionDecryptResult = { const ret: ProvisionDecryptResult = {
identityKeyPair: keyPair, identityKeyPair: keyPair,
number: provisionMessage.number, number: provisionMessage.number,
uuid: provisionMessage.uuid,
provisioningCode: provisionMessage.provisioningCode, provisioningCode: provisionMessage.provisioningCode,
userAgent: provisionMessage.userAgent, userAgent: provisionMessage.userAgent,
readReceipts: provisionMessage.readReceipts, readReceipts: provisionMessage.readReceipts,

View file

@ -2366,6 +2366,7 @@ export function initialize({
password: auth.password, password: auth.password,
responseType: 'jsonwithdetails', responseType: 'jsonwithdetails',
data, data,
timeout: 30000,
version, version,
}); });
@ -2489,6 +2490,7 @@ export function initialize({
user: directoryAuth.username, user: directoryAuth.username,
password: directoryAuth.password, password: directoryAuth.password,
responseType: 'json', responseType: 'json',
timeout: 30000,
data: JSON.stringify(data), data: JSON.stringify(data),
version, version,
}); });