SafetyNumberChangeDialog: Introduce awareness of stories

This commit is contained in:
Scott Nonnenberg 2022-11-10 20:10:30 -08:00 committed by GitHub
parent 709588a874
commit 5100d17ed2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 2531 additions and 522 deletions

23
ts/util/waitForAll.ts Normal file
View file

@ -0,0 +1,23 @@
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import PQueue from 'p-queue';
import { MINUTE } from './durations';
const MAX_CONCURRENCY = 5;
export async function waitForAll<T>({
tasks,
maxConcurrency = MAX_CONCURRENCY,
}: {
tasks: Array<() => Promise<T>>;
maxConcurrency?: number;
}): Promise<Array<T>> {
const queue = new PQueue({
concurrency: maxConcurrency,
timeout: MINUTE * 30,
throwOnTimeout: true,
});
return queue.addAll(tasks);
}