mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-02 00:07:56 +01:00
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
// Copyright 2025 Signal Messenger, LLC
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
import type { ReadonlyObjectDeep } from 'type-fest/source/readonly-deep.js';
|
|
import { isEnabled, type ConfigMapType } from '../RemoteConfig.dom.js';
|
|
import {
|
|
isFeaturedEnabledNoRedux,
|
|
isFeaturedEnabledSelector,
|
|
} from './isFeatureEnabled.dom.js';
|
|
import { itemStorage } from '../textsecure/Storage.preload.js';
|
|
import { isNightly } from './version.std.js';
|
|
import { isTestOrMockEnvironment } from '../environment.std.js';
|
|
|
|
const IOS_USER_AGENT = 'OWI';
|
|
|
|
export function isLocalBackupsEnabled(reduxArgs?: {
|
|
currentVersion: string;
|
|
remoteConfig: ReadonlyObjectDeep<ConfigMapType> | undefined;
|
|
}): boolean {
|
|
// This is a temporary guard until iOS supports importing local backups
|
|
// Android no longer sends its OWA agent string, so we have to rely on iOS
|
|
if (
|
|
itemStorage.get('userAgent') === IOS_USER_AGENT &&
|
|
!isNightly(window.getVersion()) &&
|
|
!isTestOrMockEnvironment() &&
|
|
!isEnabled('desktop.internalUser', reduxArgs?.remoteConfig)
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
if (reduxArgs) {
|
|
return isFeaturedEnabledSelector({
|
|
currentVersion: reduxArgs.currentVersion,
|
|
remoteConfig: reduxArgs.remoteConfig,
|
|
betaKey: 'desktop.localBackups.beta',
|
|
prodKey: 'desktop.localBackups.prod',
|
|
});
|
|
}
|
|
|
|
return isFeaturedEnabledNoRedux({
|
|
betaKey: 'desktop.localBackups.beta',
|
|
prodKey: 'desktop.localBackups.prod',
|
|
});
|
|
}
|