signal-desktop/ts/util/backupMediaDownload.ts
automated-signal ec0d64de6e
Pause, cancel & resume backup media download
Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
2024-09-16 14:44:56 -07:00

34 lines
1.1 KiB
TypeScript

// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { DataWriter } from '../sql/Client';
export async function pauseBackupMediaDownload(): Promise<void> {
await window.storage.put('backupMediaDownloadPaused', true);
}
export async function resumeBackupMediaDownload(): Promise<void> {
await window.storage.put('backupMediaDownloadPaused', false);
}
export async function resetBackupMediaDownloadItems(): Promise<void> {
await Promise.all([
window.storage.remove('backupMediaDownloadTotalBytes'),
window.storage.remove('backupMediaDownloadCompletedBytes'),
window.storage.remove('backupMediaDownloadBannerDismissed'),
window.storage.remove('backupMediaDownloadPaused'),
]);
}
export async function cancelBackupMediaDownload(): Promise<void> {
await DataWriter.removeAllBackupAttachmentDownloadJobs();
await resetBackupMediaDownloadItems();
}
export async function resetBackupMediaDownload(): Promise<void> {
await resetBackupMediaDownloadItems();
}
export async function dismissBackupMediaDownloadBanner(): Promise<void> {
await window.storage.put('backupMediaDownloadBannerDismissed', true);
}