signal-desktop/ts/util/isBackupEnabled.ts

33 lines
950 B
TypeScript
Raw Normal View History

2024-04-22 23:25:56 +02:00
// Copyright 2024 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import * as RemoteConfig from '../RemoteConfig';
import { isTestOrMockEnvironment } from '../environment';
2024-09-04 11:12:45 -07:00
import { isStagingServer } from './isStagingServer';
import { isNightly } from './version';
2024-04-22 23:25:56 +02:00
export function areRemoteBackupsTurnedOn(): boolean {
return isBackupFeatureEnabled() && window.storage.get('backupTier') != null;
}
// Downloading from a remote backup is currently a test-only feature
export function canAttemptRemoteBackupDownload(): boolean {
return isBackupFeatureEnabled() && isTestOrMockEnvironment();
}
export function isBackupFeatureEnabled(
reduxConfig?: RemoteConfig.ConfigMapType
): boolean {
if (isStagingServer() || isTestOrMockEnvironment()) {
2024-08-08 12:22:48 -07:00
return true;
}
if (isNightly(window.getVersion())) {
return true;
}
return Boolean(
RemoteConfig.isEnabled('desktop.backup.credentialFetch', reduxConfig)
);
}