Add backup validation to settings

This commit is contained in:
Fedor Indutny
2025-04-15 16:04:30 -07:00
committed by GitHub
parent fef6706a75
commit f68ef019a5
16 changed files with 292 additions and 34 deletions
+27
View File
@@ -14,6 +14,7 @@ import classNames from 'classnames';
import * as LocaleMatcher from '@formatjs/intl-localematcher';
import type { MediaDeviceSettings } from '../types/Calling';
import type { ExportResultType as BackupExportResultType } from '../services/backups';
import type {
AutoDownloadAttachmentType,
NotificationSettingType,
@@ -75,6 +76,7 @@ import {
SettingsRow,
} from './PreferencesUtil';
import { PreferencesBackups } from './PreferencesBackups';
import { PreferencesInternal } from './PreferencesInternal';
import { FunEmojiLocalizationProvider } from './fun/FunEmojiLocalizationProvider';
type CheckboxChangeHandlerType = (value: boolean) => unknown;
@@ -145,6 +147,7 @@ export type PropsDataType = {
isSyncSupported: boolean;
isSystemTraySupported: boolean;
isMinimizeToAndStartInSystemTraySupported: boolean;
isInternalUser: boolean;
availableCameras: Array<
Pick<MediaDeviceInfo, 'deviceId' | 'groupId' | 'kind' | 'label'>
@@ -175,6 +178,7 @@ type PropsFunctionType = {
value: CustomColorType;
}
) => unknown;
validateBackup: () => Promise<BackupExportResultType>;
// Change handlers
onAudioNotificationsChange: CheckboxChangeHandlerType;
@@ -232,6 +236,7 @@ export enum Page {
Privacy = 'Privacy',
DataUsage = 'DataUsage',
Backups = 'Backups',
Internal = 'Internal',
// Sub pages
ChatColor = 'ChatColor',
@@ -319,6 +324,7 @@ export function Preferences({
isSyncSupported,
isSystemTraySupported,
isMinimizeToAndStartInSystemTraySupported,
isInternalUser,
lastSyncTime,
makeSyncRequest,
notificationContent,
@@ -373,6 +379,7 @@ export function Preferences({
localeOverride,
themeSetting,
universalExpireTimer = DurationInSeconds.ZERO,
validateBackup,
whoCanFindMe,
whoCanSeeMe,
zoomFactor,
@@ -410,6 +417,9 @@ export function Preferences({
if (page === Page.Backups && !shouldShowBackupsPage) {
setPage(Page.General);
}
if (page === Page.Internal && !isInternalUser) {
setPage(Page.General);
}
useEffect(() => {
if (page === Page.Backups) {
@@ -1728,6 +1738,10 @@ export function Preferences({
locale={resolvedLocale}
/>
);
} else if (page === Page.Internal) {
settings = (
<PreferencesInternal i18n={i18n} validateBackup={validateBackup} />
);
}
return (
@@ -1829,6 +1843,19 @@ export function Preferences({
{i18n('icu:Preferences__button--backups')}
</button>
) : null}
{isInternalUser ? (
<button
type="button"
className={classNames({
Preferences__button: true,
'Preferences__button--internal': true,
'Preferences__button--selected': page === Page.Internal,
})}
onClick={() => setPage(Page.Internal)}
>
{i18n('icu:Preferences__button--internal')}
</button>
) : null}
</div>
<div className="Preferences__settings-pane" ref={settingsPaneRef}>
{settings}