|
|
|
@ -62,34 +62,24 @@ export const forceSyncConfigurationNowIfNeeded = async (
|
|
|
|
|
) =>
|
|
|
|
|
new Promise(resolve => {
|
|
|
|
|
const allConvos = ConversationController.getInstance().getConversations();
|
|
|
|
|
|
|
|
|
|
void getCurrentConfigurationMessage(allConvos)
|
|
|
|
|
.then(configMessage => {
|
|
|
|
|
// console.warn('forceSyncConfigurationNowIfNeeded with', configMessage);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// this just adds the message to the sending queue.
|
|
|
|
|
// if waitForMessageSent is set, we need to effectively wait until then
|
|
|
|
|
// tslint:disable-next-line: no-void-expression
|
|
|
|
|
const callback = waitForMessageSent
|
|
|
|
|
? () => {
|
|
|
|
|
resolve(true);
|
|
|
|
|
}
|
|
|
|
|
: undefined;
|
|
|
|
|
void getMessageQueue().sendSyncMessage(
|
|
|
|
|
configMessage,
|
|
|
|
|
callback as any
|
|
|
|
|
);
|
|
|
|
|
// either we resolve from the callback if we need to wait for it,
|
|
|
|
|
// or we don't want to wait, we resolve it here.
|
|
|
|
|
if (!waitForMessageSent) {
|
|
|
|
|
resolve(true);
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
window.log.warn(
|
|
|
|
|
'Caught an error while sending our ConfigurationMessage:',
|
|
|
|
|
e
|
|
|
|
|
);
|
|
|
|
|
resolve(false);
|
|
|
|
|
// this just adds the message to the sending queue.
|
|
|
|
|
// if waitForMessageSent is set, we need to effectively wait until then
|
|
|
|
|
// tslint:disable-next-line: no-void-expression
|
|
|
|
|
const callback = waitForMessageSent
|
|
|
|
|
? () => {
|
|
|
|
|
resolve(true);
|
|
|
|
|
}
|
|
|
|
|
: undefined;
|
|
|
|
|
void getMessageQueue().sendSyncMessage(configMessage, callback as any);
|
|
|
|
|
// either we resolve from the callback if we need to wait for it,
|
|
|
|
|
// or we don't want to wait, we resolve it here.
|
|
|
|
|
if (!waitForMessageSent) {
|
|
|
|
|
resolve(true);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catch(e => {
|
|
|
|
|