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) {
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);

View file

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

View file

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

View file

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