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-shadow': '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-useless-constructor': 'off',

View file

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

View file

@ -43,6 +43,7 @@ import { redactAll, addSensitivePath } from '../ts/util/privacy';
import { createSupportUrl } from '../ts/util/createSupportUrl';
import { missingCaseError } from '../ts/util/missingCaseError';
import { strictAssert } from '../ts/util/assert';
import { drop } from '../ts/util/drop';
import { consoleLogger } from '../ts/util/consoleLogger';
import type { ThemeSettingType } from '../ts/types/StorageUIKeys';
import { ThemeType } from '../ts/types/Util';
@ -483,10 +484,10 @@ function handleCommonWindowEvents(
window.webContents.on('will-navigate', (event, rawTarget) => {
event.preventDefault();
handleUrl(rawTarget);
drop(handleUrl(rawTarget));
});
window.webContents.setWindowOpenHandler(({ url }) => {
handleUrl(url);
drop(handleUrl(url));
return { action: 'deny' };
});
window.webContents.on(
@ -526,9 +527,11 @@ function handleCommonWindowEvents(
return;
}
settingsChannel?.invokeCallbackInMainWindow('persistZoomFactor', [
zoomFactor,
]);
drop(
settingsChannel?.invokeCallbackInMainWindow('persistZoomFactor', [
zoomFactor,
])
);
lastZoomFactor = zoomFactor;
};
@ -800,12 +803,6 @@ async function createWindow() {
mainWindow.on('resize', 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')) {
// Open the DevTools.
mainWindow.webContents.openDevTools();
@ -932,6 +929,16 @@ async function createWindow() {
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
@ -1056,12 +1063,14 @@ const TEN_MINUTES = 10 * 60 * 1000;
setTimeout(readyForUpdates, TEN_MINUTES);
function openContactUs() {
shell.openExternal(createSupportUrl({ locale: app.getLocale() }));
drop(shell.openExternal(createSupportUrl({ locale: app.getLocale() })));
}
function openJoinTheBeta() {
// 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() {
@ -1070,18 +1079,22 @@ function openReleaseNotes() {
return;
}
shell.openExternal(
`https://github.com/signalapp/Signal-Desktop/releases/tag/v${app.getVersion()}`
drop(
shell.openExternal(
`https://github.com/signalapp/Signal-Desktop/releases/tag/v${app.getVersion()}`
)
);
}
function openSupportPage() {
// 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() {
shell.openExternal('https://community.signalusers.org/');
drop(shell.openExternal('https://community.signalusers.org/'));
}
function showKeyboardShortcuts() {
@ -1143,10 +1156,6 @@ async function showScreenShareWindow(sourceName: string) {
handleCommonWindowEvents(screenShareWindow);
screenShareWindow.loadURL(
await prepareFileUrl([__dirname, '../screenShare.html'])
);
screenShareWindow.on('closed', () => {
screenShareWindow = undefined;
});
@ -1160,6 +1169,10 @@ async function showScreenShareWindow(sourceName: string) {
);
}
});
await screenShareWindow.loadURL(
await prepareFileUrl([__dirname, '../screenShare.html'])
);
}
let aboutWindow: BrowserWindow | undefined;
@ -1196,8 +1209,6 @@ async function showAbout() {
handleCommonWindowEvents(aboutWindow, titleBarOverlay);
aboutWindow.loadURL(await prepareFileUrl([__dirname, '../about.html']));
aboutWindow.on('closed', () => {
aboutWindow = undefined;
});
@ -1207,6 +1218,8 @@ async function showAbout() {
aboutWindow.show();
}
});
await aboutWindow.loadURL(await prepareFileUrl([__dirname, '../about.html']));
}
let settingsWindow: BrowserWindow | undefined;
@ -1244,8 +1257,6 @@ async function showSettingsWindow() {
handleCommonWindowEvents(settingsWindow, titleBarOverlay);
settingsWindow.loadURL(await prepareFileUrl([__dirname, '../settings.html']));
settingsWindow.on('closed', () => {
settingsWindow = undefined;
});
@ -1258,6 +1269,10 @@ async function showSettingsWindow() {
settingsWindow.show();
});
await settingsWindow.loadURL(
await prepareFileUrl([__dirname, '../settings.html'])
);
}
async function getIsLinked() {
@ -1275,7 +1290,7 @@ async function showStickerCreator() {
if (!(await getIsLinked())) {
const message = getLocale().i18n('StickerCreator--Authentication--error');
dialog.showMessageBox({
await dialog.showMessageBox({
type: 'warning',
message,
});
@ -1327,8 +1342,6 @@ async function showStickerCreator() {
)
: prepareFileUrl([__dirname, '../sticker-creator/dist/index.html']);
stickerCreatorWindow.loadURL(await appUrl);
stickerCreatorWindow.on('closed', () => {
stickerCreatorWindow = undefined;
});
@ -1345,6 +1358,8 @@ async function showStickerCreator() {
stickerCreatorWindow.webContents.openDevTools();
}
});
await stickerCreatorWindow.loadURL(await appUrl);
}
let debugLogWindow: BrowserWindow | undefined;
@ -1387,10 +1402,6 @@ async function showDebugLogWindow() {
handleCommonWindowEvents(debugLogWindow, titleBarOverlay);
debugLogWindow.loadURL(
await prepareFileUrl([__dirname, '../debug_log.html'])
);
debugLogWindow.on('closed', () => {
debugLogWindow = undefined;
});
@ -1403,6 +1414,10 @@ async function showDebugLogWindow() {
debugLogWindow.center();
}
});
await debugLogWindow.loadURL(
await prepareFileUrl([__dirname, '../debug_log.html'])
);
}
let permissionsPopupWindow: BrowserWindow | undefined;
@ -1446,13 +1461,6 @@ function showPermissionsPopupWindow(forCalling: boolean, forCamera: boolean) {
handleCommonWindowEvents(permissionsPopupWindow);
permissionsPopupWindow.loadURL(
await prepareFileUrl([__dirname, '../permissions_popup.html'], {
forCalling,
forCamera,
})
);
permissionsPopupWindow.on('closed', () => {
removeDarkOverlay();
permissionsPopupWindow = undefined;
@ -1466,6 +1474,13 @@ function showPermissionsPopupWindow(forCalling: boolean, forCamera: boolean) {
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
runSQLCorruptionHandler();
drop(runSQLCorruptionHandler());
return { ok: true, error: undefined };
}
@ -1539,7 +1554,7 @@ const onDatabaseError = async (error: string) => {
ready = false;
if (mainWindow) {
settingsChannel?.invokeCallbackInMainWindow('closeDB', []);
drop(settingsChannel?.invokeCallbackInMainWindow('closeDB', []));
mainWindow.close();
}
mainWindow = undefined;
@ -1577,7 +1592,7 @@ let sqlInitPromise:
| undefined;
ipc.on('database-error', (_event: Electron.Event, error: string) => {
onDatabaseError(error);
drop(onDatabaseError(error));
});
function getAppLocale(): string {
@ -1754,46 +1769,50 @@ app.on('ready', async () => {
// lookup should be done only in ephemeral config.
const backgroundColor = await getBackgroundColor({ ephemeralOnly: true });
// eslint-disable-next-line more/no-then
Promise.race([sqlInitPromise, timeout]).then(async maybeTimeout => {
if (maybeTimeout !== 'timeout') {
return;
}
getLogger().info(
'sql.initialize is taking more than three seconds; showing loading dialog'
);
loadingWindow = new BrowserWindow({
show: false,
width: 300,
height: 265,
resizable: false,
frame: false,
backgroundColor,
webPreferences: {
...defaultWebPrefs,
nodeIntegration: false,
sandbox: false,
contextIsolation: true,
preload: join(__dirname, '../ts/windows/loading/preload.js'),
},
icon: windowIcon,
});
loadingWindow.once('ready-to-show', async () => {
if (!loadingWindow) {
drop(
// eslint-disable-next-line more/no-then
Promise.race([sqlInitPromise, timeout]).then(async maybeTimeout => {
if (maybeTimeout !== 'timeout') {
return;
}
loadingWindow.show();
// Wait for sql initialization to complete, but ignore errors
await sqlInitPromise;
loadingWindow.destroy();
loadingWindow = undefined;
});
loadingWindow.loadURL(await prepareFileUrl([__dirname, '../loading.html']));
});
getLogger().info(
'sql.initialize is taking more than three seconds; showing loading dialog'
);
loadingWindow = new BrowserWindow({
show: false,
width: 300,
height: 265,
resizable: false,
frame: false,
backgroundColor,
webPreferences: {
...defaultWebPrefs,
nodeIntegration: false,
sandbox: false,
contextIsolation: true,
preload: join(__dirname, '../ts/windows/loading/preload.js'),
},
icon: windowIcon,
});
loadingWindow.once('ready-to-show', async () => {
if (!loadingWindow) {
return;
}
loadingWindow.show();
// Wait for sql initialization to complete, but ignore errors
await sqlInitPromise;
loadingWindow.destroy();
loadingWindow = undefined;
});
await loadingWindow.loadURL(
await prepareFileUrl([__dirname, '../loading.html'])
);
})
);
try {
await attachments.clearTempPath(userDataPath);
@ -1858,7 +1877,7 @@ app.on('ready', async () => {
shouldMinimizeToSystemTray(await systemTraySettingCache.get())
);
ensureFilePermissions([
await ensureFilePermissions([
'config.json',
'sql/db.sqlite',
'sql/db.sqlite-wal',
@ -1996,7 +2015,7 @@ app.on('activate', () => {
if (mainWindow) {
mainWindow.show();
} else {
createWindow();
drop(createWindow());
}
});
@ -2122,7 +2141,7 @@ ipc.on('stop-screen-share', () => {
});
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) => {
@ -2311,18 +2330,20 @@ async function ensureFilePermissions(onlyFiles?: Array<string>) {
// Touch each file in a queue
const q = new PQueue({ concurrency: 5, timeout: 1000 * 60 * 2 });
q.addAll(
files.map(f => async () => {
const isDir = f.endsWith('/');
try {
await chmod(normalize(f), isDir ? 0o700 : 0o600);
} catch (error) {
getLogger().error(
'ensureFilePermissions: Error from chmod',
error.message
);
}
})
drop(
q.addAll(
files.map(f => async () => {
const isDir = f.endsWith('/');
try {
await chmod(normalize(f), isDir ? 0o700 : 0o600);
} catch (error) {
getLogger().error(
'ensureFilePermissions: Error from chmod',
error.message
);
}
})
)
);
await q.onEmpty();
@ -2345,7 +2366,7 @@ ipc.handle('set-auto-launch', async (_event, value) => {
});
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) => {
@ -2458,7 +2479,7 @@ ipc.handle('getMenuOptions', async () => {
ipc.handle('executeMenuAction', async (_event, action: MenuActionType) => {
if (action === 'forceUpdate') {
forceUpdate();
drop(forceUpdate());
} else if (action === 'openContactUs') {
openContactUs();
} else if (action === 'openForums') {
@ -2474,15 +2495,15 @@ ipc.handle('executeMenuAction', async (_event, action: MenuActionType) => {
} else if (action === 'setupAsStandalone') {
setupAsStandalone();
} else if (action === 'showAbout') {
showAbout();
drop(showAbout());
} else if (action === 'showDebugLog') {
showDebugLogWindow();
drop(showDebugLogWindow());
} else if (action === 'showKeyboardShortcuts') {
showKeyboardShortcuts();
} else if (action === 'showSettings') {
showSettingsWindow();
drop(showSettingsWindow());
} else if (action === 'showStickerCreator') {
showStickerCreator();
drop(showStickerCreator());
} else if (action === 'showWindow') {
showWindow();
} else {

View file

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

View file

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

View file

@ -14,6 +14,7 @@ import { DropZone } from '../elements/DropZone';
import { processStickerImage } from '../util/preload';
import { useI18n } from '../util/i18n';
import { MINUTE } from '../../ts/util/durations';
import { drop } from '../../ts/util/drop';
import * as Errors from '../../ts/types/errors';
const queue = new PQueue({ concurrency: 3, timeout: MINUTE * 30 });
@ -58,26 +59,28 @@ const InnerGrid = SortableContainer(
async paths => {
actions.initializeStickers(paths);
paths.forEach(path => {
queue.add(async () => {
try {
const stickerImage = await processStickerImage(path);
actions.addImageData(stickerImage);
} catch (e) {
window.SignalContext.log.error(
'Error processing image:',
Errors.toLogFormat(e)
);
actions.removeSticker(path);
drop(
queue.add(async () => {
try {
const stickerImage = await processStickerImage(path);
actions.addImageData(stickerImage);
} catch (e) {
window.SignalContext.log.error(
'Error processing image:',
Errors.toLogFormat(e)
);
actions.removeSticker(path);
const key =
e instanceof window.ProcessStickerImageError
? e.errorMessageI18nKey
: 'StickerCreator--Toasts--errorProcessing';
actions.addToast({
key,
});
}
});
const key =
e instanceof window.ProcessStickerImageError
? e.errorMessageI18nKey
: 'StickerCreator--Toasts--errorProcessing';
actions.addToast({
key,
});
}
})
);
});
},
[actions]

View file

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

View file

@ -1419,7 +1419,7 @@ export class SignalProtocolStore extends EventEmitter {
}
sessionResets[id] = Date.now();
window.storage.put('sessionResets', sessionResets);
await window.storage.put('sessionResets', sessionResets);
try {
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
// than one hour from now.
delete sessionResets[id];
window.storage.put('sessionResets', sessionResets);
await window.storage.put('sessionResets', sessionResets);
log.error(
`lightSessionReset/${id}: Encountered error`,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -204,7 +204,7 @@ export function StoryDetailsModal({
icon: 'StoryDetailsModal__copy-icon',
label: i18n('StoryDetailsModal__copy-timestamp'),
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) {
videoRef.current.pause();
} else {
videoRef.current.play();
void videoRef.current.play();
}
}, [isPaused]);

View file

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

View file

@ -618,7 +618,7 @@ function ReplyOrReactionMessage({
icon: 'module-message__context--icon module-message__context__copy-timestamp',
label: i18n('icu:StoryViewsNRepliesModal__copy-reply-timestamp'),
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;
(async () => {
void (async () => {
try {
if (!attachment.url) {
throw new Error(

View file

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

View file

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

View file

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

View file

@ -138,7 +138,7 @@ export function GroupLinkManagement({
ref={!isAdmin ? focusRef : undefined}
onClick={() => {
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 * as log from '../../logging/log';
import { MINUTE } from '../../util/durations';
import { drop } from '../../util/drop';
export const skinTones = ['1F3FB', '1F3FC', '1F3FD', '1F3FE', '1F3FF'];
@ -124,11 +125,11 @@ export const preloadImages = async (): Promise<void> => {
const start = Date.now();
data.forEach(emoji => {
imageQueue.add(() => preload(makeImagePath(emoji.image)));
drop(imageQueue.add(() => preload(makeImagePath(emoji.image))));
if (emoji.skin_variations) {
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 = {
readonly blessedPacks: ReadonlyArray<StickerPackType>;
readonly closeStickerPackPreview: (packId: string) => unknown;
readonly closeStickerPackPreview: () => unknown;
readonly downloadStickerPack: (packId: string, packKey: string) => unknown;
readonly i18n: LocalizerType;
readonly installStickerPack: (packId: string, packKey: string) => unknown;

View file

@ -14,7 +14,7 @@ import { Button, ButtonVariant } from '../Button';
export type OwnProps = {
readonly onClose?: () => unknown;
readonly closeStickerPackPreview: (packId: string) => unknown;
readonly closeStickerPackPreview: () => unknown;
readonly downloadStickerPack: (
packId: string,
packKey: string,
@ -107,9 +107,18 @@ export const StickerPreviewModal = React.memo(function StickerPreviewModalInner(
// 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(() => {
if (pack?.id) {
closeStickerPackPreview(pack.id);
if (pack) {
closeStickerPackPreview();
}
onClose?.();
}, [closeStickerPackPreview, onClose, pack]);

View file

@ -1602,7 +1602,7 @@ export async function modifyGroupV2({
`modifyGroupV2/${logId}: Conflict while updating. Timed out; not retrying.`
);
// 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;
} else {
const errorString = Errors.toLogFormat(error);
@ -2403,7 +2403,7 @@ export async function initiateMigrationToGroupV2(
});
if (window.storage.blocked.isGroupBlocked(previousGroupV1Id)) {
window.storage.blocked.addBlockedGroup(groupId);
await window.storage.blocked.addBlockedGroup(groupId);
}
// Save these most recent updates to conversation
@ -2721,7 +2721,7 @@ export async function respondToGroupV2Migration({
);
if (window.storage.blocked.isGroupBlocked(previousGroupV1Id)) {
window.storage.blocked.addBlockedGroup(groupId);
await window.storage.blocked.addBlockedGroup(groupId);
}
if (wereWePreviouslyAMember) {
@ -2862,7 +2862,7 @@ export async function respondToGroupV2Migration({
});
if (window.storage.blocked.isGroupBlocked(previousGroupV1Id)) {
window.storage.blocked.addBlockedGroup(groupId);
await window.storage.blocked.addBlockedGroup(groupId);
}
// Save these most recent updates to conversation
@ -3080,7 +3080,7 @@ async function updateGroup(
contact.get('profileKey') !== member.profileKey
) {
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
waitThenLeave();
void waitThenLeave();
}
}
}
@ -3359,7 +3359,7 @@ async function appendChangeMessages(
// We updated the message, but didn't add new ones - refresh left pane
if (!newMessages && mergedMessages.length > 0) {
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;
}

View file

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

View file

@ -130,7 +130,7 @@ export abstract class JobQueue<T> {
const stream = this.store.stream(this.queueType);
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);
} else if (toProcess instanceof SendMessageChallengeError) {
window.Signal.challengeHandler?.register(
void window.Signal.challengeHandler?.register(
{
conversationId,
createdAt: Date.now(),

View file

@ -71,7 +71,11 @@ export async function sendDeleteForEveryone(
if (!shouldContinue) {
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;
}
@ -148,7 +152,7 @@ export async function sendDeleteForEveryone(
log.info(
`conversation ${conversation.idForLogging()} is not accepted; refusing to send`
);
updateMessageWithFailure(
void updateMessageWithFailure(
message,
[new Error('Message request was not accepted')],
log
@ -159,7 +163,7 @@ export async function sendDeleteForEveryone(
log.info(
`conversation ${conversation.idForLogging()} is unregistered; refusing to send`
);
updateMessageWithFailure(
void updateMessageWithFailure(
message,
[new Error('Contact no longer has a Signal account')],
log
@ -170,7 +174,7 @@ export async function sendDeleteForEveryone(
log.info(
`conversation ${conversation.idForLogging()} is blocked; refusing to send`
);
updateMessageWithFailure(
void updateMessageWithFailure(
message,
[new Error('Contact is blocked')],
log

View file

@ -53,7 +53,11 @@ export async function sendDeleteStoryForEveryone(
if (!shouldContinue) {
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;
}
@ -107,7 +111,7 @@ export async function sendDeleteStoryForEveryone(
`${logId}: conversation ${conversation.idForLogging()} ` +
'is not accepted; refusing to send'
);
updateMessageWithFailure(
void updateMessageWithFailure(
message,
[new Error('Message request was not accepted')],
log
@ -119,7 +123,7 @@ export async function sendDeleteStoryForEveryone(
`${logId}: conversation ${conversation.idForLogging()} ` +
'is unregistered; refusing to send'
);
updateMessageWithFailure(
void updateMessageWithFailure(
message,
[new Error('Contact no longer has a Signal account')],
log
@ -131,7 +135,7 @@ export async function sendDeleteStoryForEveryone(
`${logId}: conversation ${conversation.idForLogging()} ` +
'is blocked; refusing to send'
);
updateMessageWithFailure(
void updateMessageWithFailure(
message,
[new Error('Contact is blocked')],
log

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -9,6 +9,7 @@ import { getContactId } from '../messages/helpers';
import * as log from '../logging/log';
import * as Errors from '../types/errors';
import { deleteForEveryone } from '../util/deleteForEveryone';
import { drop } from '../util/drop';
export type DeleteAttributesType = {
targetSentTimestamp: number;
@ -67,36 +68,38 @@ export class Deletes extends Collection<DeleteModel> {
}
// Do not await, since this can deadlock the queue
targetConversation.queueJob('Deletes.onDelete', async () => {
log.info('Handling DOE for', del.get('targetSentTimestamp'));
drop(
targetConversation.queueJob('Deletes.onDelete', async () => {
log.info('Handling DOE for', del.get('targetSentTimestamp'));
const messages = await window.Signal.Data.getMessagesBySentAt(
del.get('targetSentTimestamp')
);
const targetMessage = messages.find(
m => del.get('fromId') === getContactId(m) && !m.deletedForEveryone
);
if (!targetMessage) {
log.info(
'No message for DOE',
del.get('fromId'),
const messages = await window.Signal.Data.getMessagesBySentAt(
del.get('targetSentTimestamp')
);
return;
}
const targetMessage = messages.find(
m => del.get('fromId') === getContactId(m) && !m.deletedForEveryone
);
const message = window.MessageController.register(
targetMessage.id,
targetMessage
);
if (!targetMessage) {
log.info(
'No message for DOE',
del.get('fromId'),
del.get('targetSentTimestamp')
);
await deleteForEveryone(message, del);
return;
}
this.remove(del);
});
const message = window.MessageController.register(
targetMessage.id,
targetMessage
);
await deleteForEveryone(message, del);
this.remove(del);
})
);
} catch (error) {
log.error('Deletes.onDelete error:', Errors.toLogFormat(error));
}

View file

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

View file

@ -208,7 +208,7 @@ export class Reactions extends Collection<ReactionModel> {
generatedMessage.id,
generatedMessage
);
targetConversation.addSingleMessage(messageToAdd);
void targetConversation.addSingleMessage(messageToAdd);
}
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
// marked read. We want those messages to have the same expire timer
// 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) {

View file

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

View file

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

View file

@ -39,6 +39,7 @@ import { isNotNil } from '../util/isNotNil';
import { isNormalNumber } from '../util/isNormalNumber';
import { softAssert, strictAssert } from '../util/assert';
import { missingCaseError } from '../util/missingCaseError';
import { drop } from '../util/drop';
import { dropNull } from '../util/dropNull';
import { incrementMessageCounter } from '../util/incrementMessageCounter';
import type { ConversationModel } from './conversations';
@ -1791,7 +1792,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
saveErrors(errorsToSave);
} else {
// 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) {
@ -1853,7 +1854,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
saveErrors(errors);
} else {
// We don't save because we're about to save below.
this.saveErrors(errors, { skipSave: true });
void this.saveErrors(errors, { skipSave: true });
}
throw error;
} 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
// processing incoming messages to start sending outgoing delivery receipts.
// The queue can be paused easily.
window.Whisper.deliveryReceiptQueue.add(() => {
window.Whisper.deliveryReceiptBatcher.add({
messageId,
senderE164: source,
senderUuid: sourceUuid,
timestamp: this.get('sent_at'),
isDirectConversation: isDirectConversation(conversation.attributes),
});
});
drop(
window.Whisper.deliveryReceiptQueue.add(() => {
window.Whisper.deliveryReceiptBatcher.add({
messageId,
senderE164: source,
senderUuid: sourceUuid,
timestamp: this.get('sent_at'),
isDirectConversation: isDirectConversation(
conversation.attributes
),
});
})
);
}
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
// point and these calls will return early.
if (dataMessage.expireTimer) {
conversation.updateExpirationTimer(dataMessage.expireTimer, {
void conversation.updateExpirationTimer(dataMessage.expireTimer, {
source: sourceUuid || source,
receivedAt: message.get('received_at'),
receivedAtMS: message.get('received_at_ms'),
@ -2970,7 +2975,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
!isGroupUpdate(message.attributes) &&
!isEndSession(message.attributes)
) {
conversation.updateExpirationTimer(undefined, {
void conversation.updateExpirationTimer(undefined, {
source: sourceUuid || source,
receivedAt: message.get('received_at'),
receivedAtMS: message.get('received_at_ms'),
@ -2989,14 +2994,14 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
) {
conversation.set({ profileSharing: true });
} else if (isDirectConversation(conversation.attributes)) {
conversation.setProfileKey(profileKey);
void conversation.setProfileKey(profileKey);
} else {
const local = window.ConversationController.lookupOrCreate({
e164: source,
uuid: sourceUuid,
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);
log.info(`${idLog}: Batching save`);
this.saveAndNotify(conversation, confirm);
void this.saveAndNotify(conversation, confirm);
} catch (error) {
const errorForLog = Errors.toLogFormat(error);
log.error(`${idLog}: error:`, errorForLog);
@ -3154,7 +3159,9 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
confirm();
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
// message and the other ones accompanying it in the batch are fully in
// the database.
message.getConversation()?.onReadMessage(message, markReadAt);
void message.getConversation()?.onReadMessage(message, markReadAt);
}
// 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 ' +
`${this.idForLogging()} from someone else`
);
conversation.notify(this, reaction);
void conversation.notify(this, reaction);
}
} else if (isFromThisDevice) {
log.info(
@ -3522,7 +3529,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
this.set({ reactions });
if (isOutgoing(this.attributes) && isFromSomeoneElse) {
conversation.notify(this, reaction);
void conversation.notify(this, reaction);
}
await window.Signal.Data.addReaction({
@ -3583,7 +3590,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
reactionMessage.hydrateStoryContext(this),
]);
conversation.addSingleMessage(
void conversation.addSingleMessage(
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
this.getConversation()?.updateLastMessage();
void this.getConversation()?.updateLastMessage();
} finally {
this.deletingForEveryone = undefined;
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -191,7 +191,7 @@ export async function maybeFetchNewCredentials(): Promise<void> {
log.info(`${logId}: Saving new credentials...`);
// 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.`);
}

View file

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

View file

@ -157,7 +157,7 @@ class NotificationService extends EventEmitter {
audioNotificationSupport === AudioNotificationSupport.Custom
) {
// 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;

View file

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

View file

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

View file

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

View file

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

View file

@ -4,11 +4,11 @@
import type { StorageAccessType } from '../types/Storage.d';
// Matching window.storage.put API
export function put<K extends keyof StorageAccessType>(
export async function put<K extends keyof StorageAccessType>(
key: K,
value: StorageAccessType[K]
): void {
window.storage.put(key, value);
): Promise<void> {
await window.storage.put(key, value);
}
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 { formatJobForInsert } from '../jobs/formatJobForInsert';
import { cleanupMessage } from '../util/cleanup';
import { drop } from '../util/drop';
import type {
AllItemsType,
@ -631,8 +632,8 @@ async function saveMessage(
softAssert(isValidUuid(id), 'saveMessage: messageId is not a UUID');
expiringMessagesDeletionService.update();
tapToViewMessagesDeletionService.update();
void expiringMessagesDeletionService.update();
void tapToViewMessagesDeletionService.update();
return id;
}
@ -646,8 +647,8 @@ async function saveMessages(
options
);
expiringMessagesDeletionService.update();
tapToViewMessagesDeletionService.update();
void expiringMessagesDeletionService.update();
void tapToViewMessagesDeletionService.update();
}
async function removeMessage(id: string): Promise<void> {
@ -781,9 +782,11 @@ async function removeAllMessagesInConversation(
// 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.
const queue = new PQueue({ concurrency: 3, timeout: MINUTE * 30 });
queue.addAll(
messages.map(
(message: MessageType) => async () => cleanupMessage(message)
drop(
queue.addAll(
messages.map(
(message: MessageType) => async () => cleanupMessage(message)
)
)
);
// eslint-disable-next-line no-await-in-loop

View file

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

View file

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

View file

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

View file

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

View file

@ -177,7 +177,7 @@ function onClearAttachments(conversationId: string): NoopActionType {
throw new Error('onClearAttachments: No conversation found');
}
clearConversationDraftAttachments(
void clearConversationDraftAttachments(
conversation.id,
conversation.get('draftAttachments')
);
@ -194,7 +194,7 @@ function cancelJoinRequest(conversationId: string): NoopActionType {
throw new Error('cancelJoinRequest: No conversation found');
}
longRunningTaskWrapper({
void longRunningTaskWrapper({
idForLogging: conversation.idForLogging(),
name: 'cancelJoinRequest',
task: async () => conversation.cancelJoinRequest(),
@ -383,7 +383,10 @@ function sendMultiMediaMessage(
extraReduxActions: () => {
conversation.setMarkedUnread(false);
resetLinkPreview();
clearConversationDraftAttachments(conversationId, draftAttachments);
void clearConversationDraftAttachments(
conversationId,
draftAttachments
);
setQuoteByMessageId(conversationId, undefined)(
dispatch,
getState,
@ -447,7 +450,7 @@ function sendStickerMessage(
}
const { packId, stickerId } = options;
conversation.sendStickerMessage(packId, stickerId);
void conversation.sendStickerMessage(packId, stickerId);
} catch (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 { getOwn } from '../../util/getOwn';
import { assertDev, strictAssert } from '../../util/assert';
import { drop } from '../../util/drop';
import type { DurationInSeconds } from '../../util/durations';
import * as universalExpireTimer from '../../util/universalExpireTimer';
import * as Attachment from '../../types/Attachment';
@ -1086,7 +1087,7 @@ function blockGroupLinkRequests(
throw new Error('blockGroupLinkRequests: Conversation not found!');
}
conversation.blockGroupLinkRequests(uuid);
void conversation.blockGroupLinkRequests(uuid);
return {
type: 'NOOP',
@ -1102,7 +1103,7 @@ function loadNewerMessages(
throw new Error('loadNewerMessages: Conversation not found!');
}
conversation.loadNewerMessages(newestMessageId);
void conversation.loadNewerMessages(newestMessageId);
return {
type: 'NOOP',
@ -1119,7 +1120,7 @@ function loadNewestMessages(
throw new Error('loadNewestMessages: Conversation not found!');
}
conversation.loadNewestMessages(newestMessageId, setFocus);
void conversation.loadNewestMessages(newestMessageId, setFocus);
return {
type: 'NOOP',
@ -1135,7 +1136,7 @@ function loadOlderMessages(
throw new Error('loadOlderMessages: Conversation not found!');
}
conversation.loadOlderMessages(oldestMessageId);
void conversation.loadOlderMessages(oldestMessageId);
return {
type: 'NOOP',
payload: null,
@ -1181,7 +1182,7 @@ function removeMember(
throw new Error('removeMember: Conversation not found!');
}
longRunningTaskWrapper({
void longRunningTaskWrapper({
idForLogging: conversation.idForLogging(),
name: 'removeMember',
task: () => conversation.removeFromGroupV2(memberConversationId),
@ -1211,7 +1212,7 @@ function updateSharedGroups(conversationId: string): NoopActionType {
throw new Error('updateSharedGroups: Conversation not found!');
}
conversation.throttledUpdateSharedGroups?.();
void conversation.throttledUpdateSharedGroups?.();
return {
type: 'NOOP',
@ -1508,7 +1509,7 @@ function deleteMessage({
);
}
window.Signal.Data.removeMessage(messageId);
void window.Signal.Data.removeMessage(messageId);
if (isOutgoing(message.attributes)) {
conversation.decrementSentMessageCount();
} else {
@ -1538,7 +1539,7 @@ function destroyMessages(
task: async () => {
conversation.trigger('unload', 'delete messages');
await conversation.destroyMessages();
conversation.updateLastMessage();
void conversation.updateLastMessage();
},
});
@ -1596,29 +1597,33 @@ export const markViewed = (messageId: string): void => {
message.set(messageUpdaterMarkViewed(message.attributes, Date.now()));
if (isIncoming(message.attributes)) {
viewedReceiptsJobQueue.add({
viewedReceipt: {
messageId,
senderE164,
senderUuid,
timestamp,
isDirectConversation: isDirectConversation(
message.getConversation()?.attributes
),
},
});
drop(
viewedReceiptsJobQueue.add({
viewedReceipt: {
messageId,
senderE164,
senderUuid,
timestamp,
isDirectConversation: isDirectConversation(
message.getConversation()?.attributes
),
},
})
);
}
viewSyncJobQueue.add({
viewSyncs: [
{
messageId,
senderE164,
senderUuid,
timestamp,
},
],
});
drop(
viewSyncJobQueue.add({
viewSyncs: [
{
messageId,
senderE164,
senderUuid,
timestamp,
},
],
})
);
};
function setAccessControlAddFromInviteLinkSetting(
@ -2317,7 +2322,7 @@ function getProfilesForConversation(conversationId: string): NoopActionType {
throw new Error('getProfilesForConversation: no conversation found');
}
conversation.getProfiles();
void conversation.getProfiles();
return {
type: 'NOOP',
@ -2341,7 +2346,7 @@ function conversationStoppedByMissingVerification(payload: {
}
// Intentionally not awaiting here
conversation.getProfiles();
void conversation.getProfiles();
});
return {
@ -2784,7 +2789,7 @@ function blockAndReportSpam(
const messageRequestEnum = Proto.SyncMessage.MessageRequestResponse.Type;
const idForLogging = conversation.idForLogging();
longRunningTaskWrapper({
void longRunningTaskWrapper({
name: 'blockAndReportSpam',
idForLogging,
task: async () => {
@ -2819,7 +2824,7 @@ function acceptConversation(conversationId: string): NoopActionType {
const messageRequestEnum = Proto.SyncMessage.MessageRequestResponse.Type;
longRunningTaskWrapper({
void longRunningTaskWrapper({
name: 'acceptConversation',
idForLogging: conversation.idForLogging(),
task: conversation.syncMessageRequestResponse.bind(
@ -2844,7 +2849,7 @@ function blockConversation(conversationId: string): NoopActionType {
const messageRequestEnum = Proto.SyncMessage.MessageRequestResponse.Type;
longRunningTaskWrapper({
void longRunningTaskWrapper({
name: 'blockConversation',
idForLogging: conversation.idForLogging(),
task: conversation.syncMessageRequestResponse.bind(
@ -2869,7 +2874,7 @@ function deleteConversation(conversationId: string): NoopActionType {
const messageRequestEnum = Proto.SyncMessage.MessageRequestResponse.Type;
longRunningTaskWrapper({
void longRunningTaskWrapper({
name: 'deleteConversation',
idForLogging: conversation.idForLogging(),
task: conversation.syncMessageRequestResponse.bind(
@ -2892,7 +2897,7 @@ function initiateMigrationToGroupV2(conversationId: string): NoopActionType {
);
}
longRunningTaskWrapper({
void longRunningTaskWrapper({
idForLogging: conversation.idForLogging(),
name: 'initiateMigrationToGroupV2',
task: () => doInitiateMigrationToGroupV2(conversation),
@ -3121,7 +3126,7 @@ export function scrollToMessage(
return;
}
conversation.loadAndScroll(messageId);
void conversation.loadAndScroll(messageId);
};
}
@ -3221,7 +3226,7 @@ function removeMemberFromGroup(
const conversationModel = window.ConversationController.get(conversationId);
if (conversationModel) {
const idForLogging = conversationModel.idForLogging();
longRunningTaskWrapper({
void longRunningTaskWrapper({
name: 'removeMemberFromGroup',
idForLogging,
task: () => conversationModel.removeFromGroupV2(contactId),
@ -3372,7 +3377,7 @@ function toggleAdmin(
return dispatch => {
const conversationModel = window.ConversationController.get(conversationId);
if (conversationModel) {
conversationModel.toggleAdmin(contactId);
void conversationModel.toggleAdmin(contactId);
}
dispatch({
type: 'NOOP',
@ -3387,7 +3392,7 @@ function updateConversationModelSharedGroups(
return dispatch => {
const conversation = window.ConversationController.get(conversationId);
if (conversation && conversation.throttledUpdateSharedGroups) {
conversation.throttledUpdateSharedGroups();
void conversation.throttledUpdateSharedGroups();
}
dispatch({
type: 'NOOP',
@ -3457,7 +3462,7 @@ function showArchivedConversations(): ShowArchivedConversationsActionType {
function doubleCheckMissingQuoteReference(messageId: string): NoopActionType {
const message = window.MessageController.getById(messageId);
if (message) {
message.doubleCheckMissingQuoteReference();
void message.doubleCheckMissingQuoteReference();
}
return {

View file

@ -443,11 +443,10 @@ function closeStickerPackPreview(): ThunkAction<
return async (dispatch, getState) => {
const packId = getState().globalModals.stickerPackPreviewId;
if (!packId) {
return;
if (packId && Stickers.getStickerPack(packId) !== undefined) {
await Stickers.removeEphemeralPack(packId);
}
await Stickers.removeEphemeralPack(packId);
dispatch({
type: CLOSE_STICKER_PACK_PREVIEW,
});
@ -460,7 +459,7 @@ export function showStickerPackPreview(
): ShowStickerPackPreviewActionType {
// Intentionally not awaiting this so that we can show the modal right away.
// The modal has a loading spinner on it.
Stickers.downloadEphemeralPack(packId, packKey);
void Stickers.downloadEphemeralPack(packId, packKey);
return {
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 type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions';
import { useBoundActions } from '../../hooks/useBoundActions';
import { drop } from '../../util/drop';
import type {
ConversationColorType,
CustomColorType,
@ -100,16 +101,19 @@ export const useActions = (): BoundActionCreatorsMapObject<typeof actions> =>
function putItem<K extends keyof StorageAccessType>(
key: K,
value: StorageAccessType[K]
): ItemPutAction {
storageShim.put(key, value);
return {
type: 'items/PUT',
payload: null,
): ThunkAction<void, RootStateType, unknown, ItemPutAction> {
return async dispatch => {
dispatch({
type: 'items/PUT',
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);
}
@ -124,7 +128,7 @@ function putItemExternal(key: string, value: unknown): ItemPutExternalAction {
}
function removeItem(key: keyof StorageAccessType): ItemRemoveAction {
storageShim.remove(key);
drop(storageShim.remove(key));
return {
type: 'items/REMOVE',

View file

@ -77,7 +77,7 @@ function closeLightbox(): ThunkAction<
if (!item.attachment.path) {
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;
}
(async () => {
void (async () => {
dispatch({
type: 'SEARCH_MESSAGES_RESULTS_FULFILLED',
payload: {
@ -220,7 +220,7 @@ const doSearch = debounce(
})();
if (!searchConversationId) {
(async () => {
void (async () => {
const { conversationIds, contactIds } =
await queryConversationsAndContacts(query, {
ourConversationId,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2172,7 +2172,7 @@ describe('both/state/ducks/conversations', () => {
assert.isUndefined(
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 { Address } from '../../types/Address';
import { UUID } from '../../types/UUID';
import { explodePromise } from '../../util/explodePromise';
import { SignalProtocolStore } from '../../SignalProtocolStore';
import type { ConversationModel } from '../../models/conversations';
import * as KeyChangeListener from '../../textsecure/KeyChangeListener';
@ -76,13 +77,15 @@ describe('KeyChangeListener', () => {
});
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 { resolve, promise } = explodePromise<void>();
convo.addKeyChange = async () => {
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);
});
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 { resolve, promise } = explodePromise<void>();
groupConvo.addKeyChange = async (_, keyChangedId) => {
assert.equal(uuidWithKeyChange, keyChangedId?.toString());
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;
(async () => {
void (async () => {
await waitForOnline(fakeNavigator, fakeWindow, { timeout: 9999 });
done = true;
})();

View file

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

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