Skip to content

Commit

Permalink
Adjust timeouts for better performance
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg-signal authored Jan 11, 2021
1 parent 172598b commit 3a726ad
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
10 changes: 9 additions & 1 deletion ts/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
10 changes: 4 additions & 6 deletions ts/textsecure/AccountManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
);
}
Expand Down
1 change: 1 addition & 0 deletions ts/textsecure/ProvisioningCipher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions ts/textsecure/WebAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2366,6 +2366,7 @@ export function initialize({
password: auth.password,
responseType: 'jsonwithdetails',
data,
timeout: 30000,
version,
});

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

0 comments on commit 3a726ad

Please sign in to comment.