Don't always show an error on manual contact sync
This commit is contained in:
parent
a82fa86176
commit
e0415de893
5 changed files with 60 additions and 31 deletions
|
@ -312,6 +312,10 @@
|
||||||
await window.makeSyncRequest();
|
await window.makeSyncRequest();
|
||||||
this.onsuccess();
|
this.onsuccess();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
window.log.error(
|
||||||
|
'settings sync timeout error:',
|
||||||
|
error && error.stack ? error.stack : error
|
||||||
|
);
|
||||||
this.ontimeout();
|
this.ontimeout();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -365,7 +365,7 @@ export async function startApp(): Promise<void> {
|
||||||
onChangeTheme();
|
onChangeTheme();
|
||||||
},
|
},
|
||||||
getHideMenuBar: () => window.storage.get('hide-menu-bar'),
|
getHideMenuBar: () => window.storage.get('hide-menu-bar'),
|
||||||
setHideMenuBar: (value: WhatIsThis) => {
|
setHideMenuBar: (value: boolean) => {
|
||||||
window.storage.put('hide-menu-bar', value);
|
window.storage.put('hide-menu-bar', value);
|
||||||
window.setAutoHideMenuBar(value);
|
window.setAutoHideMenuBar(value);
|
||||||
window.setMenuBarVisibility(!value);
|
window.setMenuBarVisibility(!value);
|
||||||
|
@ -373,53 +373,56 @@ export async function startApp(): Promise<void> {
|
||||||
|
|
||||||
getNotificationSetting: () =>
|
getNotificationSetting: () =>
|
||||||
window.storage.get('notification-setting', 'message'),
|
window.storage.get('notification-setting', 'message'),
|
||||||
setNotificationSetting: (value: WhatIsThis) =>
|
setNotificationSetting: (value: 'message' | 'name' | 'count' | 'off') =>
|
||||||
window.storage.put('notification-setting', value),
|
window.storage.put('notification-setting', value),
|
||||||
getNotificationDrawAttention: () =>
|
getNotificationDrawAttention: () =>
|
||||||
window.storage.get('notification-draw-attention', true),
|
window.storage.get('notification-draw-attention', true),
|
||||||
setNotificationDrawAttention: (value: WhatIsThis) =>
|
setNotificationDrawAttention: (value: boolean) =>
|
||||||
window.storage.put('notification-draw-attention', value),
|
window.storage.put('notification-draw-attention', value),
|
||||||
getAudioNotification: () => window.storage.get('audio-notification'),
|
getAudioNotification: () => window.storage.get('audio-notification'),
|
||||||
setAudioNotification: (value: WhatIsThis) =>
|
setAudioNotification: (value: boolean) =>
|
||||||
window.storage.put('audio-notification', value),
|
window.storage.put('audio-notification', value),
|
||||||
getCountMutedConversations: () =>
|
getCountMutedConversations: () =>
|
||||||
window.storage.get('badge-count-muted-conversations', false),
|
window.storage.get('badge-count-muted-conversations', false),
|
||||||
setCountMutedConversations: (value: WhatIsThis) => {
|
setCountMutedConversations: (value: boolean) => {
|
||||||
window.storage.put('badge-count-muted-conversations', value);
|
window.storage.put('badge-count-muted-conversations', value);
|
||||||
window.Whisper.events.trigger('updateUnreadCount');
|
window.Whisper.events.trigger('updateUnreadCount');
|
||||||
},
|
},
|
||||||
getCallRingtoneNotification: () =>
|
getCallRingtoneNotification: () =>
|
||||||
window.storage.get('call-ringtone-notification', true),
|
window.storage.get('call-ringtone-notification', true),
|
||||||
setCallRingtoneNotification: (value: WhatIsThis) =>
|
setCallRingtoneNotification: (value: boolean) =>
|
||||||
window.storage.put('call-ringtone-notification', value),
|
window.storage.put('call-ringtone-notification', value),
|
||||||
getCallSystemNotification: () =>
|
getCallSystemNotification: () =>
|
||||||
window.storage.get('call-system-notification', true),
|
window.storage.get('call-system-notification', true),
|
||||||
setCallSystemNotification: (value: WhatIsThis) =>
|
setCallSystemNotification: (value: boolean) =>
|
||||||
window.storage.put('call-system-notification', value),
|
window.storage.put('call-system-notification', value),
|
||||||
getIncomingCallNotification: () =>
|
getIncomingCallNotification: () =>
|
||||||
window.storage.get('incoming-call-notification', true),
|
window.storage.get('incoming-call-notification', true),
|
||||||
setIncomingCallNotification: (value: WhatIsThis) =>
|
setIncomingCallNotification: (value: boolean) =>
|
||||||
window.storage.put('incoming-call-notification', value),
|
window.storage.put('incoming-call-notification', value),
|
||||||
|
|
||||||
getSpellCheck: () => window.storage.get('spell-check', true),
|
getSpellCheck: () => window.storage.get('spell-check', true),
|
||||||
setSpellCheck: (value: WhatIsThis) => {
|
setSpellCheck: (value: boolean) => {
|
||||||
window.storage.put('spell-check', value);
|
window.storage.put('spell-check', value);
|
||||||
},
|
},
|
||||||
|
|
||||||
getAlwaysRelayCalls: () => window.storage.get('always-relay-calls'),
|
getAlwaysRelayCalls: () => window.storage.get('always-relay-calls'),
|
||||||
setAlwaysRelayCalls: (value: WhatIsThis) =>
|
setAlwaysRelayCalls: (value: boolean) =>
|
||||||
window.storage.put('always-relay-calls', value),
|
window.storage.put('always-relay-calls', value),
|
||||||
|
|
||||||
// eslint-disable-next-line eqeqeq
|
// eslint-disable-next-line eqeqeq
|
||||||
isPrimary: () => window.textsecure.storage.user.getDeviceId() == '1',
|
isPrimary: () => window.textsecure.storage.user.getDeviceId() == '1',
|
||||||
getSyncRequest: () =>
|
getSyncRequest: () =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise<void>((resolve, reject) => {
|
||||||
const syncRequest = window.getSyncRequest();
|
const FIVE_MINUTES = 5 * 60 * 60 * 1000;
|
||||||
syncRequest.addEventListener('success', resolve);
|
const syncRequest = window.getSyncRequest(FIVE_MINUTES);
|
||||||
syncRequest.addEventListener('timeout', reject);
|
syncRequest.addEventListener('success', () => resolve());
|
||||||
|
syncRequest.addEventListener('timeout', () =>
|
||||||
|
reject(new Error('timeout'))
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
getLastSyncTime: () => window.storage.get('synced_at'),
|
getLastSyncTime: () => window.storage.get('synced_at'),
|
||||||
setLastSyncTime: (value: WhatIsThis) =>
|
setLastSyncTime: (value: number) =>
|
||||||
window.storage.put('synced_at', value),
|
window.storage.put('synced_at', value),
|
||||||
|
|
||||||
addDarkOverlay: () => {
|
addDarkOverlay: () => {
|
||||||
|
@ -1602,10 +1605,11 @@ export async function startApp(): Promise<void> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.getSyncRequest = () => {
|
window.getSyncRequest = (timeoutMillis?: number) => {
|
||||||
const syncRequest = new window.textsecure.SyncRequest(
|
const syncRequest = new window.textsecure.SyncRequest(
|
||||||
window.textsecure.messaging,
|
window.textsecure.messaging,
|
||||||
messageReceiver
|
messageReceiver,
|
||||||
|
timeoutMillis
|
||||||
);
|
);
|
||||||
syncRequest.start();
|
syncRequest.start();
|
||||||
return syncRequest;
|
return syncRequest;
|
||||||
|
@ -1822,7 +1826,9 @@ export async function startApp(): Promise<void> {
|
||||||
addQueuedEventListener('message', onMessageReceived);
|
addQueuedEventListener('message', onMessageReceived);
|
||||||
addQueuedEventListener('delivery', onDeliveryReceipt);
|
addQueuedEventListener('delivery', onDeliveryReceipt);
|
||||||
addQueuedEventListener('contact', onContactReceived);
|
addQueuedEventListener('contact', onContactReceived);
|
||||||
|
addQueuedEventListener('contactsync', onContactSyncComplete);
|
||||||
addQueuedEventListener('group', onGroupReceived);
|
addQueuedEventListener('group', onGroupReceived);
|
||||||
|
addQueuedEventListener('groupsync', onGroupSyncComplete);
|
||||||
addQueuedEventListener('sent', onSentMessage);
|
addQueuedEventListener('sent', onSentMessage);
|
||||||
addQueuedEventListener('readSync', onReadSync);
|
addQueuedEventListener('readSync', onReadSync);
|
||||||
addQueuedEventListener('read', onReadReceipt);
|
addQueuedEventListener('read', onReadReceipt);
|
||||||
|
@ -2334,6 +2340,11 @@ export async function startApp(): Promise<void> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onContactSyncComplete() {
|
||||||
|
window.log.info('onContactSyncComplete');
|
||||||
|
await window.storage.put('synced_at', Date.now());
|
||||||
|
}
|
||||||
|
|
||||||
async function onContactReceived(ev: WhatIsThis) {
|
async function onContactReceived(ev: WhatIsThis) {
|
||||||
const details = ev.contactDetails;
|
const details = ev.contactDetails;
|
||||||
|
|
||||||
|
@ -2466,6 +2477,11 @@ export async function startApp(): Promise<void> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onGroupSyncComplete() {
|
||||||
|
window.log.info('onGroupSyncComplete');
|
||||||
|
await window.storage.put('synced_at', Date.now());
|
||||||
|
}
|
||||||
|
|
||||||
// Note: this handler is only for v1 groups received via 'group sync' messages
|
// Note: this handler is only for v1 groups received via 'group sync' messages
|
||||||
async function onGroupReceived(ev: WhatIsThis) {
|
async function onGroupReceived(ev: WhatIsThis) {
|
||||||
const details = ev.groupDetails;
|
const details = ev.groupDetails;
|
||||||
|
|
|
@ -24,9 +24,12 @@ class SyncRequestInner extends EventTarget {
|
||||||
|
|
||||||
ongroup: Function;
|
ongroup: Function;
|
||||||
|
|
||||||
|
timeoutMillis: number;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private sender: MessageSender,
|
private sender: MessageSender,
|
||||||
private receiver: MessageReceiver
|
private receiver: MessageReceiver,
|
||||||
|
timeoutMillis?: number
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -44,6 +47,8 @@ class SyncRequestInner extends EventTarget {
|
||||||
|
|
||||||
this.ongroup = this.onGroupSyncComplete.bind(this);
|
this.ongroup = this.onGroupSyncComplete.bind(this);
|
||||||
receiver.addEventListener('groupsync', this.ongroup);
|
receiver.addEventListener('groupsync', this.ongroup);
|
||||||
|
|
||||||
|
this.timeoutMillis = timeoutMillis || 60000;
|
||||||
}
|
}
|
||||||
|
|
||||||
async start(): Promise<void> {
|
async start(): Promise<void> {
|
||||||
|
@ -81,7 +86,7 @@ class SyncRequestInner extends EventTarget {
|
||||||
error && error.stack ? error.stack : error
|
error && error.stack ? error.stack : error
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
this.timeout = setTimeout(this.onTimeout.bind(this), 60000);
|
this.timeout = setTimeout(this.onTimeout.bind(this), this.timeoutMillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
onContactSyncComplete() {
|
onContactSyncComplete() {
|
||||||
|
@ -125,8 +130,12 @@ export default class SyncRequest {
|
||||||
|
|
||||||
removeEventListener: (name: string, handler: Function) => void;
|
removeEventListener: (name: string, handler: Function) => void;
|
||||||
|
|
||||||
constructor(sender: MessageSender, receiver: MessageReceiver) {
|
constructor(
|
||||||
const inner = new SyncRequestInner(sender, receiver);
|
sender: MessageSender,
|
||||||
|
receiver: MessageReceiver,
|
||||||
|
timeoutMillis?: number
|
||||||
|
) {
|
||||||
|
const inner = new SyncRequestInner(sender, receiver, timeoutMillis);
|
||||||
this.inner = inner;
|
this.inner = inner;
|
||||||
this.addEventListener = inner.addEventListener.bind(inner);
|
this.addEventListener = inner.addEventListener.bind(inner);
|
||||||
this.removeEventListener = inner.removeEventListener.bind(inner);
|
this.removeEventListener = inner.removeEventListener.bind(inner);
|
||||||
|
|
|
@ -17100,7 +17100,7 @@
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
"path": "ts/textsecure/SyncRequest.js",
|
"path": "ts/textsecure/SyncRequest.js",
|
||||||
"line": " wrap(sender.sendRequestConfigurationSyncMessage(sendOptions));",
|
"line": " wrap(sender.sendRequestConfigurationSyncMessage(sendOptions));",
|
||||||
"lineNumber": 43,
|
"lineNumber": 44,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2020-04-05T23:45:16.746Z"
|
"updated": "2020-04-05T23:45:16.746Z"
|
||||||
},
|
},
|
||||||
|
@ -17108,7 +17108,7 @@
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
"path": "ts/textsecure/SyncRequest.js",
|
"path": "ts/textsecure/SyncRequest.js",
|
||||||
"line": " wrap(sender.sendRequestBlockSyncMessage(sendOptions));",
|
"line": " wrap(sender.sendRequestBlockSyncMessage(sendOptions));",
|
||||||
"lineNumber": 45,
|
"lineNumber": 46,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2020-04-05T23:45:16.746Z"
|
"updated": "2020-04-05T23:45:16.746Z"
|
||||||
},
|
},
|
||||||
|
@ -17116,7 +17116,7 @@
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
"path": "ts/textsecure/SyncRequest.js",
|
"path": "ts/textsecure/SyncRequest.js",
|
||||||
"line": " wrap(sender.sendRequestContactSyncMessage(sendOptions))",
|
"line": " wrap(sender.sendRequestContactSyncMessage(sendOptions))",
|
||||||
"lineNumber": 47,
|
"lineNumber": 48,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2020-04-05T23:45:16.746Z"
|
"updated": "2020-04-05T23:45:16.746Z"
|
||||||
},
|
},
|
||||||
|
@ -17124,7 +17124,7 @@
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
"path": "ts/textsecure/SyncRequest.js",
|
"path": "ts/textsecure/SyncRequest.js",
|
||||||
"line": " return wrap(sender.sendRequestGroupSyncMessage(sendOptions));",
|
"line": " return wrap(sender.sendRequestGroupSyncMessage(sendOptions));",
|
||||||
"lineNumber": 50,
|
"lineNumber": 51,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2020-04-05T23:45:16.746Z"
|
"updated": "2020-04-05T23:45:16.746Z"
|
||||||
},
|
},
|
||||||
|
@ -17132,7 +17132,7 @@
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
"path": "ts/textsecure/SyncRequest.ts",
|
"path": "ts/textsecure/SyncRequest.ts",
|
||||||
"line": " wrap(sender.sendRequestConfigurationSyncMessage(sendOptions));",
|
"line": " wrap(sender.sendRequestConfigurationSyncMessage(sendOptions));",
|
||||||
"lineNumber": 67,
|
"lineNumber": 72,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2020-04-05T23:45:16.746Z"
|
"updated": "2020-04-05T23:45:16.746Z"
|
||||||
},
|
},
|
||||||
|
@ -17140,7 +17140,7 @@
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
"path": "ts/textsecure/SyncRequest.ts",
|
"path": "ts/textsecure/SyncRequest.ts",
|
||||||
"line": " wrap(sender.sendRequestBlockSyncMessage(sendOptions));",
|
"line": " wrap(sender.sendRequestBlockSyncMessage(sendOptions));",
|
||||||
"lineNumber": 70,
|
"lineNumber": 75,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2020-04-05T23:45:16.746Z"
|
"updated": "2020-04-05T23:45:16.746Z"
|
||||||
},
|
},
|
||||||
|
@ -17148,7 +17148,7 @@
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
"path": "ts/textsecure/SyncRequest.ts",
|
"path": "ts/textsecure/SyncRequest.ts",
|
||||||
"line": " wrap(sender.sendRequestContactSyncMessage(sendOptions))",
|
"line": " wrap(sender.sendRequestContactSyncMessage(sendOptions))",
|
||||||
"lineNumber": 73,
|
"lineNumber": 78,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2020-04-05T23:45:16.746Z"
|
"updated": "2020-04-05T23:45:16.746Z"
|
||||||
},
|
},
|
||||||
|
@ -17156,7 +17156,7 @@
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
"path": "ts/textsecure/SyncRequest.ts",
|
"path": "ts/textsecure/SyncRequest.ts",
|
||||||
"line": " return wrap(sender.sendRequestGroupSyncMessage(sendOptions));",
|
"line": " return wrap(sender.sendRequestGroupSyncMessage(sendOptions));",
|
||||||
"lineNumber": 76,
|
"lineNumber": 81,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2020-04-05T23:45:16.746Z"
|
"updated": "2020-04-05T23:45:16.746Z"
|
||||||
},
|
},
|
||||||
|
@ -17284,4 +17284,4 @@
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2021-04-06T23:11:04.431Z"
|
"updated": "2021-04-06T23:11:04.431Z"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
2
ts/window.d.ts
vendored
2
ts/window.d.ts
vendored
|
@ -170,7 +170,7 @@ declare global {
|
||||||
getServerPublicParams: () => string;
|
getServerPublicParams: () => string;
|
||||||
getSfuUrl: () => string;
|
getSfuUrl: () => string;
|
||||||
getSocketStatus: () => number;
|
getSocketStatus: () => number;
|
||||||
getSyncRequest: () => SyncRequest;
|
getSyncRequest: (timeoutMillis?: number) => SyncRequest;
|
||||||
getTitle: () => string;
|
getTitle: () => string;
|
||||||
waitForEmptyEventQueue: () => Promise<void>;
|
waitForEmptyEventQueue: () => Promise<void>;
|
||||||
getVersion: () => string;
|
getVersion: () => string;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue