Add no-misused/floating-promises lint rule

This commit is contained in:
Fedor Indutny 2022-12-21 10:41:48 -08:00 committed by GitHub
parent 1a68c3db62
commit ed271d92ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
150 changed files with 1296 additions and 991 deletions

View file

@ -188,6 +188,17 @@ const typescriptRules = {
'@typescript-eslint/no-redeclare': 'error', '@typescript-eslint/no-redeclare': 'error',
'@typescript-eslint/no-shadow': 'error', '@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/no-useless-constructor': ['error'], '@typescript-eslint/no-useless-constructor': ['error'],
'@typescript-eslint/no-misused-promises': [
'error',
{
checksVoidReturn: false
}
],
'@typescript-eslint/no-floating-promises': 'error',
// We allow "void promise", but new call-sites should use `drop(promise)`.
'no-void': ['error', { 'allowAsStatement': true }],
'no-shadow': 'off', 'no-shadow': 'off',
'no-useless-constructor': 'off', 'no-useless-constructor': 'off',

View file

@ -178,7 +178,7 @@ function deleteOrphanedAttachments({
} }
// Intentionally not awaiting // Intentionally not awaiting
runSafe(); void runSafe();
} }
export function initialize({ export function initialize({

View file

@ -43,6 +43,7 @@ import { redactAll, addSensitivePath } from '../ts/util/privacy';
import { createSupportUrl } from '../ts/util/createSupportUrl'; import { createSupportUrl } from '../ts/util/createSupportUrl';
import { missingCaseError } from '../ts/util/missingCaseError'; import { missingCaseError } from '../ts/util/missingCaseError';
import { strictAssert } from '../ts/util/assert'; import { strictAssert } from '../ts/util/assert';
import { drop } from '../ts/util/drop';
import { consoleLogger } from '../ts/util/consoleLogger'; import { consoleLogger } from '../ts/util/consoleLogger';
import type { ThemeSettingType } from '../ts/types/StorageUIKeys'; import type { ThemeSettingType } from '../ts/types/StorageUIKeys';
import { ThemeType } from '../ts/types/Util'; import { ThemeType } from '../ts/types/Util';
@ -483,10 +484,10 @@ function handleCommonWindowEvents(
window.webContents.on('will-navigate', (event, rawTarget) => { window.webContents.on('will-navigate', (event, rawTarget) => {
event.preventDefault(); event.preventDefault();
handleUrl(rawTarget); drop(handleUrl(rawTarget));
}); });
window.webContents.setWindowOpenHandler(({ url }) => { window.webContents.setWindowOpenHandler(({ url }) => {
handleUrl(url); drop(handleUrl(url));
return { action: 'deny' }; return { action: 'deny' };
}); });
window.webContents.on( window.webContents.on(
@ -526,9 +527,11 @@ function handleCommonWindowEvents(
return; return;
} }
drop(
settingsChannel?.invokeCallbackInMainWindow('persistZoomFactor', [ settingsChannel?.invokeCallbackInMainWindow('persistZoomFactor', [
zoomFactor, zoomFactor,
]); ])
);
lastZoomFactor = zoomFactor; lastZoomFactor = zoomFactor;
}; };
@ -800,12 +803,6 @@ async function createWindow() {
mainWindow.on('resize', captureWindowStats); mainWindow.on('resize', captureWindowStats);
mainWindow.on('move', captureWindowStats); mainWindow.on('move', captureWindowStats);
if (getEnvironment() === Environment.Test) {
mainWindow.loadURL(await prepareFileUrl([__dirname, '../test/index.html']));
} else {
mainWindow.loadURL(await prepareFileUrl([__dirname, '../background.html']));
}
if (!enableCI && config.get<boolean>('openDevTools')) { if (!enableCI && config.get<boolean>('openDevTools')) {
// Open the DevTools. // Open the DevTools.
mainWindow.webContents.openDevTools(); mainWindow.webContents.openDevTools();
@ -932,6 +929,16 @@ async function createWindow() {
mainWindow.show(); mainWindow.show();
} }
}); });
if (getEnvironment() === Environment.Test) {
await mainWindow.loadURL(
await prepareFileUrl([__dirname, '../test/index.html'])
);
} else {
await mainWindow.loadURL(
await prepareFileUrl([__dirname, '../background.html'])
);
}
} }
// Renderer asks if we are done with the database // Renderer asks if we are done with the database
@ -1056,12 +1063,14 @@ const TEN_MINUTES = 10 * 60 * 1000;
setTimeout(readyForUpdates, TEN_MINUTES); setTimeout(readyForUpdates, TEN_MINUTES);
function openContactUs() { function openContactUs() {
shell.openExternal(createSupportUrl({ locale: app.getLocale() })); drop(shell.openExternal(createSupportUrl({ locale: app.getLocale() })));
} }
function openJoinTheBeta() { function openJoinTheBeta() {
// If we omit the language, the site will detect the language and redirect // If we omit the language, the site will detect the language and redirect
shell.openExternal('https://support.signal.org/hc/articles/360007318471'); drop(
shell.openExternal('https://support.signal.org/hc/articles/360007318471')
);
} }
function openReleaseNotes() { function openReleaseNotes() {
@ -1070,18 +1079,22 @@ function openReleaseNotes() {
return; return;
} }
drop(
shell.openExternal( shell.openExternal(
`https://github.com/signalapp/Signal-Desktop/releases/tag/v${app.getVersion()}` `https://github.com/signalapp/Signal-Desktop/releases/tag/v${app.getVersion()}`
)
); );
} }
function openSupportPage() { function openSupportPage() {
// If we omit the language, the site will detect the language and redirect // If we omit the language, the site will detect the language and redirect
shell.openExternal('https://support.signal.org/hc/sections/360001602812'); drop(
shell.openExternal('https://support.signal.org/hc/sections/360001602812')
);
} }
function openForums() { function openForums() {
shell.openExternal('https://community.signalusers.org/'); drop(shell.openExternal('https://community.signalusers.org/'));
} }
function showKeyboardShortcuts() { function showKeyboardShortcuts() {
@ -1143,10 +1156,6 @@ async function showScreenShareWindow(sourceName: string) {
handleCommonWindowEvents(screenShareWindow); handleCommonWindowEvents(screenShareWindow);
screenShareWindow.loadURL(
await prepareFileUrl([__dirname, '../screenShare.html'])
);
screenShareWindow.on('closed', () => { screenShareWindow.on('closed', () => {
screenShareWindow = undefined; screenShareWindow = undefined;
}); });
@ -1160,6 +1169,10 @@ async function showScreenShareWindow(sourceName: string) {
); );
} }
}); });
await screenShareWindow.loadURL(
await prepareFileUrl([__dirname, '../screenShare.html'])
);
} }
let aboutWindow: BrowserWindow | undefined; let aboutWindow: BrowserWindow | undefined;
@ -1196,8 +1209,6 @@ async function showAbout() {
handleCommonWindowEvents(aboutWindow, titleBarOverlay); handleCommonWindowEvents(aboutWindow, titleBarOverlay);
aboutWindow.loadURL(await prepareFileUrl([__dirname, '../about.html']));
aboutWindow.on('closed', () => { aboutWindow.on('closed', () => {
aboutWindow = undefined; aboutWindow = undefined;
}); });
@ -1207,6 +1218,8 @@ async function showAbout() {
aboutWindow.show(); aboutWindow.show();
} }
}); });
await aboutWindow.loadURL(await prepareFileUrl([__dirname, '../about.html']));
} }
let settingsWindow: BrowserWindow | undefined; let settingsWindow: BrowserWindow | undefined;
@ -1244,8 +1257,6 @@ async function showSettingsWindow() {
handleCommonWindowEvents(settingsWindow, titleBarOverlay); handleCommonWindowEvents(settingsWindow, titleBarOverlay);
settingsWindow.loadURL(await prepareFileUrl([__dirname, '../settings.html']));
settingsWindow.on('closed', () => { settingsWindow.on('closed', () => {
settingsWindow = undefined; settingsWindow = undefined;
}); });
@ -1258,6 +1269,10 @@ async function showSettingsWindow() {
settingsWindow.show(); settingsWindow.show();
}); });
await settingsWindow.loadURL(
await prepareFileUrl([__dirname, '../settings.html'])
);
} }
async function getIsLinked() { async function getIsLinked() {
@ -1275,7 +1290,7 @@ async function showStickerCreator() {
if (!(await getIsLinked())) { if (!(await getIsLinked())) {
const message = getLocale().i18n('StickerCreator--Authentication--error'); const message = getLocale().i18n('StickerCreator--Authentication--error');
dialog.showMessageBox({ await dialog.showMessageBox({
type: 'warning', type: 'warning',
message, message,
}); });
@ -1327,8 +1342,6 @@ async function showStickerCreator() {
) )
: prepareFileUrl([__dirname, '../sticker-creator/dist/index.html']); : prepareFileUrl([__dirname, '../sticker-creator/dist/index.html']);
stickerCreatorWindow.loadURL(await appUrl);
stickerCreatorWindow.on('closed', () => { stickerCreatorWindow.on('closed', () => {
stickerCreatorWindow = undefined; stickerCreatorWindow = undefined;
}); });
@ -1345,6 +1358,8 @@ async function showStickerCreator() {
stickerCreatorWindow.webContents.openDevTools(); stickerCreatorWindow.webContents.openDevTools();
} }
}); });
await stickerCreatorWindow.loadURL(await appUrl);
} }
let debugLogWindow: BrowserWindow | undefined; let debugLogWindow: BrowserWindow | undefined;
@ -1387,10 +1402,6 @@ async function showDebugLogWindow() {
handleCommonWindowEvents(debugLogWindow, titleBarOverlay); handleCommonWindowEvents(debugLogWindow, titleBarOverlay);
debugLogWindow.loadURL(
await prepareFileUrl([__dirname, '../debug_log.html'])
);
debugLogWindow.on('closed', () => { debugLogWindow.on('closed', () => {
debugLogWindow = undefined; debugLogWindow = undefined;
}); });
@ -1403,6 +1414,10 @@ async function showDebugLogWindow() {
debugLogWindow.center(); debugLogWindow.center();
} }
}); });
await debugLogWindow.loadURL(
await prepareFileUrl([__dirname, '../debug_log.html'])
);
} }
let permissionsPopupWindow: BrowserWindow | undefined; let permissionsPopupWindow: BrowserWindow | undefined;
@ -1446,13 +1461,6 @@ function showPermissionsPopupWindow(forCalling: boolean, forCamera: boolean) {
handleCommonWindowEvents(permissionsPopupWindow); handleCommonWindowEvents(permissionsPopupWindow);
permissionsPopupWindow.loadURL(
await prepareFileUrl([__dirname, '../permissions_popup.html'], {
forCalling,
forCamera,
})
);
permissionsPopupWindow.on('closed', () => { permissionsPopupWindow.on('closed', () => {
removeDarkOverlay(); removeDarkOverlay();
permissionsPopupWindow = undefined; permissionsPopupWindow = undefined;
@ -1466,6 +1474,13 @@ function showPermissionsPopupWindow(forCalling: boolean, forCamera: boolean) {
permissionsPopupWindow.show(); permissionsPopupWindow.show();
} }
}); });
await permissionsPopupWindow.loadURL(
await prepareFileUrl([__dirname, '../permissions_popup.html'], {
forCalling,
forCamera,
})
);
}); });
} }
@ -1529,7 +1544,7 @@ async function initializeSQL(
} }
// Only if we've initialized things successfully do we set up the corruption handler // Only if we've initialized things successfully do we set up the corruption handler
runSQLCorruptionHandler(); drop(runSQLCorruptionHandler());
return { ok: true, error: undefined }; return { ok: true, error: undefined };
} }
@ -1539,7 +1554,7 @@ const onDatabaseError = async (error: string) => {
ready = false; ready = false;
if (mainWindow) { if (mainWindow) {
settingsChannel?.invokeCallbackInMainWindow('closeDB', []); drop(settingsChannel?.invokeCallbackInMainWindow('closeDB', []));
mainWindow.close(); mainWindow.close();
} }
mainWindow = undefined; mainWindow = undefined;
@ -1577,7 +1592,7 @@ let sqlInitPromise:
| undefined; | undefined;
ipc.on('database-error', (_event: Electron.Event, error: string) => { ipc.on('database-error', (_event: Electron.Event, error: string) => {
onDatabaseError(error); drop(onDatabaseError(error));
}); });
function getAppLocale(): string { function getAppLocale(): string {
@ -1754,6 +1769,7 @@ app.on('ready', async () => {
// lookup should be done only in ephemeral config. // lookup should be done only in ephemeral config.
const backgroundColor = await getBackgroundColor({ ephemeralOnly: true }); const backgroundColor = await getBackgroundColor({ ephemeralOnly: true });
drop(
// eslint-disable-next-line more/no-then // eslint-disable-next-line more/no-then
Promise.race([sqlInitPromise, timeout]).then(async maybeTimeout => { Promise.race([sqlInitPromise, timeout]).then(async maybeTimeout => {
if (maybeTimeout !== 'timeout') { if (maybeTimeout !== 'timeout') {
@ -1792,8 +1808,11 @@ app.on('ready', async () => {
loadingWindow = undefined; loadingWindow = undefined;
}); });
loadingWindow.loadURL(await prepareFileUrl([__dirname, '../loading.html'])); await loadingWindow.loadURL(
}); await prepareFileUrl([__dirname, '../loading.html'])
);
})
);
try { try {
await attachments.clearTempPath(userDataPath); await attachments.clearTempPath(userDataPath);
@ -1858,7 +1877,7 @@ app.on('ready', async () => {
shouldMinimizeToSystemTray(await systemTraySettingCache.get()) shouldMinimizeToSystemTray(await systemTraySettingCache.get())
); );
ensureFilePermissions([ await ensureFilePermissions([
'config.json', 'config.json',
'sql/db.sqlite', 'sql/db.sqlite',
'sql/db.sqlite-wal', 'sql/db.sqlite-wal',
@ -1996,7 +2015,7 @@ app.on('activate', () => {
if (mainWindow) { if (mainWindow) {
mainWindow.show(); mainWindow.show();
} else { } else {
createWindow(); drop(createWindow());
} }
}); });
@ -2122,7 +2141,7 @@ ipc.on('stop-screen-share', () => {
}); });
ipc.on('show-screen-share', (_event: Electron.Event, sourceName: string) => { ipc.on('show-screen-share', (_event: Electron.Event, sourceName: string) => {
showScreenShareWindow(sourceName); drop(showScreenShareWindow(sourceName));
}); });
ipc.on('update-tray-icon', (_event: Electron.Event, unreadCount: number) => { ipc.on('update-tray-icon', (_event: Electron.Event, unreadCount: number) => {
@ -2311,6 +2330,7 @@ async function ensureFilePermissions(onlyFiles?: Array<string>) {
// Touch each file in a queue // Touch each file in a queue
const q = new PQueue({ concurrency: 5, timeout: 1000 * 60 * 2 }); const q = new PQueue({ concurrency: 5, timeout: 1000 * 60 * 2 });
drop(
q.addAll( q.addAll(
files.map(f => async () => { files.map(f => async () => {
const isDir = f.endsWith('/'); const isDir = f.endsWith('/');
@ -2323,6 +2343,7 @@ async function ensureFilePermissions(onlyFiles?: Array<string>) {
); );
} }
}) })
)
); );
await q.onEmpty(); await q.onEmpty();
@ -2345,7 +2366,7 @@ ipc.handle('set-auto-launch', async (_event, value) => {
}); });
ipc.on('show-message-box', (_event, { type, message }) => { ipc.on('show-message-box', (_event, { type, message }) => {
dialog.showMessageBox({ type, message }); drop(dialog.showMessageBox({ type, message }));
}); });
ipc.on('show-item-in-folder', (_event, folder) => { ipc.on('show-item-in-folder', (_event, folder) => {
@ -2458,7 +2479,7 @@ ipc.handle('getMenuOptions', async () => {
ipc.handle('executeMenuAction', async (_event, action: MenuActionType) => { ipc.handle('executeMenuAction', async (_event, action: MenuActionType) => {
if (action === 'forceUpdate') { if (action === 'forceUpdate') {
forceUpdate(); drop(forceUpdate());
} else if (action === 'openContactUs') { } else if (action === 'openContactUs') {
openContactUs(); openContactUs();
} else if (action === 'openForums') { } else if (action === 'openForums') {
@ -2474,15 +2495,15 @@ ipc.handle('executeMenuAction', async (_event, action: MenuActionType) => {
} else if (action === 'setupAsStandalone') { } else if (action === 'setupAsStandalone') {
setupAsStandalone(); setupAsStandalone();
} else if (action === 'showAbout') { } else if (action === 'showAbout') {
showAbout(); drop(showAbout());
} else if (action === 'showDebugLog') { } else if (action === 'showDebugLog') {
showDebugLogWindow(); drop(showDebugLogWindow());
} else if (action === 'showKeyboardShortcuts') { } else if (action === 'showKeyboardShortcuts') {
showKeyboardShortcuts(); showKeyboardShortcuts();
} else if (action === 'showSettings') { } else if (action === 'showSettings') {
showSettingsWindow(); drop(showSettingsWindow());
} else if (action === 'showStickerCreator') { } else if (action === 'showStickerCreator') {
showStickerCreator(); drop(showStickerCreator());
} else if (action === 'showWindow') { } else if (action === 'showWindow') {
showWindow(); showWindow();
} else { } else {

View file

@ -251,8 +251,8 @@
"@types/webpack-dev-server": "3.11.3", "@types/webpack-dev-server": "3.11.3",
"@types/websocket": "1.0.0", "@types/websocket": "1.0.0",
"@types/yargs": "17.0.7", "@types/yargs": "17.0.7",
"@typescript-eslint/eslint-plugin": "5.43.0", "@typescript-eslint/eslint-plugin": "5.47.0",
"@typescript-eslint/parser": "5.43.0", "@typescript-eslint/parser": "5.47.0",
"arraybuffer-loader": "1.0.3", "arraybuffer-loader": "1.0.3",
"asar": "3.1.0", "asar": "3.1.0",
"axe-core": "4.1.4", "axe-core": "4.1.4",
@ -274,7 +274,7 @@
"electron-notarize": "1.2.1", "electron-notarize": "1.2.1",
"endanger": "7.0.4", "endanger": "7.0.4",
"esbuild": "0.15.8", "esbuild": "0.15.8",
"eslint": "8.27.0", "eslint": "8.30.0",
"eslint-config-airbnb-typescript-prettier": "5.0.0", "eslint-config-airbnb-typescript-prettier": "5.0.0",
"eslint-config-prettier": "8.5.0", "eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.26.0", "eslint-plugin-import": "2.26.0",

View file

@ -29,7 +29,7 @@ export function UploadStage(): JSX.Element {
const [complete, setComplete] = React.useState(0); const [complete, setComplete] = React.useState(0);
React.useEffect(() => { React.useEffect(() => {
(async () => { void (async () => {
const onProgress = () => { const onProgress = () => {
setComplete(i => i + 1); setComplete(i => i + 1);
}; };

View file

@ -14,6 +14,7 @@ import { DropZone } from '../elements/DropZone';
import { processStickerImage } from '../util/preload'; import { processStickerImage } from '../util/preload';
import { useI18n } from '../util/i18n'; import { useI18n } from '../util/i18n';
import { MINUTE } from '../../ts/util/durations'; import { MINUTE } from '../../ts/util/durations';
import { drop } from '../../ts/util/drop';
import * as Errors from '../../ts/types/errors'; import * as Errors from '../../ts/types/errors';
const queue = new PQueue({ concurrency: 3, timeout: MINUTE * 30 }); const queue = new PQueue({ concurrency: 3, timeout: MINUTE * 30 });
@ -58,6 +59,7 @@ const InnerGrid = SortableContainer(
async paths => { async paths => {
actions.initializeStickers(paths); actions.initializeStickers(paths);
paths.forEach(path => { paths.forEach(path => {
drop(
queue.add(async () => { queue.add(async () => {
try { try {
const stickerImage = await processStickerImage(path); const stickerImage = await processStickerImage(path);
@ -77,7 +79,8 @@ const InnerGrid = SortableContainer(
key, key,
}); });
} }
}); })
);
}); });
}, },
[actions] [actions]

View file

@ -20,6 +20,7 @@ import * as Errors from './types/errors';
import { getContactId } from './messages/helpers'; import { getContactId } from './messages/helpers';
import { maybeDeriveGroupV2Id } from './groups'; import { maybeDeriveGroupV2Id } from './groups';
import { assertDev, strictAssert } from './util/assert'; import { assertDev, strictAssert } from './util/assert';
import { drop } from './util/drop';
import { isGroupV1, isGroupV2 } from './util/whatTypeOfConversation'; import { isGroupV1, isGroupV2 } from './util/whatTypeOfConversation';
import { getConversationUnreadCountForAppBadge } from './util/getConversationUnreadCountForAppBadge'; import { getConversationUnreadCountForAppBadge } from './util/getConversationUnreadCountForAppBadge';
import { UUID, isValidUuid, UUIDKind } from './types/UUID'; import { UUID, isValidUuid, UUIDKind } from './types/UUID';
@ -193,7 +194,7 @@ export class ConversationController {
), ),
0 0
); );
window.storage.put('unreadCount', newUnreadCount); drop(window.storage.put('unreadCount', newUnreadCount));
if (newUnreadCount > 0) { if (newUnreadCount > 0) {
window.setBadgeCount(newUnreadCount); window.setBadgeCount(newUnreadCount);
@ -1119,13 +1120,13 @@ export class ConversationController {
this._conversations.resetLookups(); this._conversations.resetLookups();
current.captureChange('combineConversations'); current.captureChange('combineConversations');
current.updateLastMessage(); void current.updateLastMessage();
const titleIsUseful = Boolean( const titleIsUseful = Boolean(
obsoleteTitleInfo && getTitleNoDefault(obsoleteTitleInfo) obsoleteTitleInfo && getTitleNoDefault(obsoleteTitleInfo)
); );
if (!fromPniSignature && obsoleteTitleInfo && titleIsUseful) { if (!fromPniSignature && obsoleteTitleInfo && titleIsUseful) {
current.addConversationMerge(obsoleteTitleInfo); void current.addConversationMerge(obsoleteTitleInfo);
} }
log.warn(`${logId}: Complete!`); log.warn(`${logId}: Complete!`);
@ -1305,10 +1306,12 @@ export class ConversationController {
timeout: MINUTE * 30, timeout: MINUTE * 30,
throwOnTimeout: true, throwOnTimeout: true,
}); });
drop(
queue.addAll( queue.addAll(
temporaryConversations.map(item => async () => { temporaryConversations.map(item => async () => {
await removeConversation(item.id); await removeConversation(item.id);
}) })
)
); );
await queue.onIdle(); await queue.onIdle();

View file

@ -122,7 +122,7 @@ export const refreshRemoteConfig = async (
}; };
}, {}); }, {});
window.storage.put('remoteConfig', config); await window.storage.put('remoteConfig', config);
}; };
export const maybeRefreshRemoteConfig = throttle( export const maybeRefreshRemoteConfig = throttle(

View file

@ -1419,7 +1419,7 @@ export class SignalProtocolStore extends EventEmitter {
} }
sessionResets[id] = Date.now(); sessionResets[id] = Date.now();
window.storage.put('sessionResets', sessionResets); await window.storage.put('sessionResets', sessionResets);
try { try {
const { uuid } = qualifiedAddress; const { uuid } = qualifiedAddress;
@ -1446,7 +1446,7 @@ export class SignalProtocolStore extends EventEmitter {
// If we failed to do the session reset, then we'll allow another attempt sooner // If we failed to do the session reset, then we'll allow another attempt sooner
// than one hour from now. // than one hour from now.
delete sessionResets[id]; delete sessionResets[id];
window.storage.put('sessionResets', sessionResets); await window.storage.put('sessionResets', sessionResets);
log.error( log.error(
`lightSessionReset/${id}: Encountered error`, `lightSessionReset/${id}: Encountered error`,

View file

@ -34,6 +34,7 @@ import { DEFAULT_CONVERSATION_COLOR } from './types/Colors';
import { ThemeType } from './types/Util'; import { ThemeType } from './types/Util';
import { ChallengeHandler } from './challenge'; import { ChallengeHandler } from './challenge';
import * as durations from './util/durations'; import * as durations from './util/durations';
import { drop } from './util/drop';
import { explodePromise } from './util/explodePromise'; import { explodePromise } from './util/explodePromise';
import { isWindowDragElement } from './util/isWindowDragElement'; import { isWindowDragElement } from './util/isWindowDragElement';
import { assertDev, strictAssert } from './util/assert'; import { assertDev, strictAssert } from './util/assert';
@ -299,6 +300,7 @@ export async function startApp(): Promise<void> {
track = true track = true
): (event: E) => void { ): (event: E) => void {
return (event: E): void => { return (event: E): void => {
drop(
eventHandlerQueue.add( eventHandlerQueue.add(
createTaskWithTimeout(async () => { createTaskWithTimeout(async () => {
try { try {
@ -306,12 +308,14 @@ export async function startApp(): Promise<void> {
} finally { } finally {
// message/sent: Message.handleDataMessage has its own queue and will // message/sent: Message.handleDataMessage has its own queue and will
// trigger this event itself when complete. // trigger this event itself when complete.
// error: Error processing (below) also has its own queue and self-trigger. // error: Error processing (below) also has its own queue and
// self-trigger.
if (track) { if (track) {
window.Whisper.events.trigger('incrementProgress'); window.Whisper.events.trigger('incrementProgress');
} }
} }
}, `queuedEventListener(${event.type}, ${event.timeStamp})`) }, `queuedEventListener(${event.type}, ${event.timeStamp})`)
)
); );
}; };
} }
@ -367,13 +371,13 @@ export async function startApp(): Promise<void> {
messageReceiver.addEventListener( messageReceiver.addEventListener(
'decryption-error', 'decryption-error',
queuedEventListener((event: DecryptionErrorEvent): void => { queuedEventListener((event: DecryptionErrorEvent): void => {
onDecryptionErrorQueue.add(() => onDecryptionError(event)); drop(onDecryptionErrorQueue.add(() => onDecryptionError(event)));
}) })
); );
messageReceiver.addEventListener( messageReceiver.addEventListener(
'retry-request', 'retry-request',
queuedEventListener((event: RetryRequestEvent): void => { queuedEventListener((event: RetryRequestEvent): void => {
onRetryRequestQueue.add(() => onRetryRequest(event)); drop(onRetryRequestQueue.add(() => onRetryRequest(event)));
}) })
); );
messageReceiver.addEventListener('empty', queuedEventListener(onEmpty)); messageReceiver.addEventListener('empty', queuedEventListener(onEmpty));
@ -413,9 +417,11 @@ export async function startApp(): Promise<void> {
window.storage.onready(() => { window.storage.onready(() => {
if (!window.storage.get('defaultConversationColor')) { if (!window.storage.get('defaultConversationColor')) {
drop(
window.storage.put( window.storage.put(
'defaultConversationColor', 'defaultConversationColor',
DEFAULT_CONVERSATION_COLOR DEFAULT_CONVERSATION_COLOR
)
); );
} }
}); });
@ -549,7 +555,7 @@ export async function startApp(): Promise<void> {
KeyChangeListener.init(window.textsecure.storage.protocol); KeyChangeListener.init(window.textsecure.storage.protocol);
window.textsecure.storage.protocol.on('removePreKey', (ourUuid: UUID) => { window.textsecure.storage.protocol.on('removePreKey', (ourUuid: UUID) => {
const uuidKind = window.textsecure.storage.user.getOurUuidKind(ourUuid); const uuidKind = window.textsecure.storage.user.getOurUuidKind(ourUuid);
window.getAccountManager().refreshPreKeys(uuidKind); void window.getAccountManager().refreshPreKeys(uuidKind);
}); });
window.textsecure.storage.protocol.on('removeAllData', () => { window.textsecure.storage.protocol.on('removeAllData', () => {
@ -575,7 +581,7 @@ export async function startApp(): Promise<void> {
accountManager.addEventListener('registration', () => { accountManager.addEventListener('registration', () => {
window.Whisper.events.trigger('userChanged', false); window.Whisper.events.trigger('userChanged', false);
window.Signal.Util.Registration.markDone(); drop(window.Signal.Util.Registration.markDone());
log.info('dispatching registration event'); log.info('dispatching registration event');
window.Whisper.events.trigger('registration_done'); window.Whisper.events.trigger('registration_done');
}); });
@ -643,7 +649,7 @@ export async function startApp(): Promise<void> {
} }
log.info('Storage fetch'); log.info('Storage fetch');
window.storage.fetch(); drop(window.storage.fetch());
function mapOldThemeToNew( function mapOldThemeToNew(
theme: Readonly< theme: Readonly<
@ -675,7 +681,7 @@ export async function startApp(): Promise<void> {
strictAssert(server !== undefined, 'WebAPI not ready'); strictAssert(server !== undefined, 'WebAPI not ready');
cleanupSessionResets(); void cleanupSessionResets();
// These make key operations available to IPC handlers created in preload.js // These make key operations available to IPC handlers created in preload.js
window.Events = createIPCEvents({ window.Events = createIPCEvents({
@ -685,7 +691,7 @@ export async function startApp(): Promise<void> {
window.Signal.Util.flushMessageCounter(); window.Signal.Util.flushMessageCounter();
// Stop background processing // Stop background processing
AttachmentDownloads.stop(); void AttachmentDownloads.stop();
idleDetector.stop(); idleDetector.stop();
// Stop processing incoming messages // Stop processing incoming messages
@ -750,7 +756,7 @@ export async function startApp(): Promise<void> {
} }
// Start heartbeat timer // Start heartbeat timer
window.storage.put('lastHeartbeat', toDayMillis(Date.now())); await window.storage.put('lastHeartbeat', toDayMillis(Date.now()));
const TWELVE_HOURS = 12 * 60 * 60 * 1000; const TWELVE_HOURS = 12 * 60 * 60 * 1000;
setInterval( setInterval(
() => window.storage.put('lastHeartbeat', toDayMillis(Date.now())), () => window.storage.put('lastHeartbeat', toDayMillis(Date.now())),
@ -772,7 +778,7 @@ export async function startApp(): Promise<void> {
log.info( log.info(
`Clearing remoteBuildExpiration. Previous value was ${remoteBuildExpiration}` `Clearing remoteBuildExpiration. Previous value was ${remoteBuildExpiration}`
); );
window.storage.remove('remoteBuildExpiration'); await window.storage.remove('remoteBuildExpiration');
} }
if (window.isBeforeVersion(lastVersion, 'v1.29.2-beta.1')) { if (window.isBeforeVersion(lastVersion, 'v1.29.2-beta.1')) {
@ -795,9 +801,9 @@ export async function startApp(): Promise<void> {
const newThemeSetting = mapOldThemeToNew(themeSetting); const newThemeSetting = mapOldThemeToNew(themeSetting);
if (window.isBeforeVersion(lastVersion, 'v1.25.0')) { if (window.isBeforeVersion(lastVersion, 'v1.25.0')) {
if (newThemeSetting === window.systemTheme) { if (newThemeSetting === window.systemTheme) {
window.Events.setThemeSetting('system'); void window.Events.setThemeSetting('system');
} else { } else {
window.Events.setThemeSetting(newThemeSetting); void window.Events.setThemeSetting(newThemeSetting);
} }
} }
@ -855,7 +861,7 @@ export async function startApp(): Promise<void> {
await window.Signal.Data.cleanupOrphanedAttachments(); await window.Signal.Data.cleanupOrphanedAttachments();
// Don't block on the following operation // Don't block on the following operation
window.Signal.Data.ensureFilePermissions(); void window.Signal.Data.ensureFilePermissions();
} }
try { try {
@ -919,7 +925,7 @@ export async function startApp(): Promise<void> {
} }
}); });
window.Signal.RemoteConfig.initRemoteConfig(server); void window.Signal.RemoteConfig.initRemoteConfig(server);
let retryReceiptLifespan: number | undefined; let retryReceiptLifespan: number | undefined;
try { try {
@ -980,6 +986,7 @@ export async function startApp(): Promise<void> {
const receivedAt = Date.now(); const receivedAt = Date.now();
const receivedAtCounter = const receivedAtCounter =
window.Signal.Util.incrementMessageCounter(); window.Signal.Util.incrementMessageCounter();
drop(
conversation.queueJob('addDeliveryIssue', () => conversation.queueJob('addDeliveryIssue', () =>
conversation.addDeliveryIssue({ conversation.addDeliveryIssue({
receivedAt, receivedAt,
@ -987,6 +994,7 @@ export async function startApp(): Promise<void> {
senderUuid, senderUuid,
sentAt, sentAt,
}) })
)
); );
} }
}); });
@ -1044,7 +1052,7 @@ export async function startApp(): Promise<void> {
); );
} finally { } finally {
initializeRedux({ mainWindowStats, menuOptions }); initializeRedux({ mainWindowStats, menuOptions });
start(); void start();
window.Signal.Services.initializeNetworkObserver( window.Signal.Services.initializeNetworkObserver(
window.reduxActions.network window.reduxActions.network
); );
@ -1743,7 +1751,7 @@ export async function startApp(): Promise<void> {
shiftKey && shiftKey &&
(key === 'p' || key === 'P') (key === 'p' || key === 'P')
) { ) {
clearConversationDraftAttachments( void clearConversationDraftAttachments(
conversation.id, conversation.id,
conversation.get('draftAttachments') conversation.get('draftAttachments')
); );
@ -1799,7 +1807,7 @@ export async function startApp(): Promise<void> {
); );
window.Whisper.events.on('unlinkAndDisconnect', () => { window.Whisper.events.on('unlinkAndDisconnect', () => {
unlinkAndDisconnect(RemoveAllConfiguration.Full); void unlinkAndDisconnect(RemoveAllConfiguration.Full);
}); });
async function runStorageService() { async function runStorageService() {
@ -1834,7 +1842,7 @@ export async function startApp(): Promise<void> {
const ourE164 = ourConversation?.get('e164'); const ourE164 = ourConversation?.get('e164');
if (ourE164) { if (ourE164) {
log.warn('Restoring E164 from our conversation'); log.warn('Restoring E164 from our conversation');
window.storage.user.setNumber(ourE164); await window.storage.user.setNumber(ourE164);
} }
} }
@ -1846,7 +1854,7 @@ export async function startApp(): Promise<void> {
window.dispatchEvent(new Event('storage_ready')); window.dispatchEvent(new Event('storage_ready'));
badgeImageFileDownloader.checkForFilesToDownload(); void badgeImageFileDownloader.checkForFilesToDownload();
log.info('Expiration start timestamp cleanup: starting...'); log.info('Expiration start timestamp cleanup: starting...');
const messagesUnexpectedlyMissingExpirationStartTimestamp = const messagesUnexpectedlyMissingExpirationStartTimestamp =
@ -1895,15 +1903,15 @@ export async function startApp(): Promise<void> {
log.info('handling registration event'); log.info('handling registration event');
strictAssert(server !== undefined, 'WebAPI not ready'); strictAssert(server !== undefined, 'WebAPI not ready');
server.authenticate( void server.authenticate(
window.textsecure.storage.user.getWebAPICredentials() window.textsecure.storage.user.getWebAPICredentials()
); );
// Cancel throttled calls to refreshRemoteConfig since our auth changed. // Cancel throttled calls to refreshRemoteConfig since our auth changed.
window.Signal.RemoteConfig.maybeRefreshRemoteConfig.cancel(); window.Signal.RemoteConfig.maybeRefreshRemoteConfig.cancel();
window.Signal.RemoteConfig.maybeRefreshRemoteConfig(server); void window.Signal.RemoteConfig.maybeRefreshRemoteConfig(server);
connect(true); void connect(true);
}); });
cancelInitializationMessage(); cancelInitializationMessage();
@ -1919,11 +1927,11 @@ export async function startApp(): Promise<void> {
window.Whisper.events.trigger('timetravel'); window.Whisper.events.trigger('timetravel');
}); });
expiringMessagesDeletionService.update(); void expiringMessagesDeletionService.update();
tapToViewMessagesDeletionService.update(); void tapToViewMessagesDeletionService.update();
window.Whisper.events.on('timetravel', () => { window.Whisper.events.on('timetravel', () => {
expiringMessagesDeletionService.update(); void expiringMessagesDeletionService.update();
tapToViewMessagesDeletionService.update(); void tapToViewMessagesDeletionService.update();
}); });
const isCoreDataValid = Boolean( const isCoreDataValid = Boolean(
@ -1932,7 +1940,7 @@ export async function startApp(): Promise<void> {
); );
if (isCoreDataValid && window.Signal.Util.Registration.everDone()) { if (isCoreDataValid && window.Signal.Util.Registration.everDone()) {
connect(); void connect();
window.reduxActions.app.openInbox(); window.reduxActions.app.openInbox();
} else { } else {
window.reduxActions.app.openInstaller(); window.reduxActions.app.openInstaller();
@ -1988,9 +1996,11 @@ export async function startApp(): Promise<void> {
const remoteBuildExpirationTimestamp = const remoteBuildExpirationTimestamp =
window.Signal.Util.parseRemoteClientExpiration(value as string); window.Signal.Util.parseRemoteClientExpiration(value as string);
if (remoteBuildExpirationTimestamp) { if (remoteBuildExpirationTimestamp) {
drop(
window.storage.put( window.storage.put(
'remoteBuildExpiration', 'remoteBuildExpiration',
remoteBuildExpirationTimestamp remoteBuildExpirationTimestamp
)
); );
window.reduxActions.expiration.hydrateExpirationStatus( window.reduxActions.expiration.hydrateExpirationStatus(
window.Signal.Util.hasExpired() window.Signal.Util.hasExpired()
@ -2051,7 +2061,7 @@ export async function startApp(): Promise<void> {
disconnectTimer = Timers.setTimeout(disconnect, 1000); disconnectTimer = Timers.setTimeout(disconnect, 1000);
if (challengeHandler) { if (challengeHandler) {
challengeHandler.onOffline(); void challengeHandler.onOffline();
} }
} }
@ -2072,7 +2082,7 @@ export async function startApp(): Promise<void> {
disconnectTimer = undefined; disconnectTimer = undefined;
} }
connect(); void connect();
} }
function isSocketOnline() { function isSocketOnline() {
@ -2089,7 +2099,7 @@ export async function startApp(): Promise<void> {
// Clear timer, since we're only called when the timer is expired // Clear timer, since we're only called when the timer is expired
disconnectTimer = undefined; disconnectTimer = undefined;
AttachmentDownloads.stop(); void AttachmentDownloads.stop();
if (server !== undefined) { if (server !== undefined) {
strictAssert( strictAssert(
messageReceiver !== undefined, messageReceiver !== undefined,
@ -2132,7 +2142,7 @@ export async function startApp(): Promise<void> {
'Starting up offline; will connect when we have network access' 'Starting up offline; will connect when we have network access'
); );
window.addEventListener('online', onOnline); window.addEventListener('online', onOnline);
onEmpty(); // this ensures that the loading screen is dismissed void onEmpty(); // this ensures that the loading screen is dismissed
// Switch to inbox view even if contact sync is still running // Switch to inbox view even if contact sync is still running
if ( if (
@ -2173,7 +2183,7 @@ export async function startApp(): Promise<void> {
expiration as string expiration as string
); );
if (remoteBuildExpirationTimestamp) { if (remoteBuildExpirationTimestamp) {
window.storage.put( await window.storage.put(
'remoteBuildExpiration', 'remoteBuildExpiration',
remoteBuildExpirationTimestamp remoteBuildExpirationTimestamp
); );
@ -2224,7 +2234,7 @@ export async function startApp(): Promise<void> {
window.Whisper.deliveryReceiptQueue.pause(); window.Whisper.deliveryReceiptQueue.pause();
notificationService.disable(); notificationService.disable();
window.Signal.Services.initializeGroupCredentialFetcher(); void window.Signal.Services.initializeGroupCredentialFetcher();
strictAssert(server !== undefined, 'WebAPI not initialized'); strictAssert(server !== undefined, 'WebAPI not initialized');
strictAssert( strictAssert(
@ -2237,14 +2247,14 @@ export async function startApp(): Promise<void> {
// If coming here after `offline` event - connect again. // If coming here after `offline` event - connect again.
await server.onOnline(); await server.onOnline();
AttachmentDownloads.start({ void AttachmentDownloads.start({
logger: log, logger: log,
}); });
if (connectCount === 1) { if (connectCount === 1) {
Stickers.downloadQueuedPacks(); Stickers.downloadQueuedPacks();
if (!newVersion) { if (!newVersion) {
runStorageService(); void runStorageService();
} }
} }
@ -2259,8 +2269,8 @@ export async function startApp(): Promise<void> {
log.info('Boot after upgrading. Requesting contact sync'); log.info('Boot after upgrading. Requesting contact sync');
window.getSyncRequest(); window.getSyncRequest();
StorageService.reprocessUnknownFields(); void StorageService.reprocessUnknownFields();
runStorageService(); void runStorageService();
try { try {
const manager = window.getAccountManager(); const manager = window.getAccountManager();
@ -2280,7 +2290,7 @@ export async function startApp(): Promise<void> {
if (!window.storage.get(udSupportKey)) { if (!window.storage.get(udSupportKey)) {
try { try {
await server.registerSupportForUnauthenticatedDelivery(); await server.registerSupportForUnauthenticatedDelivery();
window.storage.put(udSupportKey, true); await window.storage.put(udSupportKey, true);
} catch (error) { } catch (error) {
log.error( log.error(
'Error: Unable to register for unauthenticated delivery support.', 'Error: Unable to register for unauthenticated delivery support.',
@ -2331,7 +2341,7 @@ export async function startApp(): Promise<void> {
!hasThemeSetting && !hasThemeSetting &&
window.textsecure.storage.get('userAgent') === 'OWI' window.textsecure.storage.get('userAgent') === 'OWI'
) { ) {
window.storage.put( await window.storage.put(
'theme-setting', 'theme-setting',
await window.Events.getThemeSetting() await window.Events.getThemeSetting()
); );
@ -2446,7 +2456,7 @@ export async function startApp(): Promise<void> {
} }
// Intentionally not awaiting // Intentionally not awaiting
challengeHandler.onOnline(); void challengeHandler.onOnline();
reconnectBackOff.reset(); reconnectBackOff.reset();
} finally { } finally {
@ -2594,7 +2604,7 @@ export async function startApp(): Promise<void> {
storage, storage,
}); });
routineProfileRefresher.start(); void routineProfileRefresher.start();
} }
// Make sure we have the PNI identity // Make sure we have the PNI identity
@ -2632,10 +2642,10 @@ export async function startApp(): Promise<void> {
} }
log.info('manualConnect: calling connect()'); log.info('manualConnect: calling connect()');
connect(); void connect();
} }
function onConfiguration(ev: ConfigurationEvent): void { async function onConfiguration(ev: ConfigurationEvent): Promise<void> {
ev.confirm(); ev.confirm();
const { configuration } = ev; const { configuration } = ev;
@ -2646,24 +2656,24 @@ export async function startApp(): Promise<void> {
linkPreviews, linkPreviews,
} = configuration; } = configuration;
window.storage.put('read-receipt-setting', Boolean(readReceipts)); await window.storage.put('read-receipt-setting', Boolean(readReceipts));
if ( if (
unidentifiedDeliveryIndicators === true || unidentifiedDeliveryIndicators === true ||
unidentifiedDeliveryIndicators === false unidentifiedDeliveryIndicators === false
) { ) {
window.storage.put( await window.storage.put(
'unidentifiedDeliveryIndicators', 'unidentifiedDeliveryIndicators',
unidentifiedDeliveryIndicators unidentifiedDeliveryIndicators
); );
} }
if (typingIndicators === true || typingIndicators === false) { if (typingIndicators === true || typingIndicators === false) {
window.storage.put('typingIndicators', typingIndicators); await window.storage.put('typingIndicators', typingIndicators);
} }
if (linkPreviews === true || linkPreviews === false) { if (linkPreviews === true || linkPreviews === false) {
window.storage.put('linkPreviews', linkPreviews); await window.storage.put('linkPreviews', linkPreviews);
} }
} }
@ -2780,7 +2790,7 @@ export async function startApp(): Promise<void> {
fromSync: true, fromSync: true,
}); });
} else { } else {
Stickers.downloadStickerPack(id, key, { void Stickers.downloadStickerPack(id, key, {
finalStatus: 'installed', finalStatus: 'installed',
fromSync: true, fromSync: true,
}); });
@ -2909,8 +2919,10 @@ export async function startApp(): Promise<void> {
); );
} }
drop(
sender.queueJob('sendProfileKeyUpdate', () => sender.queueJob('sendProfileKeyUpdate', () =>
sender.sendProfileKeyUpdate() sender.sendProfileKeyUpdate()
)
); );
}); });
}, },
@ -2984,9 +2996,11 @@ export async function startApp(): Promise<void> {
} }
if (!message.get('unidentifiedDeliveryReceived')) { if (!message.get('unidentifiedDeliveryReceived')) {
drop(
profileKeyResponseQueue.add(() => { profileKeyResponseQueue.add(() => {
respondWithProfileKeyBatcher.add(sender); respondWithProfileKeyBatcher.add(sender);
}); })
);
} }
} }
@ -3032,7 +3046,7 @@ export async function startApp(): Promise<void> {
const reactionModel = Reactions.getSingleton().add(attributes); const reactionModel = Reactions.getSingleton().add(attributes);
// Note: We do not wait for completion here // Note: We do not wait for completion here
Reactions.getSingleton().onReaction(reactionModel, message); void Reactions.getSingleton().onReaction(reactionModel, message);
confirm(); confirm();
return; return;
} }
@ -3061,7 +3075,7 @@ export async function startApp(): Promise<void> {
const deleteModel = Deletes.getSingleton().add(attributes); const deleteModel = Deletes.getSingleton().add(attributes);
// Note: We do not wait for completion here // Note: We do not wait for completion here
Deletes.getSingleton().onDelete(deleteModel); void Deletes.getSingleton().onDelete(deleteModel);
confirm(); confirm();
return; return;
@ -3073,7 +3087,7 @@ export async function startApp(): Promise<void> {
} }
// Don't wait for handleDataMessage, as it has its own per-conversation queueing // Don't wait for handleDataMessage, as it has its own per-conversation queueing
message.handleDataMessage(data.message, event.confirm); void message.handleDataMessage(data.message, event.confirm);
} }
async function onProfileKeyUpdate({ async function onProfileKeyUpdate({
@ -3403,7 +3417,7 @@ export async function startApp(): Promise<void> {
}; };
const reactionModel = Reactions.getSingleton().add(attributes); const reactionModel = Reactions.getSingleton().add(attributes);
// Note: We do not wait for completion here // Note: We do not wait for completion here
Reactions.getSingleton().onReaction(reactionModel, message); void Reactions.getSingleton().onReaction(reactionModel, message);
event.confirm(); event.confirm();
return; return;
@ -3426,7 +3440,7 @@ export async function startApp(): Promise<void> {
}; };
const deleteModel = Deletes.getSingleton().add(attributes); const deleteModel = Deletes.getSingleton().add(attributes);
// Note: We do not wait for completion here // Note: We do not wait for completion here
Deletes.getSingleton().onDelete(deleteModel); void Deletes.getSingleton().onDelete(deleteModel);
confirm(); confirm();
return; return;
} }
@ -3437,7 +3451,7 @@ export async function startApp(): Promise<void> {
} }
// Don't wait for handleDataMessage, as it has its own per-conversation queueing // Don't wait for handleDataMessage, as it has its own per-conversation queueing
message.handleDataMessage(data.message, event.confirm, { void message.handleDataMessage(data.message, event.confirm, {
data, data,
}); });
} }
@ -3517,9 +3531,9 @@ export async function startApp(): Promise<void> {
await window.waitForAllBatchers(); await window.waitForAllBatchers();
} }
onEmpty(); void onEmpty();
window.Signal.Util.Registration.remove(); void window.Signal.Util.Registration.remove();
const NUMBER_ID_KEY = 'number_id'; const NUMBER_ID_KEY = 'number_id';
const UUID_ID_KEY = 'uuid_id'; const UUID_ID_KEY = 'uuid_id';
@ -3580,7 +3594,7 @@ export async function startApp(): Promise<void> {
Errors.toLogFormat(eraseError) Errors.toLogFormat(eraseError)
); );
} finally { } finally {
window.Signal.Util.Registration.markEverDone(); await window.Signal.Util.Registration.markEverDone();
} }
} }
@ -3592,7 +3606,7 @@ export async function startApp(): Promise<void> {
error instanceof HTTPError && error instanceof HTTPError &&
(error.code === 401 || error.code === 403) (error.code === 401 || error.code === 403)
) { ) {
unlinkAndDisconnect(RemoveAllConfiguration.Full); void unlinkAndDisconnect(RemoveAllConfiguration.Full);
return; return;
} }
@ -3614,7 +3628,7 @@ export async function startApp(): Promise<void> {
}; };
const sync = ViewOnceOpenSyncs.getSingleton().add(attributes); const sync = ViewOnceOpenSyncs.getSingleton().add(attributes);
ViewOnceOpenSyncs.getSingleton().onSync(sync); void ViewOnceOpenSyncs.getSingleton().onSync(sync);
} }
async function onFetchLatestSync(ev: FetchLatestEvent): Promise<void> { async function onFetchLatestSync(ev: FetchLatestEvent): Promise<void> {
@ -3656,7 +3670,7 @@ export async function startApp(): Promise<void> {
if (storageServiceKey == null) { if (storageServiceKey == null) {
log.info('onKeysSync: deleting window.storageKey'); log.info('onKeysSync: deleting window.storageKey');
window.storage.remove('storageKey'); await window.storage.remove('storageKey');
} }
if (storageServiceKey) { if (storageServiceKey) {
@ -3713,7 +3727,7 @@ export async function startApp(): Promise<void> {
}; };
const sync = MessageRequests.getSingleton().add(attributes); const sync = MessageRequests.getSingleton().add(attributes);
MessageRequests.getSingleton().onResponse(sync); void MessageRequests.getSingleton().onResponse(sync);
} }
function onReadReceipt(event: Readonly<ReadEvent>): void { function onReadReceipt(event: Readonly<ReadEvent>): void {
@ -3787,7 +3801,7 @@ export async function startApp(): Promise<void> {
const receipt = MessageReceipts.getSingleton().add(attributes); const receipt = MessageReceipts.getSingleton().add(attributes);
// Note: We do not wait for completion here // Note: We do not wait for completion here
MessageReceipts.getSingleton().onReceipt(receipt); void MessageReceipts.getSingleton().onReceipt(receipt);
} }
function onReadSync(ev: ReadSyncEvent): Promise<void> { function onReadSync(ev: ReadSyncEvent): Promise<void> {
@ -3925,7 +3939,7 @@ export async function startApp(): Promise<void> {
const receipt = MessageReceipts.getSingleton().add(attributes); const receipt = MessageReceipts.getSingleton().add(attributes);
// Note: We don't wait for completion here // Note: We don't wait for completion here
MessageReceipts.getSingleton().onReceipt(receipt); void MessageReceipts.getSingleton().onReceipt(receipt);
} }
} }

View file

@ -58,7 +58,7 @@ class BadgeImageFileDownloader {
previousState === previousState ===
BadgeDownloaderState.CheckingWithAnotherCheckEnqueued BadgeDownloaderState.CheckingWithAnotherCheckEnqueued
) { ) {
this.checkForFilesToDownload(); void this.checkForFilesToDownload();
} }
return; return;
} }

View file

@ -210,7 +210,7 @@ export class ChallengeHandler {
} }
if (challenge.token) { if (challenge.token) {
this.solve({ reason, token: challenge.token }); void this.solve({ reason, token: challenge.token });
} }
} }
@ -247,7 +247,7 @@ export class ChallengeHandler {
setTimeout(() => { setTimeout(() => {
this.startTimers.delete(conversationId); this.startTimers.delete(conversationId);
this.startQueue(conversationId); void this.startQueue(conversationId);
}, waitTime) }, waitTime)
); );
log.info( log.info(
@ -269,7 +269,7 @@ export class ChallengeHandler {
return; return;
} }
this.solve({ token: challenge.token, reason }); void this.solve({ token: challenge.token, reason });
} }
public onResponse(response: IPCResponse): void { public onResponse(response: IPCResponse): void {

View file

@ -109,7 +109,7 @@ export function AvatarEditor({
} }
} }
cacheAvatars(); void cacheAvatars();
return () => { return () => {
shouldCancel = true; shouldCancel = true;

View file

@ -45,7 +45,7 @@ export function AvatarIconEditor({
setAvatarBuffer(buffer); setAvatarBuffer(buffer);
} }
} }
loadAvatar(); void loadAvatar();
return () => { return () => {
shouldCancel = true; shouldCancel = true;

View file

@ -62,7 +62,7 @@ export function AvatarPreview({
let shouldCancel = false; let shouldCancel = false;
(async () => { void (async () => {
try { try {
const buffer = await imagePathToBytes(avatarPath); const buffer = await imagePathToBytes(avatarPath);
if (shouldCancel) { if (shouldCancel) {

View file

@ -30,7 +30,7 @@ export function AvatarUploadButton({
let shouldCancel = false; let shouldCancel = false;
(async () => { void (async () => {
let newAvatar: Uint8Array; let newAvatar: Uint8Array;
try { try {
newAvatar = await processImageFile(processingFile); newAvatar = await processImageFile(processingFile);

View file

@ -50,7 +50,7 @@ export function BetterAvatar({
return noop; return noop;
} }
makeAvatar(); void makeAvatar();
return () => { return () => {
shouldCancel = true; shouldCancel = true;

View file

@ -90,7 +90,7 @@ function Bars({ audioLevel }: { audioLevel: number }): ReactElement {
useEffect(() => { useEffect(() => {
animatedProps.audioLevel.stop(); animatedProps.audioLevel.stop();
animatedProps.audioLevel.start(audioLevel); void animatedProps.audioLevel.start(audioLevel);
}, [audioLevel, animatedProps]); }, [audioLevel, animatedProps]);
return ( return (

View file

@ -86,7 +86,7 @@ export function DebugLogWindow({
setToastType(undefined); setToastType(undefined);
} }
doFetchLogs(); void doFetchLogs();
return () => { return () => {
shouldCancel = true; shouldCancel = true;

View file

@ -27,7 +27,7 @@ export type Contents = {
// `audioContext` global, however, as the browser limits the number that can be // `audioContext` global, however, as the browser limits the number that can be
// created.) // created.)
const audioContext = new AudioContext(); const audioContext = new AudioContext();
audioContext.suspend(); void audioContext.suspend();
const waveformCache: WaveformCache = new LRU({ const waveformCache: WaveformCache = new LRU({
max: MAX_WAVEFORM_COUNT, max: MAX_WAVEFORM_COUNT,

View file

@ -203,7 +203,7 @@ export function Lightbox({
} }
if (videoElement.paused) { if (videoElement.paused) {
videoElement.play(); void videoElement.play();
} else { } else {
videoElement.pause(); videoElement.pause();
} }

View file

@ -504,7 +504,7 @@ export function ProfileEditor({
username !== undefined, username !== undefined,
'Should not be visible without username' 'Should not be visible without username'
); );
window.navigator.clipboard.writeText(username); void window.navigator.clipboard.writeText(username);
showToast(ToastType.CopiedUsername); showToast(ToastType.CopiedUsername);
}, },
}, },
@ -517,7 +517,7 @@ export function ProfileEditor({
username !== undefined, username !== undefined,
'Should not be visible without username' 'Should not be visible without username'
); );
window.navigator.clipboard.writeText( void window.navigator.clipboard.writeText(
generateUsernameLink(username) generateUsernameLink(username)
); );
showToast(ToastType.CopiedUsernameLink); showToast(ToastType.CopiedUsernameLink);

View file

@ -38,7 +38,7 @@ export function QrCode(props: PropsType): ReactElement {
return; return;
} }
navigator.clipboard.writeText(data); void navigator.clipboard.writeText(data);
const el = elRef.current; const el = elRef.current;
if (!el) { if (!el) {

View file

@ -954,7 +954,7 @@ export function SendStoryModal({
actions={[ actions={[
{ {
action: () => { action: () => {
toggleGroupsForStorySend([confirmRemoveGroupId]); void toggleGroupsForStorySend([confirmRemoveGroupId]);
setConfirmRemoveGroupId(undefined); setConfirmRemoveGroupId(undefined);
}, },
style: 'negative', style: 'negative',

View file

@ -138,7 +138,7 @@ export function StandaloneRegistration({
}); });
try { try {
requestVerification(type, number, token); void requestVerification(type, number, token);
setError(undefined); setError(undefined);
} catch (err) { } catch (err) {
setError(err.message); setError(err.message);
@ -152,7 +152,7 @@ export function StandaloneRegistration({
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
onRequestCode('sms'); void onRequestCode('sms');
}, },
[onRequestCode] [onRequestCode]
); );
@ -162,7 +162,7 @@ export function StandaloneRegistration({
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
onRequestCode('voice'); void onRequestCode('voice');
}, },
[onRequestCode] [onRequestCode]
); );

View file

@ -311,7 +311,7 @@ export function StoriesSettingsModal({
page={page} page={page}
onClose={onClose} onClose={onClose}
onCreateList={(name, uuids) => { onCreateList={(name, uuids) => {
onDistributionListCreated(name, uuids); void onDistributionListCreated(name, uuids);
resetChooseViewersScreen(); resetChooseViewersScreen();
}} }}
onBackButtonClick={() => onBackButtonClick={() =>

View file

@ -149,7 +149,7 @@ export function StoryCreator({
} }
} }
loadAttachment(); void loadAttachment();
return () => { return () => {
unmounted = true; unmounted = true;

View file

@ -204,7 +204,7 @@ export function StoryDetailsModal({
icon: 'StoryDetailsModal__copy-icon', icon: 'StoryDetailsModal__copy-icon',
label: i18n('StoryDetailsModal__copy-timestamp'), label: i18n('StoryDetailsModal__copy-timestamp'),
onClick: () => { onClick: () => {
window.navigator.clipboard.writeText(String(timestamp)); void window.navigator.clipboard.writeText(String(timestamp));
}, },
}, },
]; ];

View file

@ -72,7 +72,7 @@ export function StoryImage({
if (isPaused) { if (isPaused) {
videoRef.current.pause(); videoRef.current.pause();
} else { } else {
videoRef.current.play(); void videoRef.current.play();
} }
}, [isPaused]); }, [isPaused]);

View file

@ -247,7 +247,7 @@ export function StoryViewer({
// are sequentially posted. // are sequentially posted.
useEffect(() => { useEffect(() => {
let shouldCancel = false; let shouldCancel = false;
(async function hydrateStoryDuration() { void (async function hydrateStoryDuration() {
if (!attachment) { if (!attachment) {
return; return;
} }

View file

@ -618,7 +618,7 @@ function ReplyOrReactionMessage({
icon: 'module-message__context--icon module-message__context__copy-timestamp', icon: 'module-message__context--icon module-message__context__copy-timestamp',
label: i18n('icu:StoryViewsNRepliesModal__copy-reply-timestamp'), label: i18n('icu:StoryViewsNRepliesModal__copy-reply-timestamp'),
onClick: () => { onClick: () => {
window.navigator.clipboard.writeText(String(reply.timestamp)); void window.navigator.clipboard.writeText(String(reply.timestamp));
}, },
}); });
} }

View file

@ -321,7 +321,7 @@ export function MessageAudio(props: Props): JSX.Element {
let canceled = false; let canceled = false;
(async () => { void (async () => {
try { try {
if (!attachment.url) { if (!attachment.url) {
throw new Error( throw new Error(

View file

@ -367,7 +367,9 @@ export class MessageDetail extends React.Component<Props> {
icon: 'StoryDetailsModal__copy-icon', icon: 'StoryDetailsModal__copy-icon',
label: i18n('StoryDetailsModal__copy-timestamp'), label: i18n('StoryDetailsModal__copy-timestamp'),
onClick: () => { onClick: () => {
window.navigator.clipboard.writeText(String(sentAt)); void window.navigator.clipboard.writeText(
String(sentAt)
);
}, },
}, },
]} ]}

View file

@ -163,7 +163,7 @@ function MessageAudioContainer({
setIsActive(true); setIsActive(true);
} }
if (!playing) { if (!playing) {
audio.play(); void audio.play();
setPlaying(true); setPlaying(true);
setPlayed(true); setPlayed(true);
} }
@ -183,7 +183,7 @@ function MessageAudioContainer({
const setIsPlayingAction = (value: boolean) => { const setIsPlayingAction = (value: boolean) => {
if (value) { if (value) {
audio.play(); void audio.play();
} else { } else {
audio.pause(); audio.pause();
} }

View file

@ -249,7 +249,7 @@ export function AddGroupMembersModal({
return renderConfirmAdditionsModal({ return renderConfirmAdditionsModal({
groupTitle, groupTitle,
makeRequest: () => { makeRequest: () => {
makeRequest(selectedConversationIds); void makeRequest(selectedConversationIds);
}, },
onClose: onCloseConfirmationDialog, onClose: onCloseConfirmationDialog,
requestState, requestState,

View file

@ -138,7 +138,7 @@ export function GroupLinkManagement({
ref={!isAdmin ? focusRef : undefined} ref={!isAdmin ? focusRef : undefined}
onClick={() => { onClick={() => {
if (conversation.groupLink) { if (conversation.groupLink) {
copyGroupLink(conversation.groupLink); void copyGroupLink(conversation.groupLink);
} }
}} }}
/> />

View file

@ -23,6 +23,7 @@ import is from '@sindresorhus/is';
import { getOwn } from '../../util/getOwn'; import { getOwn } from '../../util/getOwn';
import * as log from '../../logging/log'; import * as log from '../../logging/log';
import { MINUTE } from '../../util/durations'; import { MINUTE } from '../../util/durations';
import { drop } from '../../util/drop';
export const skinTones = ['1F3FB', '1F3FC', '1F3FD', '1F3FE', '1F3FF']; export const skinTones = ['1F3FB', '1F3FC', '1F3FD', '1F3FE', '1F3FF'];
@ -124,11 +125,11 @@ export const preloadImages = async (): Promise<void> => {
const start = Date.now(); const start = Date.now();
data.forEach(emoji => { data.forEach(emoji => {
imageQueue.add(() => preload(makeImagePath(emoji.image))); drop(imageQueue.add(() => preload(makeImagePath(emoji.image))));
if (emoji.skin_variations) { if (emoji.skin_variations) {
Object.values(emoji.skin_variations).forEach(variation => { Object.values(emoji.skin_variations).forEach(variation => {
imageQueue.add(() => preload(makeImagePath(variation.image))); drop(imageQueue.add(() => preload(makeImagePath(variation.image))));
}); });
} }
}); });

View file

@ -10,7 +10,7 @@ import { Tabs } from '../Tabs';
export type OwnProps = { export type OwnProps = {
readonly blessedPacks: ReadonlyArray<StickerPackType>; readonly blessedPacks: ReadonlyArray<StickerPackType>;
readonly closeStickerPackPreview: (packId: string) => unknown; readonly closeStickerPackPreview: () => unknown;
readonly downloadStickerPack: (packId: string, packKey: string) => unknown; readonly downloadStickerPack: (packId: string, packKey: string) => unknown;
readonly i18n: LocalizerType; readonly i18n: LocalizerType;
readonly installStickerPack: (packId: string, packKey: string) => unknown; readonly installStickerPack: (packId: string, packKey: string) => unknown;

View file

@ -14,7 +14,7 @@ import { Button, ButtonVariant } from '../Button';
export type OwnProps = { export type OwnProps = {
readonly onClose?: () => unknown; readonly onClose?: () => unknown;
readonly closeStickerPackPreview: (packId: string) => unknown; readonly closeStickerPackPreview: () => unknown;
readonly downloadStickerPack: ( readonly downloadStickerPack: (
packId: string, packId: string,
packKey: string, packKey: string,
@ -107,9 +107,18 @@ export const StickerPreviewModal = React.memo(function StickerPreviewModalInner(
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
React.useEffect(() => {
if (pack) {
return;
}
// Pack fully uninstalled, don't keep the modal open
closeStickerPackPreview();
}, [pack, closeStickerPackPreview]);
const handleClose = React.useCallback(() => { const handleClose = React.useCallback(() => {
if (pack?.id) { if (pack) {
closeStickerPackPreview(pack.id); closeStickerPackPreview();
} }
onClose?.(); onClose?.();
}, [closeStickerPackPreview, onClose, pack]); }, [closeStickerPackPreview, onClose, pack]);

View file

@ -1602,7 +1602,7 @@ export async function modifyGroupV2({
`modifyGroupV2/${logId}: Conflict while updating. Timed out; not retrying.` `modifyGroupV2/${logId}: Conflict while updating. Timed out; not retrying.`
); );
// We don't wait here because we're breaking out of the loop immediately. // We don't wait here because we're breaking out of the loop immediately.
conversation.fetchLatestGroupV2Data({ force: true }); void conversation.fetchLatestGroupV2Data({ force: true });
throw error; throw error;
} else { } else {
const errorString = Errors.toLogFormat(error); const errorString = Errors.toLogFormat(error);
@ -2403,7 +2403,7 @@ export async function initiateMigrationToGroupV2(
}); });
if (window.storage.blocked.isGroupBlocked(previousGroupV1Id)) { if (window.storage.blocked.isGroupBlocked(previousGroupV1Id)) {
window.storage.blocked.addBlockedGroup(groupId); await window.storage.blocked.addBlockedGroup(groupId);
} }
// Save these most recent updates to conversation // Save these most recent updates to conversation
@ -2721,7 +2721,7 @@ export async function respondToGroupV2Migration({
); );
if (window.storage.blocked.isGroupBlocked(previousGroupV1Id)) { if (window.storage.blocked.isGroupBlocked(previousGroupV1Id)) {
window.storage.blocked.addBlockedGroup(groupId); await window.storage.blocked.addBlockedGroup(groupId);
} }
if (wereWePreviouslyAMember) { if (wereWePreviouslyAMember) {
@ -2862,7 +2862,7 @@ export async function respondToGroupV2Migration({
}); });
if (window.storage.blocked.isGroupBlocked(previousGroupV1Id)) { if (window.storage.blocked.isGroupBlocked(previousGroupV1Id)) {
window.storage.blocked.addBlockedGroup(groupId); await window.storage.blocked.addBlockedGroup(groupId);
} }
// Save these most recent updates to conversation // Save these most recent updates to conversation
@ -3080,7 +3080,7 @@ async function updateGroup(
contact.get('profileKey') !== member.profileKey contact.get('profileKey') !== member.profileKey
) { ) {
contactsWithoutProfileKey.push(contact); contactsWithoutProfileKey.push(contact);
contact.setProfileKey(member.profileKey); void contact.setProfileKey(member.profileKey);
} }
}); });
@ -3155,7 +3155,7 @@ async function updateGroup(
}; };
// Cannot await here, would infinitely block queue // Cannot await here, would infinitely block queue
waitThenLeave(); void waitThenLeave();
} }
} }
} }
@ -3359,7 +3359,7 @@ async function appendChangeMessages(
// We updated the message, but didn't add new ones - refresh left pane // We updated the message, but didn't add new ones - refresh left pane
if (!newMessages && mergedMessages.length > 0) { if (!newMessages && mergedMessages.length > 0) {
await conversation.updateLastMessage(); await conversation.updateLastMessage();
conversation.updateUnread(); void conversation.updateUnread();
} }
} }

View file

@ -422,7 +422,7 @@ export async function joinViaLink(hash: string): Promise<void> {
} }
}; };
fetchAvatar(); void fetchAvatar();
await promise; await promise;
} }

View file

@ -46,7 +46,7 @@ export const useTheme = (): ThemeType => {
} }
SignalContext.nativeThemeListener.subscribe(applyTheme); SignalContext.nativeThemeListener.subscribe(applyTheme);
loop(); void loop();
return () => { return () => {
abortController.abort(); abortController.abort();

View file

@ -130,7 +130,7 @@ export abstract class JobQueue<T> {
const stream = this.store.stream(this.queueType); const stream = this.store.stream(this.queueType);
for await (const storedJob of stream) { for await (const storedJob of stream) {
this.enqueueStoredJob(storedJob); void this.enqueueStoredJob(storedJob);
} }
} }

View file

@ -412,7 +412,7 @@ export class ConversationJobQueue extends JobQueue<ConversationQueueJobData> {
} }
untrustedUuids.push(uuid); untrustedUuids.push(uuid);
} else if (toProcess instanceof SendMessageChallengeError) { } else if (toProcess instanceof SendMessageChallengeError) {
window.Signal.challengeHandler?.register( void window.Signal.challengeHandler?.register(
{ {
conversationId, conversationId,
createdAt: Date.now(), createdAt: Date.now(),

View file

@ -71,7 +71,11 @@ export async function sendDeleteForEveryone(
if (!shouldContinue) { if (!shouldContinue) {
log.info(`${logId}: Ran out of time. Giving up on sending`); log.info(`${logId}: Ran out of time. Giving up on sending`);
updateMessageWithFailure(message, [new Error('Ran out of time!')], log); void updateMessageWithFailure(
message,
[new Error('Ran out of time!')],
log
);
return; return;
} }
@ -148,7 +152,7 @@ export async function sendDeleteForEveryone(
log.info( log.info(
`conversation ${conversation.idForLogging()} is not accepted; refusing to send` `conversation ${conversation.idForLogging()} is not accepted; refusing to send`
); );
updateMessageWithFailure( void updateMessageWithFailure(
message, message,
[new Error('Message request was not accepted')], [new Error('Message request was not accepted')],
log log
@ -159,7 +163,7 @@ export async function sendDeleteForEveryone(
log.info( log.info(
`conversation ${conversation.idForLogging()} is unregistered; refusing to send` `conversation ${conversation.idForLogging()} is unregistered; refusing to send`
); );
updateMessageWithFailure( void updateMessageWithFailure(
message, message,
[new Error('Contact no longer has a Signal account')], [new Error('Contact no longer has a Signal account')],
log log
@ -170,7 +174,7 @@ export async function sendDeleteForEveryone(
log.info( log.info(
`conversation ${conversation.idForLogging()} is blocked; refusing to send` `conversation ${conversation.idForLogging()} is blocked; refusing to send`
); );
updateMessageWithFailure( void updateMessageWithFailure(
message, message,
[new Error('Contact is blocked')], [new Error('Contact is blocked')],
log log

View file

@ -53,7 +53,11 @@ export async function sendDeleteStoryForEveryone(
if (!shouldContinue) { if (!shouldContinue) {
log.info(`${logId}: Ran out of time. Giving up on sending`); log.info(`${logId}: Ran out of time. Giving up on sending`);
updateMessageWithFailure(message, [new Error('Ran out of time!')], log); void updateMessageWithFailure(
message,
[new Error('Ran out of time!')],
log
);
return; return;
} }
@ -107,7 +111,7 @@ export async function sendDeleteStoryForEveryone(
`${logId}: conversation ${conversation.idForLogging()} ` + `${logId}: conversation ${conversation.idForLogging()} ` +
'is not accepted; refusing to send' 'is not accepted; refusing to send'
); );
updateMessageWithFailure( void updateMessageWithFailure(
message, message,
[new Error('Message request was not accepted')], [new Error('Message request was not accepted')],
log log
@ -119,7 +123,7 @@ export async function sendDeleteStoryForEveryone(
`${logId}: conversation ${conversation.idForLogging()} ` + `${logId}: conversation ${conversation.idForLogging()} ` +
'is unregistered; refusing to send' 'is unregistered; refusing to send'
); );
updateMessageWithFailure( void updateMessageWithFailure(
message, message,
[new Error('Contact no longer has a Signal account')], [new Error('Contact no longer has a Signal account')],
log log
@ -131,7 +135,7 @@ export async function sendDeleteStoryForEveryone(
`${logId}: conversation ${conversation.idForLogging()} ` + `${logId}: conversation ${conversation.idForLogging()} ` +
'is blocked; refusing to send' 'is blocked; refusing to send'
); );
updateMessageWithFailure( void updateMessageWithFailure(
message, message,
[new Error('Contact is blocked')], [new Error('Contact is blocked')],
log log

View file

@ -196,7 +196,7 @@ export async function sendNormalMessage(
log.info( log.info(
'No recipients; not sending to ourselves or to group, and no successful sends. Failing job.' 'No recipients; not sending to ourselves or to group, and no successful sends. Failing job.'
); );
markMessageFailed(message, [new Error('No valid recipients')]); void markMessageFailed(message, [new Error('No valid recipients')]);
return; return;
} }
@ -281,7 +281,7 @@ export async function sendNormalMessage(
log.info( log.info(
`conversation ${conversation.idForLogging()} is not accepted; refusing to send` `conversation ${conversation.idForLogging()} is not accepted; refusing to send`
); );
markMessageFailed(message, [ void markMessageFailed(message, [
new Error('Message request was not accepted'), new Error('Message request was not accepted'),
]); ]);
return; return;
@ -290,7 +290,7 @@ export async function sendNormalMessage(
log.info( log.info(
`conversation ${conversation.idForLogging()} is unregistered; refusing to send` `conversation ${conversation.idForLogging()} is unregistered; refusing to send`
); );
markMessageFailed(message, [ void markMessageFailed(message, [
new Error('Contact no longer has a Signal account'), new Error('Contact no longer has a Signal account'),
]); ]);
return; return;
@ -299,7 +299,7 @@ export async function sendNormalMessage(
log.info( log.info(
`conversation ${conversation.idForLogging()} is blocked; refusing to send` `conversation ${conversation.idForLogging()} is blocked; refusing to send`
); );
markMessageFailed(message, [new Error('Contact is blocked')]); void markMessageFailed(message, [new Error('Contact is blocked')]);
return; return;
} }
@ -561,7 +561,7 @@ async function markMessageFailed(
errors: Array<Error> errors: Array<Error>
): Promise<void> { ): Promise<void> {
message.markFailed(); message.markFailed();
message.saveErrors(errors, { skipSave: true }); void message.saveErrors(errors, { skipSave: true });
await window.Signal.Data.saveMessage(message.attributes, { await window.Signal.Data.saveMessage(message.attributes, {
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(), ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
}); });

View file

@ -322,7 +322,7 @@ export async function sendReaction(
reactionMessage.hydrateStoryContext(message), reactionMessage.hydrateStoryContext(message),
]); ]);
conversation.addSingleMessage( void conversation.addSingleMessage(
window.MessageController.register(reactionMessage.id, reactionMessage) window.MessageController.register(reactionMessage.id, reactionMessage)
); );
} }

View file

@ -399,7 +399,7 @@ export async function sendStory(
// conversationJobQueue. // conversationJobQueue.
errors.forEach(error => { errors.forEach(error => {
if (error instanceof SendMessageChallengeError) { if (error instanceof SendMessageChallengeError) {
window.Signal.challengeHandler?.register( void window.Signal.challengeHandler?.register(
{ {
conversationId: conversation.id, conversationId: conversation.id,
createdAt: Date.now(), createdAt: Date.now(),
@ -641,7 +641,7 @@ async function markMessageFailed(
errors: Array<Error> errors: Array<Error>
): Promise<void> { ): Promise<void> {
message.markFailed(); message.markFailed();
message.saveErrors(errors, { skipSave: true }); void message.saveErrors(errors, { skipSave: true });
await window.Signal.Data.saveMessage(message.attributes, { await window.Signal.Data.saveMessage(message.attributes, {
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(), ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
}); });

View file

@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
import type { WebAPIType } from '../textsecure/WebAPI'; import type { WebAPIType } from '../textsecure/WebAPI';
import { drop } from '../util/drop';
import { conversationJobQueue } from './conversationJobQueue'; import { conversationJobQueue } from './conversationJobQueue';
import { deliveryReceiptsJobQueue } from './deliveryReceiptsJobQueue'; import { deliveryReceiptsJobQueue } from './deliveryReceiptsJobQueue';
@ -25,22 +26,22 @@ export function initializeAllJobQueues({
reportSpamJobQueue.initialize({ server }); reportSpamJobQueue.initialize({ server });
// General conversation send queue // General conversation send queue
conversationJobQueue.streamJobs(); drop(conversationJobQueue.streamJobs());
// Single proto send queue, used for a variety of one-off simple messages // Single proto send queue, used for a variety of one-off simple messages
singleProtoJobQueue.streamJobs(); drop(singleProtoJobQueue.streamJobs());
// Syncs to others // Syncs to others
deliveryReceiptsJobQueue.streamJobs(); drop(deliveryReceiptsJobQueue.streamJobs());
readReceiptsJobQueue.streamJobs(); drop(readReceiptsJobQueue.streamJobs());
viewedReceiptsJobQueue.streamJobs(); drop(viewedReceiptsJobQueue.streamJobs());
// Syncs to ourselves // Syncs to ourselves
readSyncJobQueue.streamJobs(); drop(readSyncJobQueue.streamJobs());
viewSyncJobQueue.streamJobs(); drop(viewSyncJobQueue.streamJobs());
viewOnceOpenJobQueue.streamJobs(); drop(viewOnceOpenJobQueue.streamJobs());
// Other queues // Other queues
removeStorageKeyJobQueue.streamJobs(); drop(removeStorageKeyJobQueue.streamJobs());
reportSpamJobQueue.streamJobs(); drop(reportSpamJobQueue.streamJobs());
} }

View file

@ -96,7 +96,7 @@ export async function initialize(
globalLogger = undefined; globalLogger = undefined;
if (shouldRestart) { if (shouldRestart) {
initialize(getMainWindow); void initialize(getMainWindow);
} }
}; };

View file

@ -55,7 +55,7 @@ export class ChallengeMainHandler {
private initialize(): void { private initialize(): void {
ipc.on('challenge:request', (event, request) => { ipc.on('challenge:request', (event, request) => {
this.onRequest(event, request); void this.onRequest(event, request);
}); });
} }
} }

View file

@ -62,7 +62,7 @@ export async function start(options: StartOptionsType): Promise<void> {
enabled = true; enabled = true;
await resetAttachmentDownloadPending(); await resetAttachmentDownloadPending();
_tick(); void _tick();
} }
export async function stop(): Promise<void> { export async function stop(): Promise<void> {
@ -133,7 +133,7 @@ export async function addJob(
await saveAttachmentDownloadJob(toSave); await saveAttachmentDownloadJob(toSave);
_maybeStartJob(); void _maybeStartJob();
return { return {
...attachment, ...attachment,
@ -146,7 +146,7 @@ async function _tick(): Promise<void> {
clearTimeoutIfNecessary(timeout); clearTimeoutIfNecessary(timeout);
timeout = null; timeout = null;
_maybeStartJob(); void _maybeStartJob();
timeout = setTimeout(_tick, TICK_INTERVAL); timeout = setTimeout(_tick, TICK_INTERVAL);
} }
@ -229,13 +229,13 @@ async function _maybeStartJob(): Promise<void> {
Errors.toLogFormat(error) Errors.toLogFormat(error)
); );
} finally { } finally {
_maybeStartJob(); void _maybeStartJob();
} }
} }
}; };
// Note: intentionally not awaiting // Note: intentionally not awaiting
postProcess(); void postProcess();
} }
} }
} }
@ -360,7 +360,7 @@ async function _runJob(job?: AttachmentDownloadJobType): Promise<void> {
await saveAttachmentDownloadJob(failedJob); await saveAttachmentDownloadJob(failedJob);
} finally { } finally {
delete _activeAttachmentDownloadJobs[id]; delete _activeAttachmentDownloadJobs[id];
_maybeStartJob(); void _maybeStartJob();
} }
} }
} }
@ -420,7 +420,7 @@ async function _finishJob(
await removeAttachmentDownloadJob(id); await removeAttachmentDownloadJob(id);
delete _activeAttachmentDownloadJobs[id]; delete _activeAttachmentDownloadJobs[id];
_maybeStartJob(); void _maybeStartJob();
} }
function getActiveJobCount(): number { function getActiveJobCount(): number {
@ -472,7 +472,7 @@ async function _addAttachmentToMessage(
}); });
} finally { } finally {
if (attachment.path) { if (attachment.path) {
window.Signal.Migrations.deleteAttachmentData(attachment.path); void window.Signal.Migrations.deleteAttachmentData(attachment.path);
} }
} }
return; return;

View file

@ -9,6 +9,7 @@ import { getContactId } from '../messages/helpers';
import * as log from '../logging/log'; import * as log from '../logging/log';
import * as Errors from '../types/errors'; import * as Errors from '../types/errors';
import { deleteForEveryone } from '../util/deleteForEveryone'; import { deleteForEveryone } from '../util/deleteForEveryone';
import { drop } from '../util/drop';
export type DeleteAttributesType = { export type DeleteAttributesType = {
targetSentTimestamp: number; targetSentTimestamp: number;
@ -67,6 +68,7 @@ export class Deletes extends Collection<DeleteModel> {
} }
// Do not await, since this can deadlock the queue // Do not await, since this can deadlock the queue
drop(
targetConversation.queueJob('Deletes.onDelete', async () => { targetConversation.queueJob('Deletes.onDelete', async () => {
log.info('Handling DOE for', del.get('targetSentTimestamp')); log.info('Handling DOE for', del.get('targetSentTimestamp'));
@ -96,7 +98,8 @@ export class Deletes extends Collection<DeleteModel> {
await deleteForEveryone(message, del); await deleteForEveryone(message, del);
this.remove(del); this.remove(del);
}); })
);
} catch (error) { } catch (error) {
log.error('Deletes.onDelete error:', Errors.toLogFormat(error)); log.error('Deletes.onDelete error:', Errors.toLogFormat(error));
} }

View file

@ -118,7 +118,7 @@ export class MessageRequests extends Collection<MessageRequestModel> {
return; return;
} }
conversation.applyMessageRequestResponse(sync.get('type'), { void conversation.applyMessageRequestResponse(sync.get('type'), {
fromSync: true, fromSync: true,
}); });

View file

@ -208,7 +208,7 @@ export class Reactions extends Collection<ReactionModel> {
generatedMessage.id, generatedMessage.id,
generatedMessage generatedMessage
); );
targetConversation.addSingleMessage(messageToAdd); void targetConversation.addSingleMessage(messageToAdd);
} }
await message.handleReaction(reaction); await message.handleReaction(reaction);

View file

@ -116,7 +116,7 @@ export class ReadSyncs extends Collection {
// onReadMessage may result in messages older than this one being // onReadMessage may result in messages older than this one being
// marked read. We want those messages to have the same expire timer // marked read. We want those messages to have the same expire timer
// start time as this one, so we pass the readAt value through. // start time as this one, so we pass the readAt value through.
message.getConversation()?.onReadMessage(message, readAt); void message.getConversation()?.onReadMessage(message, readAt);
}; };
if (window.startupProcessingQueue) { if (window.startupProcessingQueue) {

View file

@ -98,7 +98,7 @@ export class ViewSyncs extends Collection {
const attachments = message.get('attachments'); const attachments = message.get('attachments');
if (!attachments?.every(isDownloaded)) { if (!attachments?.every(isDownloaded)) {
queueAttachmentDownloads(message.attributes); void queueAttachmentDownloads(message.attributes);
} }
} }

View file

@ -23,6 +23,7 @@ import type {
QuotedMessageType, QuotedMessageType,
SenderKeyInfoType, SenderKeyInfoType,
} from '../model-types.d'; } from '../model-types.d';
import { drop } from '../util/drop';
import { getInitials } from '../util/getInitials'; import { getInitials } from '../util/getInitials';
import { normalizeUuid } from '../util/normalizeUuid'; import { normalizeUuid } from '../util/normalizeUuid';
import { clearTimeoutIfNecessary } from '../util/clearTimeoutIfNecessary'; import { clearTimeoutIfNecessary } from '../util/clearTimeoutIfNecessary';
@ -880,19 +881,19 @@ export class ConversationModel extends window.Backbone
const uuid = this.get('uuid'); const uuid = this.get('uuid');
if (uuid) { if (uuid) {
window.storage.blocked.addBlockedUuid(uuid); drop(window.storage.blocked.addBlockedUuid(uuid));
blocked = true; blocked = true;
} }
const e164 = this.get('e164'); const e164 = this.get('e164');
if (e164) { if (e164) {
window.storage.blocked.addBlockedNumber(e164); drop(window.storage.blocked.addBlockedNumber(e164));
blocked = true; blocked = true;
} }
const groupId = this.get('groupId'); const groupId = this.get('groupId');
if (groupId) { if (groupId) {
window.storage.blocked.addBlockedGroup(groupId); drop(window.storage.blocked.addBlockedGroup(groupId));
blocked = true; blocked = true;
} }
@ -912,19 +913,19 @@ export class ConversationModel extends window.Backbone
const uuid = this.get('uuid'); const uuid = this.get('uuid');
if (uuid) { if (uuid) {
window.storage.blocked.removeBlockedUuid(uuid); drop(window.storage.blocked.removeBlockedUuid(uuid));
unblocked = true; unblocked = true;
} }
const e164 = this.get('e164'); const e164 = this.get('e164');
if (e164) { if (e164) {
window.storage.blocked.removeBlockedNumber(e164); drop(window.storage.blocked.removeBlockedNumber(e164));
unblocked = true; unblocked = true;
} }
const groupId = this.get('groupId'); const groupId = this.get('groupId');
if (groupId) { if (groupId) {
window.storage.blocked.removeBlockedGroup(groupId); drop(window.storage.blocked.removeBlockedGroup(groupId));
unblocked = true; unblocked = true;
} }
@ -936,7 +937,7 @@ export class ConversationModel extends window.Backbone
this.captureChange('unblock'); this.captureChange('unblock');
} }
this.fetchLatestGroupV2Data({ force: true }); void this.fetchLatestGroupV2Data({ force: true });
} }
return unblocked; return unblocked;
@ -1010,7 +1011,7 @@ export class ConversationModel extends window.Backbone
if (!this.typingRefreshTimer) { if (!this.typingRefreshTimer) {
const isTyping = true; const isTyping = true;
this.setTypingRefreshTimer(); this.setTypingRefreshTimer();
this.sendTypingMessage(isTyping); void this.sendTypingMessage(isTyping);
} }
this.setTypingPauseTimer(); this.setTypingPauseTimer();
@ -1026,7 +1027,7 @@ export class ConversationModel extends window.Backbone
onTypingRefreshTimeout(): void { onTypingRefreshTimeout(): void {
const isTyping = true; const isTyping = true;
this.sendTypingMessage(isTyping); void this.sendTypingMessage(isTyping);
// This timer will continue to reset itself until the pause timer stops it // This timer will continue to reset itself until the pause timer stops it
this.setTypingRefreshTimer(); this.setTypingRefreshTimer();
@ -1042,7 +1043,7 @@ export class ConversationModel extends window.Backbone
onTypingPauseTimeout(): void { onTypingPauseTimeout(): void {
const isTyping = false; const isTyping = false;
this.sendTypingMessage(isTyping); void this.sendTypingMessage(isTyping);
this.clearTypingTimers(); this.clearTypingTimers();
} }
@ -1331,7 +1332,7 @@ export class ConversationModel extends window.Backbone
return; return;
} }
this.addSingleMessage(message); void this.addSingleMessage(message);
} }
// New messages might arrive while we're in the middle of a bulk fetch from the // New messages might arrive while we're in the middle of a bulk fetch from the
@ -1380,7 +1381,7 @@ export class ConversationModel extends window.Backbone
newestId && messageIds && messageIds[messageIds.length - 1] === newestId; newestId && messageIds && messageIds[messageIds.length - 1] === newestId;
if (isJustSent && existingConversation && !isLatestInMemory) { if (isJustSent && existingConversation && !isLatestInMemory) {
this.loadNewestMessages(undefined, undefined); void this.loadNewestMessages(undefined, undefined);
} else if ( } else if (
// The message has to be not a story or has to be a story reply in direct // The message has to be not a story or has to be a story reply in direct
// conversation. // conversation.
@ -1452,12 +1453,12 @@ export class ConversationModel extends window.Backbone
// scroll directly to the oldest message, because that could scroll the hero off // scroll directly to the oldest message, because that could scroll the hero off
// the screen. // the screen.
if (!newestMessageId && !this.getAccepted() && metrics.oldest) { if (!newestMessageId && !this.getAccepted() && metrics.oldest) {
this.loadAndScroll(metrics.oldest.id, { disableScroll: true }); void this.loadAndScroll(metrics.oldest.id, { disableScroll: true });
return; return;
} }
if (scrollToLatestUnread && metrics.oldestUnseen) { if (scrollToLatestUnread && metrics.oldestUnseen) {
this.loadAndScroll(metrics.oldestUnseen.id, { void this.loadAndScroll(metrics.oldestUnseen.id, {
disableScroll: !setFocus, disableScroll: !setFocus,
}); });
return; return;
@ -1939,12 +1940,12 @@ export class ConversationModel extends window.Backbone
this.get('profileSharing') || this.get('sentMessageCount') this.get('profileSharing') || this.get('sentMessageCount')
); );
if (!oldValue && e164 && haveSentMessage && !disableDiscoveryNotification) { if (!oldValue && e164 && haveSentMessage && !disableDiscoveryNotification) {
this.addPhoneNumberDiscovery(e164); void this.addPhoneNumberDiscovery(e164);
} }
// This user changed their phone number // This user changed their phone number
if (oldValue && e164) { if (oldValue && e164) {
this.addChangeNumberNotification(oldValue, e164); void this.addChangeNumberNotification(oldValue, e164);
} }
window.Signal.Data.updateConversation(this.attributes); window.Signal.Data.updateConversation(this.attributes);
@ -1966,7 +1967,11 @@ export class ConversationModel extends window.Backbone
// for the case where we need to do old and new PNI comparisons. We'll wait // for the case where we need to do old and new PNI comparisons. We'll wait
// for the PNI update to do that. // for the PNI update to do that.
if (oldValue && oldValue !== this.get('pni')) { if (oldValue && oldValue !== this.get('pni')) {
window.textsecure.storage.protocol.removeIdentityKey(UUID.cast(oldValue)); drop(
window.textsecure.storage.protocol.removeIdentityKey(
UUID.cast(oldValue)
)
);
} }
this.captureChange('updateUuid'); this.captureChange('updateUuid');
@ -1985,7 +1990,7 @@ export class ConversationModel extends window.Backbone
log.warn( log.warn(
`${logId}: Already had previousIdentityKey, new one does not match` `${logId}: Already had previousIdentityKey, new one does not match`
); );
this.addKeyChange('trackPreviousIdentityKey - change'); void this.addKeyChange('trackPreviousIdentityKey - change');
} }
log.warn(`${logId}: Setting new previousIdentityKey`); log.warn(`${logId}: Setting new previousIdentityKey`);
@ -2031,7 +2036,7 @@ export class ConversationModel extends window.Backbone
newIdentityRecord.publicKey newIdentityRecord.publicKey
) )
) { ) {
this.addKeyChange('updatePni - change'); void this.addKeyChange('updatePni - change');
} else if (!newIdentityRecord && oldIdentityRecord) { } else if (!newIdentityRecord && oldIdentityRecord) {
this.trackPreviousIdentityKey(oldIdentityRecord.publicKey); this.trackPreviousIdentityKey(oldIdentityRecord.publicKey);
} }
@ -2052,7 +2057,11 @@ export class ConversationModel extends window.Backbone
// If this PNI is going away or going to someone else, we'll delete all its sessions // If this PNI is going away or going to someone else, we'll delete all its sessions
if (oldValue) { if (oldValue) {
window.textsecure.storage.protocol.removeIdentityKey(UUID.cast(oldValue)); drop(
window.textsecure.storage.protocol.removeIdentityKey(
UUID.cast(oldValue)
)
);
} }
if (pni && !this.get('uuid')) { if (pni && !this.get('uuid')) {
@ -2235,7 +2244,7 @@ export class ConversationModel extends window.Backbone
isGroupV1(this.attributes) || isGroupV1(this.attributes) ||
isDirectConversation(this.attributes) isDirectConversation(this.attributes)
) { ) {
this.sendProfileKeyUpdate(); void this.sendProfileKeyUpdate();
} else if ( } else if (
isGroupV2(this.attributes) && isGroupV2(this.attributes) &&
this.isMemberPending(ourACI) this.isMemberPending(ourACI)
@ -2283,7 +2292,7 @@ export class ConversationModel extends window.Backbone
// Delete messages locally, other devices should delete upon receiving // Delete messages locally, other devices should delete upon receiving
// the sync message // the sync message
await this.destroyMessages(); await this.destroyMessages();
this.updateLastMessage(); void this.updateLastMessage();
if (isLocalAction) { if (isLocalAction) {
this.trigger('unload', 'deleted from message request'); this.trigger('unload', 'deleted from message request');
@ -2302,7 +2311,7 @@ export class ConversationModel extends window.Backbone
// Delete messages locally, other devices should delete upon receiving // Delete messages locally, other devices should delete upon receiving
// the sync message // the sync message
await this.destroyMessages(); await this.destroyMessages();
this.updateLastMessage(); void this.updateLastMessage();
if (isLocalAction) { if (isLocalAction) {
this.trigger('unload', 'blocked and deleted from message request'); this.trigger('unload', 'blocked and deleted from message request');
@ -2944,7 +2953,7 @@ export class ConversationModel extends window.Backbone
); );
this.trigger('newmessage', model); this.trigger('newmessage', model);
this.updateUnread(); void this.updateUnread();
} }
async addDeliveryIssue({ async addDeliveryIssue({
@ -2990,7 +2999,7 @@ export class ConversationModel extends window.Backbone
this.trigger('newmessage', model); this.trigger('newmessage', model);
await this.notify(model); await this.notify(model);
this.updateUnread(); void this.updateUnread();
} }
async addKeyChange(reason: string, keyChangedId?: UUID): Promise<void> { async addKeyChange(reason: string, keyChangedId?: UUID): Promise<void> {
@ -3053,7 +3062,7 @@ export class ConversationModel extends window.Backbone
parsedUuid parsedUuid
); );
groups.forEach(group => { groups.forEach(group => {
group.addKeyChange('addKeyChange - group fan-out', parsedUuid); void group.addKeyChange('addKeyChange - group fan-out', parsedUuid);
}); });
} }
@ -3197,14 +3206,14 @@ export class ConversationModel extends window.Backbone
); );
this.trigger('newmessage', model); this.trigger('newmessage', model);
this.updateUnread(); void this.updateUnread();
const uuid = this.getUuid(); const uuid = this.getUuid();
if (isDirectConversation(this.attributes) && uuid) { if (isDirectConversation(this.attributes) && uuid) {
window.ConversationController.getAllGroupsInvolvingUuid(uuid).then( void window.ConversationController.getAllGroupsInvolvingUuid(uuid).then(
groups => { groups => {
groups.forEach(group => { groups.forEach(group => {
group.addVerifiedChange(this.id, verified, options); void group.addVerifiedChange(this.id, verified, options);
}); });
} }
); );
@ -3263,7 +3272,7 @@ export class ConversationModel extends window.Backbone
); );
this.trigger('newmessage', model); this.trigger('newmessage', model);
this.updateUnread(); void this.updateUnread();
if (this.get('isArchived')) { if (this.get('isArchived')) {
this.setArchived(false); this.setArchived(false);
@ -3289,7 +3298,7 @@ export class ConversationModel extends window.Backbone
(await window.Signal.Data.hasGroupCallHistoryMessage(this.id, eraId)); (await window.Signal.Data.hasGroupCallHistoryMessage(this.id, eraId));
if (alreadyHasMessage) { if (alreadyHasMessage) {
this.updateLastMessage(); void this.updateLastMessage();
return false; return false;
} }
@ -3338,10 +3347,10 @@ export class ConversationModel extends window.Backbone
const uuid = this.getUuid(); const uuid = this.getUuid();
if (isDirectConversation(this.attributes) && uuid) { if (isDirectConversation(this.attributes) && uuid) {
window.ConversationController.getAllGroupsInvolvingUuid(uuid).then( void window.ConversationController.getAllGroupsInvolvingUuid(uuid).then(
groups => { groups => {
groups.forEach(group => { groups.forEach(group => {
group.addProfileChange(profileChange, this.id); void group.addProfileChange(profileChange, this.id);
}); });
} }
); );
@ -3892,11 +3901,13 @@ export class ConversationModel extends window.Backbone
}, },
}; };
drop(
this.enqueueMessageForSend({ this.enqueueMessageForSend({
body: undefined, body: undefined,
attachments: [], attachments: [],
sticker, sticker,
}); })
);
window.reduxActions.stickers.useSticker(packId, stickerId); window.reduxActions.stickers.useSticker(packId, stickerId);
} }
@ -4019,7 +4030,7 @@ export class ConversationModel extends window.Backbone
if (preview && preview.length) { if (preview && preview.length) {
attachments.forEach(attachment => { attachments.forEach(attachment => {
if (attachment.path) { if (attachment.path) {
deleteAttachmentData(attachment.path); void deleteAttachmentData(attachment.path);
} }
}); });
} }
@ -4208,8 +4219,10 @@ export class ConversationModel extends window.Backbone
}); });
// This runs as a job to avoid race conditions // This runs as a job to avoid race conditions
drop(
this.queueJob('maybeSetPendingUniversalTimer', async () => this.queueJob('maybeSetPendingUniversalTimer', async () =>
this.maybeSetPendingUniversalTimer(stats.hasUserInitiatedMessages) this.maybeSetPendingUniversalTimer(stats.hasUserInitiatedMessages)
)
); );
const { preview, activity } = stats; const { preview, activity } = stats;
@ -4608,8 +4621,8 @@ export class ConversationModel extends window.Backbone
const message = window.MessageController.register(id, model); const message = window.MessageController.register(id, model);
this.addSingleMessage(message); void this.addSingleMessage(message);
this.updateUnread(); void this.updateUnread();
log.info( log.info(
`${logId}: added a notification received_at=${model.get('received_at')}` `${logId}: added a notification received_at=${model.get('received_at')}`
@ -4664,10 +4677,10 @@ export class ConversationModel extends window.Backbone
model.set({ id }); model.set({ id });
const message = window.MessageController.register(model.id, model); const message = window.MessageController.register(model.id, model);
this.addSingleMessage(message); void this.addSingleMessage(message);
const options = await getSendOptions(this.attributes); const options = await getSendOptions(this.attributes);
message.send( void message.send(
handleMessageSend( handleMessageSend(
messaging.leaveGroup(groupId, groupIdentifiers, options), messaging.leaveGroup(groupId, groupIdentifiers, options),
{ messageIds: [], sendType: 'legacyGroupChange' } { messageIds: [], sendType: 'legacyGroupChange' }
@ -4739,7 +4752,7 @@ export class ConversationModel extends window.Backbone
onChangeProfileKey(): void { onChangeProfileKey(): void {
if (isDirectConversation(this.attributes)) { if (isDirectConversation(this.attributes)) {
this.getProfiles(); void this.getProfiles();
} }
} }
@ -4799,9 +4812,9 @@ export class ConversationModel extends window.Backbone
): Promise<void> { ): Promise<void> {
if (isMe(this.attributes)) { if (isMe(this.attributes)) {
if (avatarPath) { if (avatarPath) {
window.storage.put('avatarUrl', avatarPath); await window.storage.put('avatarUrl', avatarPath);
} else { } else {
window.storage.remove('avatarUrl'); await window.storage.remove('avatarUrl');
} }
} }
@ -4938,7 +4951,7 @@ export class ConversationModel extends window.Backbone
'deriveProfileKeyVersion: Failed to derive profile key version, ' + 'deriveProfileKeyVersion: Failed to derive profile key version, ' +
'clearing profile key.' 'clearing profile key.'
); );
this.setProfileKey(undefined); void this.setProfileKey(undefined);
return; return;
} }
@ -5210,7 +5223,7 @@ export class ConversationModel extends window.Backbone
log.info('storageService[captureChange]', logMessage, this.idForLogging()); log.info('storageService[captureChange]', logMessage, this.idForLogging());
this.set({ needsStorageServiceSync: true }); this.set({ needsStorageServiceSync: true });
this.queueJob('captureChange', async () => { void this.queueJob('captureChange', async () => {
storageServiceUploadJob(); storageServiceUploadJob();
}); });
} }
@ -5474,7 +5487,7 @@ export class ConversationModel extends window.Backbone
} }
writePinnedConversations(pinnedConversationIds: Array<string>): void { writePinnedConversations(pinnedConversationIds: Array<string>): void {
window.storage.put('pinnedConversationIds', pinnedConversationIds); drop(window.storage.put('pinnedConversationIds', pinnedConversationIds));
const myId = window.ConversationController.getOurConversationId(); const myId = window.ConversationController.getOurConversationId();
const me = window.ConversationController.get(myId); const me = window.ConversationController.get(myId);

View file

@ -39,6 +39,7 @@ import { isNotNil } from '../util/isNotNil';
import { isNormalNumber } from '../util/isNormalNumber'; import { isNormalNumber } from '../util/isNormalNumber';
import { softAssert, strictAssert } from '../util/assert'; import { softAssert, strictAssert } from '../util/assert';
import { missingCaseError } from '../util/missingCaseError'; import { missingCaseError } from '../util/missingCaseError';
import { drop } from '../util/drop';
import { dropNull } from '../util/dropNull'; import { dropNull } from '../util/dropNull';
import { incrementMessageCounter } from '../util/incrementMessageCounter'; import { incrementMessageCounter } from '../util/incrementMessageCounter';
import type { ConversationModel } from './conversations'; import type { ConversationModel } from './conversations';
@ -1791,7 +1792,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
saveErrors(errorsToSave); saveErrors(errorsToSave);
} else { } else {
// We skip save because we'll save in the next step. // We skip save because we'll save in the next step.
this.saveErrors(errorsToSave, { skipSave: true }); void this.saveErrors(errorsToSave, { skipSave: true });
} }
if (!this.doNotSave) { if (!this.doNotSave) {
@ -1853,7 +1854,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
saveErrors(errors); saveErrors(errors);
} else { } else {
// We don't save because we're about to save below. // We don't save because we're about to save below.
this.saveErrors(errors, { skipSave: true }); void this.saveErrors(errors, { skipSave: true });
} }
throw error; throw error;
} finally { } finally {
@ -2583,15 +2584,19 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
// Note: We both queue and batch because we want to wait until we are done // Note: We both queue and batch because we want to wait until we are done
// processing incoming messages to start sending outgoing delivery receipts. // processing incoming messages to start sending outgoing delivery receipts.
// The queue can be paused easily. // The queue can be paused easily.
drop(
window.Whisper.deliveryReceiptQueue.add(() => { window.Whisper.deliveryReceiptQueue.add(() => {
window.Whisper.deliveryReceiptBatcher.add({ window.Whisper.deliveryReceiptBatcher.add({
messageId, messageId,
senderE164: source, senderE164: source,
senderUuid: sourceUuid, senderUuid: sourceUuid,
timestamp: this.get('sent_at'), timestamp: this.get('sent_at'),
isDirectConversation: isDirectConversation(conversation.attributes), isDirectConversation: isDirectConversation(
}); conversation.attributes
),
}); });
})
);
} }
const [quote, storyQuote] = await Promise.all([ const [quote, storyQuote] = await Promise.all([
@ -2957,7 +2962,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
// along with an expireTimer), the conversation will be updated by this // along with an expireTimer), the conversation will be updated by this
// point and these calls will return early. // point and these calls will return early.
if (dataMessage.expireTimer) { if (dataMessage.expireTimer) {
conversation.updateExpirationTimer(dataMessage.expireTimer, { void conversation.updateExpirationTimer(dataMessage.expireTimer, {
source: sourceUuid || source, source: sourceUuid || source,
receivedAt: message.get('received_at'), receivedAt: message.get('received_at'),
receivedAtMS: message.get('received_at_ms'), receivedAtMS: message.get('received_at_ms'),
@ -2970,7 +2975,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
!isGroupUpdate(message.attributes) && !isGroupUpdate(message.attributes) &&
!isEndSession(message.attributes) !isEndSession(message.attributes)
) { ) {
conversation.updateExpirationTimer(undefined, { void conversation.updateExpirationTimer(undefined, {
source: sourceUuid || source, source: sourceUuid || source,
receivedAt: message.get('received_at'), receivedAt: message.get('received_at'),
receivedAtMS: message.get('received_at_ms'), receivedAtMS: message.get('received_at_ms'),
@ -2989,14 +2994,14 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
) { ) {
conversation.set({ profileSharing: true }); conversation.set({ profileSharing: true });
} else if (isDirectConversation(conversation.attributes)) { } else if (isDirectConversation(conversation.attributes)) {
conversation.setProfileKey(profileKey); void conversation.setProfileKey(profileKey);
} else { } else {
const local = window.ConversationController.lookupOrCreate({ const local = window.ConversationController.lookupOrCreate({
e164: source, e164: source,
uuid: sourceUuid, uuid: sourceUuid,
reason: 'handleDataMessage:setProfileKey', reason: 'handleDataMessage:setProfileKey',
}); });
local?.setProfileKey(profileKey); void local?.setProfileKey(profileKey);
} }
} }
@ -3119,7 +3124,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
await this.modifyTargetMessage(conversation, isFirstRun); await this.modifyTargetMessage(conversation, isFirstRun);
log.info(`${idLog}: Batching save`); log.info(`${idLog}: Batching save`);
this.saveAndNotify(conversation, confirm); void this.saveAndNotify(conversation, confirm);
} catch (error) { } catch (error) {
const errorForLog = Errors.toLogFormat(error); const errorForLog = Errors.toLogFormat(error);
log.error(`${idLog}: error:`, errorForLog); log.error(`${idLog}: error:`, errorForLog);
@ -3154,7 +3159,9 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
confirm(); confirm();
if (!isStory(this.attributes)) { if (!isStory(this.attributes)) {
conversation.queueJob('updateUnread', () => conversation.updateUnread()); drop(
conversation.queueJob('updateUnread', () => conversation.updateUnread())
);
} }
} }
@ -3307,7 +3314,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
// We run this when `isFirstRun` is false so that it triggers when the // We run this when `isFirstRun` is false so that it triggers when the
// message and the other ones accompanying it in the batch are fully in // message and the other ones accompanying it in the batch are fully in
// the database. // the database.
message.getConversation()?.onReadMessage(message, markReadAt); void message.getConversation()?.onReadMessage(message, markReadAt);
} }
// Check for out-of-order view once open syncs // Check for out-of-order view once open syncs
@ -3450,7 +3457,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
'handleReaction: receiving story reaction to ' + 'handleReaction: receiving story reaction to ' +
`${this.idForLogging()} from someone else` `${this.idForLogging()} from someone else`
); );
conversation.notify(this, reaction); void conversation.notify(this, reaction);
} }
} else if (isFromThisDevice) { } else if (isFromThisDevice) {
log.info( log.info(
@ -3522,7 +3529,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
this.set({ reactions }); this.set({ reactions });
if (isOutgoing(this.attributes) && isFromSomeoneElse) { if (isOutgoing(this.attributes) && isFromSomeoneElse) {
conversation.notify(this, reaction); void conversation.notify(this, reaction);
} }
await window.Signal.Data.addReaction({ await window.Signal.Data.addReaction({
@ -3583,7 +3590,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
reactionMessage.hydrateStoryContext(this), reactionMessage.hydrateStoryContext(this),
]); ]);
conversation.addSingleMessage( void conversation.addSingleMessage(
window.MessageController.register(reactionMessage.id, reactionMessage) window.MessageController.register(reactionMessage.id, reactionMessage)
); );
@ -3652,7 +3659,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
); );
// Update the conversation's last message in case this was the last message // Update the conversation's last message in case this was the last message
this.getConversation()?.updateLastMessage(); void this.getConversation()?.updateLastMessage();
} finally { } finally {
this.deletingForEveryone = undefined; this.deletingForEveryone = undefined;
} }

View file

@ -14,6 +14,7 @@ import type { ConversationModel } from './models/conversations';
import type { StorageInterface } from './types/Storage.d'; import type { StorageInterface } from './types/Storage.d';
import * as Errors from './types/errors'; import * as Errors from './types/errors';
import { getProfile } from './util/getProfile'; import { getProfile } from './util/getProfile';
import { drop } from './util/drop';
import { MINUTE, HOUR, DAY, WEEK, MONTH } from './util/durations'; import { MINUTE, HOUR, DAY, WEEK, MONTH } from './util/durations';
const STORAGE_KEY = 'lastAttemptedToRefreshProfilesAt'; const STORAGE_KEY = 'lastAttemptedToRefreshProfilesAt';
@ -155,7 +156,7 @@ export async function routineProfileRefresh({
throwOnTimeout: true, throwOnTimeout: true,
}); });
for (const conversation of conversationsToRefresh) { for (const conversation of conversationsToRefresh) {
refreshQueue.add(() => refreshConversation(conversation)); drop(refreshQueue.add(() => refreshConversation(conversation)));
} }
await refreshQueue.onIdle(); await refreshQueue.onIdle();

View file

@ -92,7 +92,7 @@ function _maybeGrabLinkPreview(
return; return;
} }
addLinkPreview(link, source, { void addLinkPreview(link, source, {
disableFetch: !window.Events.getLinkPreviewSetting(), disableFetch: !window.Events.getLinkPreviewSetting(),
}); });
} }

View file

@ -19,13 +19,13 @@ export class AreWeASubscriberService {
const subscriberId = storage.get('subscriberId'); const subscriberId = storage.get('subscriberId');
if (!subscriberId || !subscriberId.byteLength) { if (!subscriberId || !subscriberId.byteLength) {
storage.put('areWeASubscriber', false); await storage.put('areWeASubscriber', false);
return; return;
} }
await waitForOnline(navigator, window); await waitForOnline(navigator, window);
storage.put( await storage.put(
'areWeASubscriber', 'areWeASubscriber',
await server.getHasSubscription(subscriberId) await server.getHasSubscription(subscriberId)
); );

View file

@ -39,7 +39,7 @@ export class RecorderClass {
this.stream = undefined; this.stream = undefined;
if (this.context) { if (this.context) {
this.context.close(); void this.context.close();
this.context = undefined; this.context = undefined;
} }
} }

View file

@ -71,6 +71,7 @@ import * as Errors from '../types/errors';
import type { ConversationModel } from '../models/conversations'; import type { ConversationModel } from '../models/conversations';
import * as Bytes from '../Bytes'; import * as Bytes from '../Bytes';
import { uuidToBytes, bytesToUuid } from '../Crypto'; import { uuidToBytes, bytesToUuid } from '../Crypto';
import { drop } from '../util/drop';
import { dropNull, shallowDropNull } from '../util/dropNull'; import { dropNull, shallowDropNull } from '../util/dropNull';
import { getOwn } from '../util/getOwn'; import { getOwn } from '../util/getOwn';
import { isNormalNumber } from '../util/isNormalNumber'; import { isNormalNumber } from '../util/isNormalNumber';
@ -311,9 +312,11 @@ export class CallingClass {
window.storage.get('previousAudioDeviceModule') window.storage.get('previousAudioDeviceModule')
); );
this.currentAudioDeviceModule = getAudioDeviceModule(); this.currentAudioDeviceModule = getAudioDeviceModule();
drop(
window.storage.put( window.storage.put(
'previousAudioDeviceModule', 'previousAudioDeviceModule',
this.currentAudioDeviceModule this.currentAudioDeviceModule
)
); );
RingRTC.setConfig({ RingRTC.setConfig({
@ -348,7 +351,7 @@ export class CallingClass {
} }
}); });
this.cleanExpiredGroupCallRingsAndLoop(); void this.cleanExpiredGroupCallRingsAndLoop();
} }
private attemptToGiveOurUuidToRingRtc(): void { private attemptToGiveOurUuidToRingRtc(): void {
@ -699,7 +702,7 @@ export class CallingClass {
eraId eraId
) { ) {
updateMessageState = GroupCallUpdateMessageState.SentLeft; updateMessageState = GroupCallUpdateMessageState.SentLeft;
this.sendGroupCallUpdateMessage(conversationId, eraId); void this.sendGroupCallUpdateMessage(conversationId, eraId);
} }
} else { } else {
this.callsByConversation[conversationId] = groupCall; this.callsByConversation[conversationId] = groupCall;
@ -717,7 +720,7 @@ export class CallingClass {
eraId eraId
) { ) {
updateMessageState = GroupCallUpdateMessageState.SentJoin; updateMessageState = GroupCallUpdateMessageState.SentJoin;
this.sendGroupCallUpdateMessage(conversationId, eraId); void this.sendGroupCallUpdateMessage(conversationId, eraId);
} }
} }
@ -749,10 +752,10 @@ export class CallingClass {
eraId eraId
) { ) {
updateMessageState = GroupCallUpdateMessageState.SentJoin; updateMessageState = GroupCallUpdateMessageState.SentJoin;
this.sendGroupCallUpdateMessage(conversationId, eraId); void this.sendGroupCallUpdateMessage(conversationId, eraId);
} }
this.updateCallHistoryForGroupCall( void this.updateCallHistoryForGroupCall(
conversationId, conversationId,
groupCall.getPeekInfo() groupCall.getPeekInfo()
); );
@ -1458,7 +1461,7 @@ export class CallingClass {
device.index, device.index,
truncateForLogging(device.name) truncateForLogging(device.name)
); );
window.Events.setPreferredAudioInputDevice(device); void window.Events.setPreferredAudioInputDevice(device);
RingRTC.setAudioInput(device.index); RingRTC.setAudioInput(device.index);
} }
@ -1468,7 +1471,7 @@ export class CallingClass {
device.index, device.index,
truncateForLogging(device.name) truncateForLogging(device.name)
); );
window.Events.setPreferredAudioOutputDevice(device); void window.Events.setPreferredAudioOutputDevice(device);
RingRTC.setAudioOutput(device.index); RingRTC.setAudioOutput(device.index);
} }
@ -1482,7 +1485,7 @@ export class CallingClass {
async setPreferredCamera(device: string): Promise<void> { async setPreferredCamera(device: string): Promise<void> {
log.info('MediaDevice: setPreferredCamera', device); log.info('MediaDevice: setPreferredCamera', device);
window.Events.setPreferredVideoInputDevice(device); void window.Events.setPreferredVideoInputDevice(device);
await this.videoCapturer.setPreferredDevice(device); await this.videoCapturer.setPreferredDevice(device);
} }
@ -2107,7 +2110,7 @@ export class CallingClass {
acceptedTime = Date.now(); acceptedTime = Date.now();
} }
conversation.addCallHistory( void conversation.addCallHistory(
{ {
callMode: CallMode.Direct, callMode: CallMode.Direct,
wasIncoming: call.isIncoming, wasIncoming: call.isIncoming,
@ -2125,7 +2128,7 @@ export class CallingClass {
wasVideoCall: boolean, wasVideoCall: boolean,
timestamp: number timestamp: number
) { ) {
conversation.addCallHistory( void conversation.addCallHistory(
{ {
callMode: CallMode.Direct, callMode: CallMode.Direct,
wasIncoming: true, wasIncoming: true,
@ -2156,7 +2159,7 @@ export class CallingClass {
} }
// Otherwise it will show up as a missed call. // Otherwise it will show up as a missed call.
conversation.addCallHistory( void conversation.addCallHistory(
{ {
callMode: CallMode.Direct, callMode: CallMode.Direct,
wasIncoming: true, wasIncoming: true,
@ -2264,7 +2267,7 @@ export class CallingClass {
} }
setTimeout(() => { setTimeout(() => {
this.cleanExpiredGroupCallRingsAndLoop(); void this.cleanExpiredGroupCallRingsAndLoop();
}, CLEAN_EXPIRED_GROUP_CALL_RINGS_INTERVAL); }, CLEAN_EXPIRED_GROUP_CALL_RINGS_INTERVAL);
} }
} }

View file

@ -78,7 +78,7 @@ class ExpiringMessagesDeletionService {
window.SignalContext.log.info( window.SignalContext.log.info(
'destroyExpiredMessages: done, scheduling another check' 'destroyExpiredMessages: done, scheduling another check'
); );
this.update(); void this.update();
} }
private async checkExpiringMessages() { private async checkExpiringMessages() {

View file

@ -191,7 +191,7 @@ export async function maybeFetchNewCredentials(): Promise<void> {
log.info(`${logId}: Saving new credentials...`); log.info(`${logId}: Saving new credentials...`);
// Note: we don't wait for this to finish // Note: we don't wait for this to finish
window.storage.put('groupCredentials', finalCredentials); await window.storage.put('groupCredentials', finalCredentials);
log.info(`${logId}: Save complete.`); log.info(`${logId}: Save complete.`);
} }

View file

@ -26,7 +26,7 @@ export function initializeNetworkObserver(
if (socketStatus === SocketStatus.CLOSED) { if (socketStatus === SocketStatus.CLOSED) {
// If we couldn't connect during startup - we should still switch SQL to // If we couldn't connect during startup - we should still switch SQL to
// the main process to avoid stalling UI. // the main process to avoid stalling UI.
window.Signal.Data.goBackToMainProcess(); void window.Signal.Data.goBackToMainProcess();
} }
networkActions.checkNetworkStatus({ networkActions.checkNetworkStatus({

View file

@ -157,7 +157,7 @@ class NotificationService extends EventEmitter {
audioNotificationSupport === AudioNotificationSupport.Custom audioNotificationSupport === AudioNotificationSupport.Custom
) { ) {
// We kick off the sound to be played. No need to await it. // We kick off the sound to be played. No need to await it.
new Sound({ src: 'sounds/notification.ogg' }).play(); void new Sound({ src: 'sounds/notification.ogg' }).play();
} }
this.lastNotification = notification; this.lastNotification = notification;

View file

@ -26,6 +26,7 @@ import { isMe } from '../util/whatTypeOfConversation';
import { getUserLanguages } from '../util/userLanguages'; import { getUserLanguages } from '../util/userLanguages';
import { parseBadgesFromServer } from '../badges/parseBadgesFromServer'; import { parseBadgesFromServer } from '../badges/parseBadgesFromServer';
import { strictAssert } from '../util/assert'; import { strictAssert } from '../util/assert';
import { drop } from '../util/drop';
import { findRetryAfterTimeFromError } from '../jobs/helpers/findRetryAfterTimeFromError'; import { findRetryAfterTimeFromError } from '../jobs/helpers/findRetryAfterTimeFromError';
import { SEALED_SENDER } from '../types/SealedSender'; import { SEALED_SENDER } from '../types/SealedSender';
import { HTTPError } from '../textsecure/Errors'; import { HTTPError } from '../textsecure/Errors';
@ -123,7 +124,7 @@ export class ProfileService {
if (isRecord(error) && 'code' in error && error.code === 413) { if (isRecord(error) && 'code' in error && error.code === 413) {
this.clearAll('got 413 from server'); this.clearAll('got 413 from server');
const time = findRetryAfterTimeFromError(error); const time = findRetryAfterTimeFromError(error);
this.pause(time); void this.pause(time);
} }
} finally { } finally {
this.jobsByConversationId.delete(conversationId); this.jobsByConversationId.delete(conversationId);
@ -139,7 +140,7 @@ export class ProfileService {
}; };
this.jobsByConversationId.set(conversationId, jobData); this.jobsByConversationId.set(conversationId, jobData);
this.jobQueue.add(job); drop(this.jobQueue.add(job));
return promise; return promise;
} }
@ -416,7 +417,7 @@ async function doGetProfile(c: ConversationModel): Promise<void> {
} }
if (profile.paymentAddress && isMe(c.attributes)) { if (profile.paymentAddress && isMe(c.attributes)) {
window.storage.put('paymentAddress', profile.paymentAddress); await window.storage.put('paymentAddress', profile.paymentAddress);
} }
if (profile.capabilities) { if (profile.capabilities) {

View file

@ -361,7 +361,7 @@ async function generateManifest(
if (isNewItem) { if (isNewItem) {
postUploadUpdateFunctions.push(() => { postUploadUpdateFunctions.push(() => {
dataInterface.modifyStoryDistribution({ void dataInterface.modifyStoryDistribution({
...storyDistributionList, ...storyDistributionList,
storageID, storageID,
storageVersion: version, storageVersion: version,
@ -394,7 +394,7 @@ async function generateManifest(
if (isNewItem) { if (isNewItem) {
postUploadUpdateFunctions.push(() => { postUploadUpdateFunctions.push(() => {
dataInterface.addUninstalledStickerPack({ void dataInterface.addUninstalledStickerPack({
...stickerPack, ...stickerPack,
storageID, storageID,
storageVersion: version, storageVersion: version,
@ -436,7 +436,7 @@ async function generateManifest(
if (isNewItem) { if (isNewItem) {
postUploadUpdateFunctions.push(() => { postUploadUpdateFunctions.push(() => {
dataInterface.createOrUpdateStickerPack({ void dataInterface.createOrUpdateStickerPack({
...stickerPack, ...stickerPack,
storageID, storageID,
storageVersion: version, storageVersion: version,
@ -784,7 +784,7 @@ async function uploadManifest(
} }
log.info(`storageService.upload(${version}): setting new manifestVersion`); log.info(`storageService.upload(${version}): setting new manifestVersion`);
window.storage.put('manifestVersion', version); await window.storage.put('manifestVersion', version);
conflictBackOff.reset(); conflictBackOff.reset();
backOff.reset(); backOff.reset();
@ -883,7 +883,7 @@ async function fetchManifest(
try { try {
const credentials = const credentials =
await window.textsecure.messaging.getStorageCredentials(); await window.textsecure.messaging.getStorageCredentials();
window.storage.put('storageCredentials', credentials); await window.storage.put('storageCredentials', credentials);
const manifestBinary = await window.textsecure.messaging.getStorageManifest( const manifestBinary = await window.textsecure.messaging.getStorageManifest(
{ {
@ -1247,7 +1247,7 @@ async function processManifest(
`storageService.process(${version}): localKey=${missingKey} was not ` + `storageService.process(${version}): localKey=${missingKey} was not ` +
'in remote manifest' 'in remote manifest'
); );
dataInterface.addUninstalledStickerPack({ void dataInterface.addUninstalledStickerPack({
...stickerPack, ...stickerPack,
storageID: undefined, storageID: undefined,
storageVersion: undefined, storageVersion: undefined,
@ -1265,7 +1265,7 @@ async function processManifest(
`storageService.process(${version}): localKey=${missingKey} was not ` + `storageService.process(${version}): localKey=${missingKey} was not ` +
'in remote manifest' 'in remote manifest'
); );
dataInterface.createOrUpdateStickerPack({ void dataInterface.createOrUpdateStickerPack({
...stickerPack, ...stickerPack,
storageID: undefined, storageID: undefined,
storageVersion: undefined, storageVersion: undefined,
@ -1283,7 +1283,7 @@ async function processManifest(
`storageService.process(${version}): localKey=${missingKey} was not ` + `storageService.process(${version}): localKey=${missingKey} was not ` +
'in remote manifest' 'in remote manifest'
); );
dataInterface.modifyStoryDistribution({ void dataInterface.modifyStoryDistribution({
...storyDistributionList, ...storyDistributionList,
storageID: undefined, storageID: undefined,
storageVersion: undefined, storageVersion: undefined,
@ -1688,7 +1688,7 @@ async function sync(
const previousFetchComplete = window.storage.get('storageFetchComplete'); const previousFetchComplete = window.storage.get('storageFetchComplete');
const manifestFromStorage = window.storage.get('manifestVersion'); const manifestFromStorage = window.storage.get('manifestVersion');
if (!previousFetchComplete && isNumber(manifestFromStorage)) { if (!previousFetchComplete && isNumber(manifestFromStorage)) {
window.storage.put('storageFetchComplete', true); await window.storage.put('storageFetchComplete', true);
} }
const localManifestVersion = manifestFromStorage || 0; const localManifestVersion = manifestFromStorage || 0;
@ -1931,7 +1931,7 @@ export const storageServiceUploadJob = debounce(() => {
return; return;
} }
storageJobQueue(async () => { void storageJobQueue(async () => {
await upload(); await upload();
}, `upload v${window.storage.get('manifestVersion')}`); }, `upload v${window.storage.get('manifestVersion')}`);
}, 500); }, 500);

View file

@ -523,14 +523,14 @@ function applyMessageRequestState(
const messageRequestEnum = Proto.SyncMessage.MessageRequestResponse.Type; const messageRequestEnum = Proto.SyncMessage.MessageRequestResponse.Type;
if (record.blocked) { if (record.blocked) {
conversation.applyMessageRequestResponse(messageRequestEnum.BLOCK, { void conversation.applyMessageRequestResponse(messageRequestEnum.BLOCK, {
fromSync: true, fromSync: true,
viaStorageServiceSync: true, viaStorageServiceSync: true,
}); });
} else if (record.whitelisted) { } else if (record.whitelisted) {
// unblocking is also handled by this function which is why the next // unblocking is also handled by this function which is why the next
// condition is part of the else-if and not separate // condition is part of the else-if and not separate
conversation.applyMessageRequestResponse(messageRequestEnum.ACCEPT, { void conversation.applyMessageRequestResponse(messageRequestEnum.ACCEPT, {
fromSync: true, fromSync: true,
viaStorageServiceSync: true, viaStorageServiceSync: true,
}); });
@ -893,7 +893,7 @@ export async function mergeGroupV2Record(
// We don't await this because this could take a very long time, waiting for queues to // We don't await this because this could take a very long time, waiting for queues to
// empty, etc. // empty, etc.
waitThenRespondToGroupV2Migration({ void waitThenRespondToGroupV2Migration({
conversation, conversation,
}); });
} else if (isGroupNewToUs) { } else if (isGroupNewToUs) {
@ -903,7 +903,7 @@ export async function mergeGroupV2Record(
// We don't await this because this could take a very long time, waiting for queues to // We don't await this because this could take a very long time, waiting for queues to
// empty, etc. // empty, etc.
waitThenMaybeUpdateGroup( void waitThenMaybeUpdateGroup(
{ {
conversation, conversation,
dropInitialJoinMessage, dropInitialJoinMessage,
@ -1001,7 +1001,7 @@ export async function mergeContactRecord(
) { ) {
// Local name doesn't match remote name, fetch profile // Local name doesn't match remote name, fetch profile
if (localName) { if (localName) {
conversation.getProfiles(); void conversation.getProfiles();
details.push('refreshing profile'); details.push('refreshing profile');
} else { } else {
conversation.set({ conversation.set({
@ -1134,36 +1134,36 @@ export async function mergeAccountRecord(
const updatedConversations = new Array<ConversationModel>(); const updatedConversations = new Array<ConversationModel>();
window.storage.put('read-receipt-setting', Boolean(readReceipts)); await window.storage.put('read-receipt-setting', Boolean(readReceipts));
if (typeof sealedSenderIndicators === 'boolean') { if (typeof sealedSenderIndicators === 'boolean') {
window.storage.put('sealedSenderIndicators', sealedSenderIndicators); await window.storage.put('sealedSenderIndicators', sealedSenderIndicators);
} }
if (typeof typingIndicators === 'boolean') { if (typeof typingIndicators === 'boolean') {
window.storage.put('typingIndicators', typingIndicators); await window.storage.put('typingIndicators', typingIndicators);
} }
if (typeof linkPreviews === 'boolean') { if (typeof linkPreviews === 'boolean') {
window.storage.put('linkPreviews', linkPreviews); await window.storage.put('linkPreviews', linkPreviews);
} }
if (typeof preferContactAvatars === 'boolean') { if (typeof preferContactAvatars === 'boolean') {
const previous = window.storage.get('preferContactAvatars'); const previous = window.storage.get('preferContactAvatars');
window.storage.put('preferContactAvatars', preferContactAvatars); await window.storage.put('preferContactAvatars', preferContactAvatars);
if (Boolean(previous) !== Boolean(preferContactAvatars)) { if (Boolean(previous) !== Boolean(preferContactAvatars)) {
window.ConversationController.forceRerender(); await window.ConversationController.forceRerender();
} }
} }
if (typeof primarySendsSms === 'boolean') { if (typeof primarySendsSms === 'boolean') {
window.storage.put('primarySendsSms', primarySendsSms); await window.storage.put('primarySendsSms', primarySendsSms);
} }
if (typeof accountE164 === 'string' && accountE164) { if (typeof accountE164 === 'string' && accountE164) {
window.storage.put('accountE164', accountE164); await window.storage.put('accountE164', accountE164);
window.storage.user.setNumber(accountE164); await window.storage.user.setNumber(accountE164);
} }
if (preferredReactionEmoji.canBeSynced(rawPreferredReactionEmoji)) { if (preferredReactionEmoji.canBeSynced(rawPreferredReactionEmoji)) {
@ -1176,10 +1176,13 @@ export async function mergeAccountRecord(
rawPreferredReactionEmoji.length rawPreferredReactionEmoji.length
); );
} }
window.storage.put('preferredReactionEmoji', rawPreferredReactionEmoji); await window.storage.put(
'preferredReactionEmoji',
rawPreferredReactionEmoji
);
} }
setUniversalExpireTimer( void setUniversalExpireTimer(
DurationInSeconds.fromSeconds(universalExpireTimer || 0) DurationInSeconds.fromSeconds(universalExpireTimer || 0)
); );
@ -1206,15 +1209,18 @@ export async function mergeAccountRecord(
phoneNumberSharingModeToStore = PhoneNumberSharingMode.Everybody; phoneNumberSharingModeToStore = PhoneNumberSharingMode.Everybody;
break; break;
} }
window.storage.put('phoneNumberSharingMode', phoneNumberSharingModeToStore); await window.storage.put(
'phoneNumberSharingMode',
phoneNumberSharingModeToStore
);
const discoverability = notDiscoverableByPhoneNumber const discoverability = notDiscoverableByPhoneNumber
? PhoneNumberDiscoverability.NotDiscoverable ? PhoneNumberDiscoverability.NotDiscoverable
: PhoneNumberDiscoverability.Discoverable; : PhoneNumberDiscoverability.Discoverable;
window.storage.put('phoneNumberDiscoverability', discoverability); await window.storage.put('phoneNumberDiscoverability', discoverability);
if (profileKey) { if (profileKey) {
ourProfileKeyService.set(profileKey); void ourProfileKeyService.set(profileKey);
} }
if (pinnedConversations) { if (pinnedConversations) {
@ -1323,40 +1329,52 @@ export async function mergeAccountRecord(
updatedConversations.push(conversation); updatedConversations.push(conversation);
}); });
window.storage.put('pinnedConversationIds', remotelyPinnedConversationIds); await window.storage.put(
'pinnedConversationIds',
remotelyPinnedConversationIds
);
} }
if (subscriberId instanceof Uint8Array) { if (subscriberId instanceof Uint8Array) {
window.storage.put('subscriberId', subscriberId); await window.storage.put('subscriberId', subscriberId);
} }
if (typeof subscriberCurrencyCode === 'string') { if (typeof subscriberCurrencyCode === 'string') {
window.storage.put('subscriberCurrencyCode', subscriberCurrencyCode); await window.storage.put('subscriberCurrencyCode', subscriberCurrencyCode);
} }
window.storage.put('displayBadgesOnProfile', Boolean(displayBadgesOnProfile)); await window.storage.put(
window.storage.put('keepMutedChatsArchived', Boolean(keepMutedChatsArchived)); 'displayBadgesOnProfile',
window.storage.put('hasSetMyStoriesPrivacy', Boolean(hasSetMyStoriesPrivacy)); Boolean(displayBadgesOnProfile)
);
await window.storage.put(
'keepMutedChatsArchived',
Boolean(keepMutedChatsArchived)
);
await window.storage.put(
'hasSetMyStoriesPrivacy',
Boolean(hasSetMyStoriesPrivacy)
);
{ {
const hasViewedOnboardingStoryBool = Boolean(hasViewedOnboardingStory); const hasViewedOnboardingStoryBool = Boolean(hasViewedOnboardingStory);
window.storage.put( await window.storage.put(
'hasViewedOnboardingStory', 'hasViewedOnboardingStory',
hasViewedOnboardingStoryBool hasViewedOnboardingStoryBool
); );
if (hasViewedOnboardingStoryBool) { if (hasViewedOnboardingStoryBool) {
findAndDeleteOnboardingStoryIfExists(); void findAndDeleteOnboardingStoryIfExists();
} }
} }
{ {
const hasStoriesDisabled = Boolean(storiesDisabled); const hasStoriesDisabled = Boolean(storiesDisabled);
window.storage.put('hasStoriesDisabled', hasStoriesDisabled); await window.storage.put('hasStoriesDisabled', hasStoriesDisabled);
window.textsecure.server?.onHasStoriesDisabledChange(hasStoriesDisabled); window.textsecure.server?.onHasStoriesDisabledChange(hasStoriesDisabled);
} }
switch (storyViewReceiptsEnabled) { switch (storyViewReceiptsEnabled) {
case Proto.OptionalBool.ENABLED: case Proto.OptionalBool.ENABLED:
window.storage.put('storyViewReceiptsEnabled', true); await window.storage.put('storyViewReceiptsEnabled', true);
break; break;
case Proto.OptionalBool.DISABLED: case Proto.OptionalBool.DISABLED:
window.storage.put('storyViewReceiptsEnabled', false); await window.storage.put('storyViewReceiptsEnabled', false);
break; break;
case Proto.OptionalBool.UNSET: case Proto.OptionalBool.UNSET:
default: default:
@ -1396,7 +1414,7 @@ export async function mergeAccountRecord(
const avatarUrl = dropNull(accountRecord.avatarUrl); const avatarUrl = dropNull(accountRecord.avatarUrl);
await conversation.setProfileAvatar(avatarUrl, profileKey); await conversation.setProfileAvatar(avatarUrl, profileKey);
window.storage.put('avatarUrl', avatarUrl); await window.storage.put('avatarUrl', avatarUrl);
} }
const { hasConflict, details: extraDetails } = doesRecordHavePendingChanges( const { hasConflict, details: extraDetails } = doesRecordHavePendingChanges(
@ -1663,7 +1681,7 @@ export async function mergeStickerPackRecord(
} }
); );
} else { } else {
Stickers.downloadStickerPack(stickerPack.id, stickerPack.key, { void Stickers.downloadStickerPack(stickerPack.id, stickerPack.key, {
finalStatus: 'installed', finalStatus: 'installed',
fromStorageService: true, fromStorageService: true,
}); });

View file

@ -76,7 +76,7 @@ class TapToViewMessagesDeletionService {
clearTimeoutIfNecessary(this.timeout); clearTimeoutIfNecessary(this.timeout);
this.timeout = setTimeout(async () => { this.timeout = setTimeout(async () => {
await eraseTapToViewMessages(); await eraseTapToViewMessages();
this.update(); void this.update();
}, wait); }, wait);
} }
} }

View file

@ -4,11 +4,11 @@
import type { StorageAccessType } from '../types/Storage.d'; import type { StorageAccessType } from '../types/Storage.d';
// Matching window.storage.put API // Matching window.storage.put API
export function put<K extends keyof StorageAccessType>( export async function put<K extends keyof StorageAccessType>(
key: K, key: K,
value: StorageAccessType[K] value: StorageAccessType[K]
): void { ): Promise<void> {
window.storage.put(key, value); await window.storage.put(key, value);
} }
export async function remove(key: keyof StorageAccessType): Promise<void> { export async function remove(key: keyof StorageAccessType): Promise<void> {

View file

@ -37,6 +37,7 @@ import * as Errors from '../types/errors';
import type { StoredJob } from '../jobs/types'; import type { StoredJob } from '../jobs/types';
import { formatJobForInsert } from '../jobs/formatJobForInsert'; import { formatJobForInsert } from '../jobs/formatJobForInsert';
import { cleanupMessage } from '../util/cleanup'; import { cleanupMessage } from '../util/cleanup';
import { drop } from '../util/drop';
import type { import type {
AllItemsType, AllItemsType,
@ -631,8 +632,8 @@ async function saveMessage(
softAssert(isValidUuid(id), 'saveMessage: messageId is not a UUID'); softAssert(isValidUuid(id), 'saveMessage: messageId is not a UUID');
expiringMessagesDeletionService.update(); void expiringMessagesDeletionService.update();
tapToViewMessagesDeletionService.update(); void tapToViewMessagesDeletionService.update();
return id; return id;
} }
@ -646,8 +647,8 @@ async function saveMessages(
options options
); );
expiringMessagesDeletionService.update(); void expiringMessagesDeletionService.update();
tapToViewMessagesDeletionService.update(); void tapToViewMessagesDeletionService.update();
} }
async function removeMessage(id: string): Promise<void> { async function removeMessage(id: string): Promise<void> {
@ -781,10 +782,12 @@ async function removeAllMessagesInConversation(
// Note: It's very important that these models are fully hydrated because // Note: It's very important that these models are fully hydrated because
// we need to delete all associated on-disk files along with the database delete. // we need to delete all associated on-disk files along with the database delete.
const queue = new PQueue({ concurrency: 3, timeout: MINUTE * 30 }); const queue = new PQueue({ concurrency: 3, timeout: MINUTE * 30 });
drop(
queue.addAll( queue.addAll(
messages.map( messages.map(
(message: MessageType) => async () => cleanupMessage(message) (message: MessageType) => async () => cleanupMessage(message)
) )
)
); );
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
await queue.onIdle(); await queue.onIdle();

View file

@ -122,7 +122,7 @@ function setIsPlaying(value: boolean): SetIsPlayingAction {
if (!value) { if (!value) {
globalMessageAudio.pause(); globalMessageAudio.pause();
} else { } else {
globalMessageAudio.play(); void globalMessageAudio.play();
} }
return { return {
type: 'audioPlayer/SET_IS_PLAYING', type: 'audioPlayer/SET_IS_PLAYING',
@ -244,7 +244,7 @@ function loadAndPlayMessageAudio(
// navigates away from the conversation // navigates away from the conversation
// TODO: DESKTOP-4158 // TODO: DESKTOP-4158
if (nextVoiceNoteMessage) { if (nextVoiceNoteMessage) {
stateChangeConfirmUpSound.play(); void stateChangeConfirmUpSound.play();
dispatch( dispatch(
loadAndPlayMessageAudio( loadAndPlayMessageAudio(
nextVoiceNoteMessage.id, nextVoiceNoteMessage.id,
@ -255,7 +255,7 @@ function loadAndPlayMessageAudio(
) )
); );
} else if (isConsecutive) { } else if (isConsecutive) {
stateChangeConfirmDownSound.play(); void stateChangeConfirmDownSound.play();
} }
}, },
}); });

View file

@ -197,7 +197,7 @@ function cancelRecording(): ThunkAction<
function errorRecording( function errorRecording(
errorDialogAudioRecorderType: ErrorDialogAudioRecorderType errorDialogAudioRecorderType: ErrorDialogAudioRecorderType
): ErrorRecordingAction { ): ErrorRecordingAction {
recorder.stop(); void recorder.stop();
return { return {
type: ERROR_RECORDING, type: ERROR_RECORDING,

View file

@ -76,7 +76,7 @@ function updateOrCreate(
payload: badges, payload: badges,
}); });
badgeImageFileDownloader.checkForFilesToDownload(); void badgeImageFileDownloader.checkForFilesToDownload();
}; };
} }

View file

@ -864,7 +864,7 @@ function groupCallStateChange(
}); });
if (didSomeoneStartPresenting) { if (didSomeoneStartPresenting) {
callingTones.someonePresenting(); void callingTones.someonePresenting();
} }
if (payload.connectionState === GroupCallConnectionState.NotConnected) { if (payload.connectionState === GroupCallConnectionState.NotConnected) {
@ -978,7 +978,7 @@ function openSystemPreferencesAction(): ThunkAction<
never never
> { > {
return () => { return () => {
openSystemPreferences(); void openSystemPreferences();
}; };
} }

View file

@ -177,7 +177,7 @@ function onClearAttachments(conversationId: string): NoopActionType {
throw new Error('onClearAttachments: No conversation found'); throw new Error('onClearAttachments: No conversation found');
} }
clearConversationDraftAttachments( void clearConversationDraftAttachments(
conversation.id, conversation.id,
conversation.get('draftAttachments') conversation.get('draftAttachments')
); );
@ -194,7 +194,7 @@ function cancelJoinRequest(conversationId: string): NoopActionType {
throw new Error('cancelJoinRequest: No conversation found'); throw new Error('cancelJoinRequest: No conversation found');
} }
longRunningTaskWrapper({ void longRunningTaskWrapper({
idForLogging: conversation.idForLogging(), idForLogging: conversation.idForLogging(),
name: 'cancelJoinRequest', name: 'cancelJoinRequest',
task: async () => conversation.cancelJoinRequest(), task: async () => conversation.cancelJoinRequest(),
@ -383,7 +383,10 @@ function sendMultiMediaMessage(
extraReduxActions: () => { extraReduxActions: () => {
conversation.setMarkedUnread(false); conversation.setMarkedUnread(false);
resetLinkPreview(); resetLinkPreview();
clearConversationDraftAttachments(conversationId, draftAttachments); void clearConversationDraftAttachments(
conversationId,
draftAttachments
);
setQuoteByMessageId(conversationId, undefined)( setQuoteByMessageId(conversationId, undefined)(
dispatch, dispatch,
getState, getState,
@ -447,7 +450,7 @@ function sendStickerMessage(
} }
const { packId, stickerId } = options; const { packId, stickerId } = options;
conversation.sendStickerMessage(packId, stickerId); void conversation.sendStickerMessage(packId, stickerId);
} catch (error) { } catch (error) {
log.error('clickSend error:', Errors.toLogFormat(error)); log.error('clickSend error:', Errors.toLogFormat(error));
} }

View file

@ -19,6 +19,7 @@ import * as log from '../../logging/log';
import { calling } from '../../services/calling'; import { calling } from '../../services/calling';
import { getOwn } from '../../util/getOwn'; import { getOwn } from '../../util/getOwn';
import { assertDev, strictAssert } from '../../util/assert'; import { assertDev, strictAssert } from '../../util/assert';
import { drop } from '../../util/drop';
import type { DurationInSeconds } from '../../util/durations'; import type { DurationInSeconds } from '../../util/durations';
import * as universalExpireTimer from '../../util/universalExpireTimer'; import * as universalExpireTimer from '../../util/universalExpireTimer';
import * as Attachment from '../../types/Attachment'; import * as Attachment from '../../types/Attachment';
@ -1086,7 +1087,7 @@ function blockGroupLinkRequests(
throw new Error('blockGroupLinkRequests: Conversation not found!'); throw new Error('blockGroupLinkRequests: Conversation not found!');
} }
conversation.blockGroupLinkRequests(uuid); void conversation.blockGroupLinkRequests(uuid);
return { return {
type: 'NOOP', type: 'NOOP',
@ -1102,7 +1103,7 @@ function loadNewerMessages(
throw new Error('loadNewerMessages: Conversation not found!'); throw new Error('loadNewerMessages: Conversation not found!');
} }
conversation.loadNewerMessages(newestMessageId); void conversation.loadNewerMessages(newestMessageId);
return { return {
type: 'NOOP', type: 'NOOP',
@ -1119,7 +1120,7 @@ function loadNewestMessages(
throw new Error('loadNewestMessages: Conversation not found!'); throw new Error('loadNewestMessages: Conversation not found!');
} }
conversation.loadNewestMessages(newestMessageId, setFocus); void conversation.loadNewestMessages(newestMessageId, setFocus);
return { return {
type: 'NOOP', type: 'NOOP',
@ -1135,7 +1136,7 @@ function loadOlderMessages(
throw new Error('loadOlderMessages: Conversation not found!'); throw new Error('loadOlderMessages: Conversation not found!');
} }
conversation.loadOlderMessages(oldestMessageId); void conversation.loadOlderMessages(oldestMessageId);
return { return {
type: 'NOOP', type: 'NOOP',
payload: null, payload: null,
@ -1181,7 +1182,7 @@ function removeMember(
throw new Error('removeMember: Conversation not found!'); throw new Error('removeMember: Conversation not found!');
} }
longRunningTaskWrapper({ void longRunningTaskWrapper({
idForLogging: conversation.idForLogging(), idForLogging: conversation.idForLogging(),
name: 'removeMember', name: 'removeMember',
task: () => conversation.removeFromGroupV2(memberConversationId), task: () => conversation.removeFromGroupV2(memberConversationId),
@ -1211,7 +1212,7 @@ function updateSharedGroups(conversationId: string): NoopActionType {
throw new Error('updateSharedGroups: Conversation not found!'); throw new Error('updateSharedGroups: Conversation not found!');
} }
conversation.throttledUpdateSharedGroups?.(); void conversation.throttledUpdateSharedGroups?.();
return { return {
type: 'NOOP', type: 'NOOP',
@ -1508,7 +1509,7 @@ function deleteMessage({
); );
} }
window.Signal.Data.removeMessage(messageId); void window.Signal.Data.removeMessage(messageId);
if (isOutgoing(message.attributes)) { if (isOutgoing(message.attributes)) {
conversation.decrementSentMessageCount(); conversation.decrementSentMessageCount();
} else { } else {
@ -1538,7 +1539,7 @@ function destroyMessages(
task: async () => { task: async () => {
conversation.trigger('unload', 'delete messages'); conversation.trigger('unload', 'delete messages');
await conversation.destroyMessages(); await conversation.destroyMessages();
conversation.updateLastMessage(); void conversation.updateLastMessage();
}, },
}); });
@ -1596,6 +1597,7 @@ export const markViewed = (messageId: string): void => {
message.set(messageUpdaterMarkViewed(message.attributes, Date.now())); message.set(messageUpdaterMarkViewed(message.attributes, Date.now()));
if (isIncoming(message.attributes)) { if (isIncoming(message.attributes)) {
drop(
viewedReceiptsJobQueue.add({ viewedReceiptsJobQueue.add({
viewedReceipt: { viewedReceipt: {
messageId, messageId,
@ -1606,9 +1608,11 @@ export const markViewed = (messageId: string): void => {
message.getConversation()?.attributes message.getConversation()?.attributes
), ),
}, },
}); })
);
} }
drop(
viewSyncJobQueue.add({ viewSyncJobQueue.add({
viewSyncs: [ viewSyncs: [
{ {
@ -1618,7 +1622,8 @@ export const markViewed = (messageId: string): void => {
timestamp, timestamp,
}, },
], ],
}); })
);
}; };
function setAccessControlAddFromInviteLinkSetting( function setAccessControlAddFromInviteLinkSetting(
@ -2317,7 +2322,7 @@ function getProfilesForConversation(conversationId: string): NoopActionType {
throw new Error('getProfilesForConversation: no conversation found'); throw new Error('getProfilesForConversation: no conversation found');
} }
conversation.getProfiles(); void conversation.getProfiles();
return { return {
type: 'NOOP', type: 'NOOP',
@ -2341,7 +2346,7 @@ function conversationStoppedByMissingVerification(payload: {
} }
// Intentionally not awaiting here // Intentionally not awaiting here
conversation.getProfiles(); void conversation.getProfiles();
}); });
return { return {
@ -2784,7 +2789,7 @@ function blockAndReportSpam(
const messageRequestEnum = Proto.SyncMessage.MessageRequestResponse.Type; const messageRequestEnum = Proto.SyncMessage.MessageRequestResponse.Type;
const idForLogging = conversation.idForLogging(); const idForLogging = conversation.idForLogging();
longRunningTaskWrapper({ void longRunningTaskWrapper({
name: 'blockAndReportSpam', name: 'blockAndReportSpam',
idForLogging, idForLogging,
task: async () => { task: async () => {
@ -2819,7 +2824,7 @@ function acceptConversation(conversationId: string): NoopActionType {
const messageRequestEnum = Proto.SyncMessage.MessageRequestResponse.Type; const messageRequestEnum = Proto.SyncMessage.MessageRequestResponse.Type;
longRunningTaskWrapper({ void longRunningTaskWrapper({
name: 'acceptConversation', name: 'acceptConversation',
idForLogging: conversation.idForLogging(), idForLogging: conversation.idForLogging(),
task: conversation.syncMessageRequestResponse.bind( task: conversation.syncMessageRequestResponse.bind(
@ -2844,7 +2849,7 @@ function blockConversation(conversationId: string): NoopActionType {
const messageRequestEnum = Proto.SyncMessage.MessageRequestResponse.Type; const messageRequestEnum = Proto.SyncMessage.MessageRequestResponse.Type;
longRunningTaskWrapper({ void longRunningTaskWrapper({
name: 'blockConversation', name: 'blockConversation',
idForLogging: conversation.idForLogging(), idForLogging: conversation.idForLogging(),
task: conversation.syncMessageRequestResponse.bind( task: conversation.syncMessageRequestResponse.bind(
@ -2869,7 +2874,7 @@ function deleteConversation(conversationId: string): NoopActionType {
const messageRequestEnum = Proto.SyncMessage.MessageRequestResponse.Type; const messageRequestEnum = Proto.SyncMessage.MessageRequestResponse.Type;
longRunningTaskWrapper({ void longRunningTaskWrapper({
name: 'deleteConversation', name: 'deleteConversation',
idForLogging: conversation.idForLogging(), idForLogging: conversation.idForLogging(),
task: conversation.syncMessageRequestResponse.bind( task: conversation.syncMessageRequestResponse.bind(
@ -2892,7 +2897,7 @@ function initiateMigrationToGroupV2(conversationId: string): NoopActionType {
); );
} }
longRunningTaskWrapper({ void longRunningTaskWrapper({
idForLogging: conversation.idForLogging(), idForLogging: conversation.idForLogging(),
name: 'initiateMigrationToGroupV2', name: 'initiateMigrationToGroupV2',
task: () => doInitiateMigrationToGroupV2(conversation), task: () => doInitiateMigrationToGroupV2(conversation),
@ -3121,7 +3126,7 @@ export function scrollToMessage(
return; return;
} }
conversation.loadAndScroll(messageId); void conversation.loadAndScroll(messageId);
}; };
} }
@ -3221,7 +3226,7 @@ function removeMemberFromGroup(
const conversationModel = window.ConversationController.get(conversationId); const conversationModel = window.ConversationController.get(conversationId);
if (conversationModel) { if (conversationModel) {
const idForLogging = conversationModel.idForLogging(); const idForLogging = conversationModel.idForLogging();
longRunningTaskWrapper({ void longRunningTaskWrapper({
name: 'removeMemberFromGroup', name: 'removeMemberFromGroup',
idForLogging, idForLogging,
task: () => conversationModel.removeFromGroupV2(contactId), task: () => conversationModel.removeFromGroupV2(contactId),
@ -3372,7 +3377,7 @@ function toggleAdmin(
return dispatch => { return dispatch => {
const conversationModel = window.ConversationController.get(conversationId); const conversationModel = window.ConversationController.get(conversationId);
if (conversationModel) { if (conversationModel) {
conversationModel.toggleAdmin(contactId); void conversationModel.toggleAdmin(contactId);
} }
dispatch({ dispatch({
type: 'NOOP', type: 'NOOP',
@ -3387,7 +3392,7 @@ function updateConversationModelSharedGroups(
return dispatch => { return dispatch => {
const conversation = window.ConversationController.get(conversationId); const conversation = window.ConversationController.get(conversationId);
if (conversation && conversation.throttledUpdateSharedGroups) { if (conversation && conversation.throttledUpdateSharedGroups) {
conversation.throttledUpdateSharedGroups(); void conversation.throttledUpdateSharedGroups();
} }
dispatch({ dispatch({
type: 'NOOP', type: 'NOOP',
@ -3457,7 +3462,7 @@ function showArchivedConversations(): ShowArchivedConversationsActionType {
function doubleCheckMissingQuoteReference(messageId: string): NoopActionType { function doubleCheckMissingQuoteReference(messageId: string): NoopActionType {
const message = window.MessageController.getById(messageId); const message = window.MessageController.getById(messageId);
if (message) { if (message) {
message.doubleCheckMissingQuoteReference(); void message.doubleCheckMissingQuoteReference();
} }
return { return {

View file

@ -443,11 +443,10 @@ function closeStickerPackPreview(): ThunkAction<
return async (dispatch, getState) => { return async (dispatch, getState) => {
const packId = getState().globalModals.stickerPackPreviewId; const packId = getState().globalModals.stickerPackPreviewId;
if (!packId) { if (packId && Stickers.getStickerPack(packId) !== undefined) {
return; await Stickers.removeEphemeralPack(packId);
} }
await Stickers.removeEphemeralPack(packId);
dispatch({ dispatch({
type: CLOSE_STICKER_PACK_PREVIEW, type: CLOSE_STICKER_PACK_PREVIEW,
}); });
@ -460,7 +459,7 @@ export function showStickerPackPreview(
): ShowStickerPackPreviewActionType { ): ShowStickerPackPreviewActionType {
// Intentionally not awaiting this so that we can show the modal right away. // Intentionally not awaiting this so that we can show the modal right away.
// The modal has a loading spinner on it. // The modal has a loading spinner on it.
Stickers.downloadEphemeralPack(packId, packKey); void Stickers.downloadEphemeralPack(packId, packKey);
return { return {
type: SHOW_STICKER_PACK_PREVIEW, type: SHOW_STICKER_PACK_PREVIEW,

View file

@ -8,6 +8,7 @@ import type { StateType as RootStateType } from '../reducer';
import * as storageShim from '../../shims/storage'; import * as storageShim from '../../shims/storage';
import type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions'; import type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions';
import { useBoundActions } from '../../hooks/useBoundActions'; import { useBoundActions } from '../../hooks/useBoundActions';
import { drop } from '../../util/drop';
import type { import type {
ConversationColorType, ConversationColorType,
CustomColorType, CustomColorType,
@ -100,16 +101,19 @@ export const useActions = (): BoundActionCreatorsMapObject<typeof actions> =>
function putItem<K extends keyof StorageAccessType>( function putItem<K extends keyof StorageAccessType>(
key: K, key: K,
value: StorageAccessType[K] value: StorageAccessType[K]
): ItemPutAction { ): ThunkAction<void, RootStateType, unknown, ItemPutAction> {
storageShim.put(key, value); return async dispatch => {
dispatch({
return {
type: 'items/PUT', type: 'items/PUT',
payload: null, payload: null,
});
await storageShim.put(key, value);
}; };
} }
function onSetSkinTone(tone: number): ItemPutAction { function onSetSkinTone(
tone: number
): ThunkAction<void, RootStateType, unknown, ItemPutAction> {
return putItem('skinTone', tone); return putItem('skinTone', tone);
} }
@ -124,7 +128,7 @@ function putItemExternal(key: string, value: unknown): ItemPutExternalAction {
} }
function removeItem(key: keyof StorageAccessType): ItemRemoveAction { function removeItem(key: keyof StorageAccessType): ItemRemoveAction {
storageShim.remove(key); drop(storageShim.remove(key));
return { return {
type: 'items/REMOVE', type: 'items/REMOVE',

View file

@ -77,7 +77,7 @@ function closeLightbox(): ThunkAction<
if (!item.attachment.path) { if (!item.attachment.path) {
return; return;
} }
window.Signal.Migrations.deleteTempFile(item.attachment.path); void window.Signal.Migrations.deleteTempFile(item.attachment.path);
}); });
} }

View file

@ -209,7 +209,7 @@ const doSearch = debounce(
return; return;
} }
(async () => { void (async () => {
dispatch({ dispatch({
type: 'SEARCH_MESSAGES_RESULTS_FULFILLED', type: 'SEARCH_MESSAGES_RESULTS_FULFILLED',
payload: { payload: {
@ -220,7 +220,7 @@ const doSearch = debounce(
})(); })();
if (!searchConversationId) { if (!searchConversationId) {
(async () => { void (async () => {
const { conversationIds, contactIds } = const { conversationIds, contactIds } =
await queryConversationsAndContacts(query, { await queryConversationsAndContacts(query, {
ourConversationId, ourConversationId,

View file

@ -193,7 +193,7 @@ function downloadStickerPack(
const { finalStatus } = options || { finalStatus: undefined }; const { finalStatus } = options || { finalStatus: undefined };
// We're just kicking this off, since it will generate more redux events // We're just kicking this off, since it will generate more redux events
externalDownloadStickerPack(packId, packKey, { finalStatus }); void externalDownloadStickerPack(packId, packKey, { finalStatus });
return { return {
type: 'NOOP', type: 'NOOP',
@ -223,7 +223,7 @@ async function doInstallStickerPack(
if (!fromSync && !fromStorageService) { if (!fromSync && !fromStorageService) {
// Kick this off, but don't wait for it // Kick this off, but don't wait for it
sendStickerPackSync(packId, packKey, true); void sendStickerPackSync(packId, packKey, true);
} }
if (!fromStorageService) { if (!fromStorageService) {
@ -268,7 +268,7 @@ async function doUninstallStickerPack(
if (!fromSync && !fromStorageService) { if (!fromSync && !fromStorageService) {
// Kick this off, but don't wait for it // Kick this off, but don't wait for it
sendStickerPackSync(packId, packKey, false); void sendStickerPackSync(packId, packKey, false);
} }
if (!fromStorageService) { if (!fromStorageService) {

View file

@ -25,6 +25,7 @@ import { ReadStatus } from '../../messages/MessageReadStatus';
import { SafetyNumberChangeSource } from '../../components/SafetyNumberChangeDialog'; import { SafetyNumberChangeSource } from '../../components/SafetyNumberChangeDialog';
import { StoryViewDirectionType, StoryViewModeType } from '../../types/Stories'; import { StoryViewDirectionType, StoryViewModeType } from '../../types/Stories';
import { assertDev } from '../../util/assert'; import { assertDev } from '../../util/assert';
import { drop } from '../../util/drop';
import { blockSendUntilConversationsAreVerified } from '../../util/blockSendUntilConversationsAreVerified'; import { blockSendUntilConversationsAreVerified } from '../../util/blockSendUntilConversationsAreVerified';
import { deleteStoryForEveryone as doDeleteStoryForEveryone } from '../../util/deleteStoryForEveryone'; import { deleteStoryForEveryone as doDeleteStoryForEveryone } from '../../util/deleteStoryForEveryone';
import { deleteGroupStoryReplyForEveryone as doDeleteGroupStoryReplyForEveryone } from '../../util/deleteGroupStoryReplyForEveryone'; import { deleteGroupStoryReplyForEveryone as doDeleteGroupStoryReplyForEveryone } from '../../util/deleteGroupStoryReplyForEveryone';
@ -374,14 +375,14 @@ function markStoryRead(
const isSignalOnboardingStory = message.get('sourceUuid') === SIGNAL_ACI; const isSignalOnboardingStory = message.get('sourceUuid') === SIGNAL_ACI;
if (isSignalOnboardingStory) { if (isSignalOnboardingStory) {
markOnboardingStoryAsRead(); void markOnboardingStoryAsRead();
return; return;
} }
const storyReadDate = Date.now(); const storyReadDate = Date.now();
message.set(markViewed(message.attributes, storyReadDate)); message.set(markViewed(message.attributes, storyReadDate));
window.Signal.Data.saveMessage(message.attributes, { void window.Signal.Data.saveMessage(message.attributes, {
ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(), ourUuid: window.textsecure.storage.user.getCheckedUuid().toString(),
}); });
@ -395,11 +396,11 @@ function markStoryRead(
const viewSyncs: Array<SyncType> = [viewedReceipt]; const viewSyncs: Array<SyncType> = [viewedReceipt];
if (!window.ConversationController.areWePrimaryDevice()) { if (!window.ConversationController.areWePrimaryDevice()) {
viewSyncJobQueue.add({ viewSyncs }); drop(viewSyncJobQueue.add({ viewSyncs }));
} }
if (window.Events.getStoryViewReceiptsEnabled()) { if (window.Events.getStoryViewReceiptsEnabled()) {
viewedReceiptsJobQueue.add({ viewedReceipt }); drop(viewedReceiptsJobQueue.add({ viewedReceipt }));
} }
await dataInterface.addNewStoryRead({ await dataInterface.addNewStoryRead({

View file

@ -291,7 +291,7 @@ function hideMyStoriesFrom(
storageServiceUploadJob(); storageServiceUploadJob();
window.storage.put('hasSetMyStoriesPrivacy', true); await window.storage.put('hasSetMyStoriesPrivacy', true);
dispatch({ dispatch({
type: HIDE_MY_STORIES_FROM, type: HIDE_MY_STORIES_FROM,
@ -338,7 +338,7 @@ function removeMembersFromDistributionList(
toRemove = []; toRemove = [];
// The user has now configured My Stories // The user has now configured My Stories
window.storage.put('hasSetMyStoriesPrivacy', true); await window.storage.put('hasSetMyStoriesPrivacy', true);
} }
await dataInterface.modifyStoryDistributionWithMembers( await dataInterface.modifyStoryDistributionWithMembers(
@ -410,7 +410,7 @@ function setMyStoriesToAllSignalConnections(): ThunkAction<
storageServiceUploadJob(); storageServiceUploadJob();
} }
window.storage.put('hasSetMyStoriesPrivacy', true); await window.storage.put('hasSetMyStoriesPrivacy', true);
dispatch({ dispatch({
type: RESET_MY_STORIES, type: RESET_MY_STORIES,
@ -467,7 +467,7 @@ function updateStoryViewers(
storageServiceUploadJob(); storageServiceUploadJob();
if (listId === MY_STORY_ID) { if (listId === MY_STORY_ID) {
window.storage.put('hasSetMyStoriesPrivacy', true); await window.storage.put('hasSetMyStoriesPrivacy', true);
} }
dispatch({ dispatch({

View file

@ -91,10 +91,10 @@ const mapStateToProps = (state: StateType) => {
theme: getTheme(state), theme: getTheme(state),
executeMenuRole: (role: MenuItemConstructorOptions['role']): void => { executeMenuRole: (role: MenuItemConstructorOptions['role']): void => {
window.SignalContext.executeMenuRole(role); void window.SignalContext.executeMenuRole(role);
}, },
executeMenuAction: (action: MenuActionType): void => { executeMenuAction: (action: MenuActionType): void => {
window.SignalContext.executeMenuAction(action); void window.SignalContext.executeMenuAction(action);
}, },
titleBarDoubleClick: (): void => { titleBarDoubleClick: (): void => {
window.titleBarDoubleClick(); window.titleBarDoubleClick();

View file

@ -196,7 +196,7 @@ export function SmartInstallScreen(): ReactElement {
return result; return result;
}; };
(async () => { void (async () => {
try { try {
await accountManager.registerSecondDevice( await accountManager.registerSecondDevice(
updateProvisioningUrl, updateProvisioningUrl,

View file

@ -17,8 +17,8 @@ describe('RetryPlaceholders', () => {
const NOW = 1_000_000; const NOW = 1_000_000;
let clock: any; let clock: any;
beforeEach(() => { beforeEach(async () => {
window.storage.put(STORAGE_KEY, undefined as any); await window.storage.put(STORAGE_KEY, undefined as any);
clock = sinon.useFakeTimers({ clock = sinon.useFakeTimers({
now: NOW, now: NOW,
@ -40,19 +40,19 @@ describe('RetryPlaceholders', () => {
} }
describe('constructor', () => { describe('constructor', () => {
it('loads previously-saved data on creation', () => { it('loads previously-saved data on creation', async () => {
const items: Array<RetryItemType> = [ const items: Array<RetryItemType> = [
getDefaultItem(), getDefaultItem(),
{ ...getDefaultItem(), conversationId: 'conversation-id-2' }, { ...getDefaultItem(), conversationId: 'conversation-id-2' },
]; ];
window.storage.put(STORAGE_KEY, items); await window.storage.put(STORAGE_KEY, items);
const placeholders = new RetryPlaceholders(); const placeholders = new RetryPlaceholders();
assert.strictEqual(2, placeholders.getCount()); assert.strictEqual(2, placeholders.getCount());
}); });
it('starts with no data if provided data fails to parse', () => { it('starts with no data if provided data fails to parse', async () => {
window.storage.put(STORAGE_KEY, [ await window.storage.put(STORAGE_KEY, [
{ item: 'is wrong shape!' }, { item: 'is wrong shape!' },
{ bad: 'is not good!' }, { bad: 'is not good!' },
] as any); ] as any);
@ -70,9 +70,9 @@ describe('RetryPlaceholders', () => {
assert.strictEqual(1, placeholders.getCount()); assert.strictEqual(1, placeholders.getCount());
}); });
it('throws if provided data fails to parse', () => { it('throws if provided data fails to parse', async () => {
const placeholders = new RetryPlaceholders(); const placeholders = new RetryPlaceholders();
assert.isRejected( await assert.isRejected(
placeholders.add({ placeholders.add({
item: 'is wrong shape!', item: 'is wrong shape!',
} as any), } as any),
@ -87,10 +87,10 @@ describe('RetryPlaceholders', () => {
assert.strictEqual(0, placeholders.getCount()); assert.strictEqual(0, placeholders.getCount());
assert.isUndefined(placeholders.getNextToExpire()); assert.isUndefined(placeholders.getNextToExpire());
}); });
it('returns only item if just one item', () => { it('returns only item if just one item', async () => {
const item = getDefaultItem(); const item = getDefaultItem();
const items: Array<RetryItemType> = [item]; const items: Array<RetryItemType> = [item];
window.storage.put(STORAGE_KEY, items); await window.storage.put(STORAGE_KEY, items);
const placeholders = new RetryPlaceholders(); const placeholders = new RetryPlaceholders();
assert.strictEqual(1, placeholders.getCount()); assert.strictEqual(1, placeholders.getCount());
@ -106,7 +106,7 @@ describe('RetryPlaceholders', () => {
receivedAt: NOW + 10, receivedAt: NOW + 10,
}; };
const items: Array<RetryItemType> = [older, newer]; const items: Array<RetryItemType> = [older, newer];
window.storage.put(STORAGE_KEY, items); await window.storage.put(STORAGE_KEY, items);
const placeholders = new RetryPlaceholders(); const placeholders = new RetryPlaceholders();
assert.strictEqual(2, placeholders.getCount()); assert.strictEqual(2, placeholders.getCount());
@ -134,7 +134,7 @@ describe('RetryPlaceholders', () => {
receivedAt: NOW + 15, receivedAt: NOW + 15,
}; };
const items: Array<RetryItemType> = [older, newer]; const items: Array<RetryItemType> = [older, newer];
window.storage.put(STORAGE_KEY, items); await window.storage.put(STORAGE_KEY, items);
const placeholders = new RetryPlaceholders(); const placeholders = new RetryPlaceholders();
assert.strictEqual(2, placeholders.getCount()); assert.strictEqual(2, placeholders.getCount());
@ -151,7 +151,7 @@ describe('RetryPlaceholders', () => {
receivedAt: NOW + 15, receivedAt: NOW + 15,
}; };
const items: Array<RetryItemType> = [older, newer]; const items: Array<RetryItemType> = [older, newer];
window.storage.put(STORAGE_KEY, items); await window.storage.put(STORAGE_KEY, items);
const placeholders = new RetryPlaceholders(); const placeholders = new RetryPlaceholders();
assert.strictEqual(2, placeholders.getCount()); assert.strictEqual(2, placeholders.getCount());
@ -169,7 +169,7 @@ describe('RetryPlaceholders', () => {
receivedAt: getDeltaIntoPast() - 900, receivedAt: getDeltaIntoPast() - 900,
}; };
const items: Array<RetryItemType> = [older, newer]; const items: Array<RetryItemType> = [older, newer];
window.storage.put(STORAGE_KEY, items); await window.storage.put(STORAGE_KEY, items);
const placeholders = new RetryPlaceholders(); const placeholders = new RetryPlaceholders();
assert.strictEqual(2, placeholders.getCount()); assert.strictEqual(2, placeholders.getCount());
@ -192,7 +192,7 @@ describe('RetryPlaceholders', () => {
conversationId: 'conversation-id-2', conversationId: 'conversation-id-2',
}; };
const items: Array<RetryItemType> = [older, newer]; const items: Array<RetryItemType> = [older, newer];
window.storage.put(STORAGE_KEY, items); await window.storage.put(STORAGE_KEY, items);
const placeholders = new RetryPlaceholders(); const placeholders = new RetryPlaceholders();
assert.strictEqual(2, placeholders.getCount()); assert.strictEqual(2, placeholders.getCount());
@ -219,7 +219,7 @@ describe('RetryPlaceholders', () => {
receivedAt: NOW + 15, receivedAt: NOW + 15,
}; };
const items: Array<RetryItemType> = [convo1a, convo1b, convo2a]; const items: Array<RetryItemType> = [convo1a, convo1b, convo2a];
window.storage.put(STORAGE_KEY, items); await window.storage.put(STORAGE_KEY, items);
const placeholders = new RetryPlaceholders(); const placeholders = new RetryPlaceholders();
assert.strictEqual(3, placeholders.getCount()); assert.strictEqual(3, placeholders.getCount());
@ -293,7 +293,7 @@ describe('RetryPlaceholders', () => {
sentAt: NOW - 11, sentAt: NOW - 11,
}; };
const items: Array<RetryItemType> = [older, newer]; const items: Array<RetryItemType> = [older, newer];
window.storage.put(STORAGE_KEY, items); await window.storage.put(STORAGE_KEY, items);
const placeholders = new RetryPlaceholders(); const placeholders = new RetryPlaceholders();
assert.strictEqual(2, placeholders.getCount()); assert.strictEqual(2, placeholders.getCount());
@ -316,7 +316,7 @@ describe('RetryPlaceholders', () => {
sentAt, sentAt,
}; };
const items: Array<RetryItemType> = [older, newer]; const items: Array<RetryItemType> = [older, newer];
window.storage.put(STORAGE_KEY, items); await window.storage.put(STORAGE_KEY, items);
const placeholders = new RetryPlaceholders(); const placeholders = new RetryPlaceholders();
assert.strictEqual(2, placeholders.getCount()); assert.strictEqual(2, placeholders.getCount());

View file

@ -124,7 +124,7 @@ describe('SignalProtocolStore', () => {
before(async () => { before(async () => {
store = window.textsecure.storage.protocol; store = window.textsecure.storage.protocol;
store.hydrateCaches(); await store.hydrateCaches();
identityKey = { identityKey = {
pubKey: getPublicKey(), pubKey: getPublicKey(),
privKey: getPrivateKey(), privKey: getPrivateKey(),
@ -140,8 +140,10 @@ describe('SignalProtocolStore', () => {
clampPrivateKey(identityKey.privKey); clampPrivateKey(identityKey.privKey);
clampPrivateKey(testKey.privKey); clampPrivateKey(testKey.privKey);
window.storage.put('registrationIdMap', { [ourUuid.toString()]: 1337 }); await window.storage.put('registrationIdMap', {
window.storage.put('identityKeyMap', { [ourUuid.toString()]: 1337,
});
await window.storage.put('identityKeyMap', {
[ourUuid.toString()]: { [ourUuid.toString()]: {
privKey: identityKey.privKey, privKey: identityKey.privKey,
pubKey: identityKey.pubKey, pubKey: identityKey.pubKey,

View file

@ -21,34 +21,34 @@ describe('#isOverHourIntoPast', () => {
}); });
describe('#cleanupSessionResets', () => { describe('#cleanupSessionResets', () => {
it('leaves empty object alone', () => { it('leaves empty object alone', async () => {
window.storage.put('sessionResets', {}); await window.storage.put('sessionResets', {});
cleanupSessionResets(); await cleanupSessionResets();
const actual = window.storage.get('sessionResets'); const actual = window.storage.get('sessionResets');
const expected = {}; const expected = {};
assert.deepEqual(actual, expected); assert.deepEqual(actual, expected);
}); });
it('filters out any timestamp older than one hour', () => { it('filters out any timestamp older than one hour', async () => {
const startValue = { const startValue = {
one: Date.now() - 1, one: Date.now() - 1,
two: Date.now(), two: Date.now(),
three: Date.now() - 65 * 60 * 1000, three: Date.now() - 65 * 60 * 1000,
}; };
window.storage.put('sessionResets', startValue); await window.storage.put('sessionResets', startValue);
cleanupSessionResets(); await cleanupSessionResets();
const actual = window.storage.get('sessionResets'); const actual = window.storage.get('sessionResets');
const expected = pick(startValue, ['one', 'two']); const expected = pick(startValue, ['one', 'two']);
assert.deepEqual(actual, expected); assert.deepEqual(actual, expected);
}); });
it('filters out falsey items', () => { it('filters out falsey items', async () => {
const startValue = { const startValue = {
one: 0, one: 0,
two: Date.now(), two: Date.now(),
}; };
window.storage.put('sessionResets', startValue); await window.storage.put('sessionResets', startValue);
cleanupSessionResets(); await cleanupSessionResets();
const actual = window.storage.get('sessionResets'); const actual = window.storage.get('sessionResets');
const expected = pick(startValue, ['two']); const expected = pick(startValue, ['two']);

View file

@ -51,21 +51,22 @@ describe('Message', () => {
STORAGE_KEYS_TO_RESTORE.forEach(key => { STORAGE_KEYS_TO_RESTORE.forEach(key => {
oldStorageValues.set(key, window.textsecure.storage.get(key)); oldStorageValues.set(key, window.textsecure.storage.get(key));
}); });
window.textsecure.storage.put('number_id', `${me}.2`); await window.textsecure.storage.put('number_id', `${me}.2`);
window.textsecure.storage.put('uuid_id', `${ourUuid}.2`); await window.textsecure.storage.put('uuid_id', `${ourUuid}.2`);
}); });
after(async () => { after(async () => {
await window.Signal.Data.removeAll(); await window.Signal.Data.removeAll();
await window.storage.fetch(); await window.storage.fetch();
oldStorageValues.forEach((oldValue, key) => { await Promise.all(
Array.from(oldStorageValues.entries()).map(([key, oldValue]) => {
if (oldValue) { if (oldValue) {
window.textsecure.storage.put(key, oldValue); return window.textsecure.storage.put(key, oldValue);
} else {
window.textsecure.storage.remove(key);
} }
}); return window.textsecure.storage.remove(key);
})
);
}); });
beforeEach(function beforeEach() { beforeEach(function beforeEach() {

View file

@ -4,6 +4,7 @@
import { assert } from 'chai'; import { assert } from 'chai';
import { sleep } from '../../util'; import { sleep } from '../../util';
import { MINUTE } from '../../util/durations'; import { MINUTE } from '../../util/durations';
import { drop } from '../../util/drop';
import { ProfileService } from '../../services/profiles'; import { ProfileService } from '../../services/profiles';
import { UUID } from '../../types/UUID'; import { UUID } from '../../types/UUID';
@ -55,9 +56,9 @@ describe('util/profiles', () => {
const service = new ProfileService(getProfileWithIncrement); const service = new ProfileService(getProfileWithIncrement);
// Queued and immediately started due to concurrency = 3 // Queued and immediately started due to concurrency = 3
service.get(UUID_1); drop(service.get(UUID_1));
service.get(UUID_2); drop(service.get(UUID_2));
service.get(UUID_3); drop(service.get(UUID_3));
// Queued but only run after paused queue restarts // Queued but only run after paused queue restarts
const lastPromise = service.get(UUID_4); const lastPromise = service.get(UUID_4);

View file

@ -9,6 +9,7 @@ import * as sinon from 'sinon';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
import Long from 'long'; import Long from 'long';
import * as durations from '../../util/durations'; import * as durations from '../../util/durations';
import { drop } from '../../util/drop';
import * as Bytes from '../../Bytes'; import * as Bytes from '../../Bytes';
import { SenderCertificateMode } from '../../textsecure/OutgoingMessage'; import { SenderCertificateMode } from '../../textsecure/OutgoingMessage';
import { SignalService as Proto } from '../../protobuf'; import { SignalService as Proto } from '../../protobuf';
@ -232,8 +233,8 @@ describe('SenderCertificateService', () => {
const service = initializeTestService(); const service = initializeTestService();
service.get(SenderCertificateMode.WithE164); drop(service.get(SenderCertificateMode.WithE164));
service.get(SenderCertificateMode.WithoutE164); drop(service.get(SenderCertificateMode.WithoutE164));
await service.clear(); await service.clear();

View file

@ -2172,7 +2172,7 @@ describe('both/state/ducks/conversations', () => {
assert.isUndefined( assert.isUndefined(
nextState.conversationsByGroupId.jkl.conversationColor nextState.conversationsByGroupId.jkl.conversationColor
); );
window.storage.remove('defaultConversationColor'); await window.storage.remove('defaultConversationColor');
}); });
}); });

View file

@ -7,6 +7,7 @@ import { v4 as getGuid } from 'uuid';
import { getRandomBytes } from '../../Crypto'; import { getRandomBytes } from '../../Crypto';
import { Address } from '../../types/Address'; import { Address } from '../../types/Address';
import { UUID } from '../../types/UUID'; import { UUID } from '../../types/UUID';
import { explodePromise } from '../../util/explodePromise';
import { SignalProtocolStore } from '../../SignalProtocolStore'; import { SignalProtocolStore } from '../../SignalProtocolStore';
import type { ConversationModel } from '../../models/conversations'; import type { ConversationModel } from '../../models/conversations';
import * as KeyChangeListener from '../../textsecure/KeyChangeListener'; import * as KeyChangeListener from '../../textsecure/KeyChangeListener';
@ -76,13 +77,15 @@ describe('KeyChangeListener', () => {
}); });
describe('When we have a conversation with this contact', () => { describe('When we have a conversation with this contact', () => {
it('generates a key change notice in the private conversation with this contact', done => { it('generates a key change notice in the private conversation with this contact', async () => {
const original = convo.addKeyChange; const original = convo.addKeyChange;
const { resolve, promise } = explodePromise<void>();
convo.addKeyChange = async () => { convo.addKeyChange = async () => {
convo.addKeyChange = original; convo.addKeyChange = original;
done(); resolve();
}; };
store.saveIdentity(address, newKey); await store.saveIdentity(address, newKey);
return promise;
}); });
}); });
@ -108,15 +111,18 @@ describe('KeyChangeListener', () => {
await window.Signal.Data.removeConversation(groupConvo.id); await window.Signal.Data.removeConversation(groupConvo.id);
}); });
it('generates a key change notice in the group conversation with this contact', done => { it('generates a key change notice in the group conversation with this contact', async () => {
const original = groupConvo.addKeyChange; const original = groupConvo.addKeyChange;
const { resolve, promise } = explodePromise<void>();
groupConvo.addKeyChange = async (_, keyChangedId) => { groupConvo.addKeyChange = async (_, keyChangedId) => {
assert.equal(uuidWithKeyChange, keyChangedId?.toString()); assert.equal(uuidWithKeyChange, keyChangedId?.toString());
groupConvo.addKeyChange = original; groupConvo.addKeyChange = original;
done(); resolve();
}; };
store.saveIdentity(address, newKey); await store.saveIdentity(address, newKey);
return promise;
}); });
}); });
}); });

View file

@ -92,7 +92,7 @@ describe('waitForOnline', () => {
}); });
let done = false; let done = false;
(async () => { void (async () => {
await waitForOnline(fakeNavigator, fakeWindow, { timeout: 9999 }); await waitForOnline(fakeNavigator, fakeWindow, { timeout: 9999 });
done = true; done = true;
})(); })();

View file

@ -11,7 +11,7 @@ import { Bootstrap, debug, stats, RUN_COUNT, DISCARD_COUNT } from './fixtures';
const CONVERSATION_SIZE = 1000; // messages const CONVERSATION_SIZE = 1000; // messages
const DELAY = 50; // milliseconds const DELAY = 50; // milliseconds
(async () => { void (async () => {
const bootstrap = new Bootstrap({ const bootstrap = new Bootstrap({
benchmark: true, benchmark: true,
}); });

Some files were not shown because too many files have changed in this diff Show more