signal-desktop/ts/util/updateBackupMediaDownloadProgress.ts
automated-signal 62cecc0a1c
Refactor backup media download progress tracking
Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
2025-07-19 09:19:02 +10:00

22 lines
738 B
TypeScript

// Copyright 2025 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { throttle } from 'lodash';
import type { BackupAttachmentDownloadProgress } from '../sql/Interface';
export async function updateBackupMediaDownloadProgress(
getBackupAttachmentDownloadProgress: () => Promise<BackupAttachmentDownloadProgress>
): Promise<void> {
const { totalBytes, completedBytes } =
await getBackupAttachmentDownloadProgress();
await Promise.all([
window.storage.put('backupMediaDownloadCompletedBytes', completedBytes),
window.storage.put('backupMediaDownloadTotalBytes', totalBytes),
]);
}
export const throttledUpdateBackupMediaDownloadProgress = throttle(
updateBackupMediaDownloadProgress,
200
);