Harden bulk retries, parallelize guest uploads, and move guest map below gallery

This commit is contained in:
2026-09-11 18:54:46 -04:00
parent 4bc48db656
commit 1e299a9914
25 changed files with 376 additions and 62 deletions
+23
View File
@@ -0,0 +1,23 @@
// Keep a few transfers in flight without flooding mobile connections or allocating
// a promise/network request for every selected file at once.
export const UPLOAD_CONCURRENCY = 3;
export async function runUploadQueue<T>(
items: readonly T[],
upload: (item: T, index: number) => Promise<void>,
) {
let next = 0;
const errors: unknown[] = [];
await Promise.all(Array.from({ length: Math.min(UPLOAD_CONCURRENCY, items.length) }, async () => {
while (next < items.length) {
const index = next++;
try {
await upload(items[index]!, index);
} catch (error) {
errors.push(error);
}
}
}));
// Never release the batch's busy guard while other transfers are still running.
if (errors.length) throw new AggregateError(errors, "Some uploads failed");
}