diff --git a/src/lib/graphql/generated/apollo-helpers.ts b/src/lib/graphql/generated/apollo-helpers.ts index f13ea61c..a54b2f42 100644 --- a/src/lib/graphql/generated/apollo-helpers.ts +++ b/src/lib/graphql/generated/apollo-helpers.ts @@ -454,8 +454,9 @@ export type PageInfoFieldPolicy = { hasPreviousPage?: FieldPolicy | FieldReadFunction, startCursor?: FieldPolicy | FieldReadFunction }; -export type PartialSettingsTypeKeySpecifier = ('autoDownloadNewChapters' | 'backupInterval' | 'backupPath' | 'backupTTL' | 'backupTime' | 'basicAuthEnabled' | 'basicAuthPassword' | 'basicAuthUsername' | 'debugLogsEnabled' | 'downloadAsCbz' | 'downloadsPath' | 'electronPath' | 'excludeCompleted' | 'excludeNotStarted' | 'excludeUnreadChapters' | 'globalUpdateInterval' | 'initialOpenInBrowserEnabled' | 'ip' | 'localSourcePath' | 'maxSourcesInParallel' | 'port' | 'socksProxyEnabled' | 'socksProxyHost' | 'socksProxyPort' | 'systemTrayEnabled' | 'webUIChannel' | 'webUIFlavor' | 'webUIInterface' | 'webUIUpdateCheckInterval' | PartialSettingsTypeKeySpecifier)[]; +export type PartialSettingsTypeKeySpecifier = ('autoDownloadAheadLimit' | 'autoDownloadNewChapters' | 'backupInterval' | 'backupPath' | 'backupTTL' | 'backupTime' | 'basicAuthEnabled' | 'basicAuthPassword' | 'basicAuthUsername' | 'debugLogsEnabled' | 'downloadAsCbz' | 'downloadsPath' | 'electronPath' | 'excludeCompleted' | 'excludeEntryWithUnreadChapters' | 'excludeNotStarted' | 'excludeUnreadChapters' | 'globalUpdateInterval' | 'gqlDebugLogsEnabled' | 'initialOpenInBrowserEnabled' | 'ip' | 'localSourcePath' | 'maxSourcesInParallel' | 'port' | 'socksProxyEnabled' | 'socksProxyHost' | 'socksProxyPort' | 'systemTrayEnabled' | 'updateMangas' | 'webUIChannel' | 'webUIFlavor' | 'webUIInterface' | 'webUIUpdateCheckInterval' | PartialSettingsTypeKeySpecifier)[]; export type PartialSettingsTypeFieldPolicy = { + autoDownloadAheadLimit?: FieldPolicy | FieldReadFunction, autoDownloadNewChapters?: FieldPolicy | FieldReadFunction, backupInterval?: FieldPolicy | FieldReadFunction, backupPath?: FieldPolicy | FieldReadFunction, @@ -469,9 +470,11 @@ export type PartialSettingsTypeFieldPolicy = { downloadsPath?: FieldPolicy | FieldReadFunction, electronPath?: FieldPolicy | FieldReadFunction, excludeCompleted?: FieldPolicy | FieldReadFunction, + excludeEntryWithUnreadChapters?: FieldPolicy | FieldReadFunction, excludeNotStarted?: FieldPolicy | FieldReadFunction, excludeUnreadChapters?: FieldPolicy | FieldReadFunction, globalUpdateInterval?: FieldPolicy | FieldReadFunction, + gqlDebugLogsEnabled?: FieldPolicy | FieldReadFunction, initialOpenInBrowserEnabled?: FieldPolicy | FieldReadFunction, ip?: FieldPolicy | FieldReadFunction, localSourcePath?: FieldPolicy | FieldReadFunction, @@ -481,6 +484,7 @@ export type PartialSettingsTypeFieldPolicy = { socksProxyHost?: FieldPolicy | FieldReadFunction, socksProxyPort?: FieldPolicy | FieldReadFunction, systemTrayEnabled?: FieldPolicy | FieldReadFunction, + updateMangas?: FieldPolicy | FieldReadFunction, webUIChannel?: FieldPolicy | FieldReadFunction, webUIFlavor?: FieldPolicy | FieldReadFunction, webUIInterface?: FieldPolicy | FieldReadFunction, @@ -521,9 +525,10 @@ export type ResetSettingsPayloadFieldPolicy = { clientMutationId?: FieldPolicy | FieldReadFunction, settings?: FieldPolicy | FieldReadFunction }; -export type RestoreBackupPayloadKeySpecifier = ('clientMutationId' | 'status' | RestoreBackupPayloadKeySpecifier)[]; +export type RestoreBackupPayloadKeySpecifier = ('clientMutationId' | 'id' | 'status' | RestoreBackupPayloadKeySpecifier)[]; export type RestoreBackupPayloadFieldPolicy = { clientMutationId?: FieldPolicy | FieldReadFunction, + id?: FieldPolicy | FieldReadFunction, status?: FieldPolicy | FieldReadFunction }; export type SelectFilterKeySpecifier = ('default' | 'name' | 'values' | SelectFilterKeySpecifier)[]; @@ -561,8 +566,9 @@ export type SetSettingsPayloadFieldPolicy = { clientMutationId?: FieldPolicy | FieldReadFunction, settings?: FieldPolicy | FieldReadFunction }; -export type SettingsKeySpecifier = ('autoDownloadNewChapters' | 'backupInterval' | 'backupPath' | 'backupTTL' | 'backupTime' | 'basicAuthEnabled' | 'basicAuthPassword' | 'basicAuthUsername' | 'debugLogsEnabled' | 'downloadAsCbz' | 'downloadsPath' | 'electronPath' | 'excludeCompleted' | 'excludeNotStarted' | 'excludeUnreadChapters' | 'globalUpdateInterval' | 'initialOpenInBrowserEnabled' | 'ip' | 'localSourcePath' | 'maxSourcesInParallel' | 'port' | 'socksProxyEnabled' | 'socksProxyHost' | 'socksProxyPort' | 'systemTrayEnabled' | 'webUIChannel' | 'webUIFlavor' | 'webUIInterface' | 'webUIUpdateCheckInterval' | SettingsKeySpecifier)[]; +export type SettingsKeySpecifier = ('autoDownloadAheadLimit' | 'autoDownloadNewChapters' | 'backupInterval' | 'backupPath' | 'backupTTL' | 'backupTime' | 'basicAuthEnabled' | 'basicAuthPassword' | 'basicAuthUsername' | 'debugLogsEnabled' | 'downloadAsCbz' | 'downloadsPath' | 'electronPath' | 'excludeCompleted' | 'excludeEntryWithUnreadChapters' | 'excludeNotStarted' | 'excludeUnreadChapters' | 'globalUpdateInterval' | 'gqlDebugLogsEnabled' | 'initialOpenInBrowserEnabled' | 'ip' | 'localSourcePath' | 'maxSourcesInParallel' | 'port' | 'socksProxyEnabled' | 'socksProxyHost' | 'socksProxyPort' | 'systemTrayEnabled' | 'updateMangas' | 'webUIChannel' | 'webUIFlavor' | 'webUIInterface' | 'webUIUpdateCheckInterval' | SettingsKeySpecifier)[]; export type SettingsFieldPolicy = { + autoDownloadAheadLimit?: FieldPolicy | FieldReadFunction, autoDownloadNewChapters?: FieldPolicy | FieldReadFunction, backupInterval?: FieldPolicy | FieldReadFunction, backupPath?: FieldPolicy | FieldReadFunction, @@ -576,9 +582,11 @@ export type SettingsFieldPolicy = { downloadsPath?: FieldPolicy | FieldReadFunction, electronPath?: FieldPolicy | FieldReadFunction, excludeCompleted?: FieldPolicy | FieldReadFunction, + excludeEntryWithUnreadChapters?: FieldPolicy | FieldReadFunction, excludeNotStarted?: FieldPolicy | FieldReadFunction, excludeUnreadChapters?: FieldPolicy | FieldReadFunction, globalUpdateInterval?: FieldPolicy | FieldReadFunction, + gqlDebugLogsEnabled?: FieldPolicy | FieldReadFunction, initialOpenInBrowserEnabled?: FieldPolicy | FieldReadFunction, ip?: FieldPolicy | FieldReadFunction, localSourcePath?: FieldPolicy | FieldReadFunction, @@ -588,13 +596,15 @@ export type SettingsFieldPolicy = { socksProxyHost?: FieldPolicy | FieldReadFunction, socksProxyPort?: FieldPolicy | FieldReadFunction, systemTrayEnabled?: FieldPolicy | FieldReadFunction, + updateMangas?: FieldPolicy | FieldReadFunction, webUIChannel?: FieldPolicy | FieldReadFunction, webUIFlavor?: FieldPolicy | FieldReadFunction, webUIInterface?: FieldPolicy | FieldReadFunction, webUIUpdateCheckInterval?: FieldPolicy | FieldReadFunction }; -export type SettingsTypeKeySpecifier = ('autoDownloadNewChapters' | 'backupInterval' | 'backupPath' | 'backupTTL' | 'backupTime' | 'basicAuthEnabled' | 'basicAuthPassword' | 'basicAuthUsername' | 'debugLogsEnabled' | 'downloadAsCbz' | 'downloadsPath' | 'electronPath' | 'excludeCompleted' | 'excludeNotStarted' | 'excludeUnreadChapters' | 'globalUpdateInterval' | 'initialOpenInBrowserEnabled' | 'ip' | 'localSourcePath' | 'maxSourcesInParallel' | 'port' | 'socksProxyEnabled' | 'socksProxyHost' | 'socksProxyPort' | 'systemTrayEnabled' | 'webUIChannel' | 'webUIFlavor' | 'webUIInterface' | 'webUIUpdateCheckInterval' | SettingsTypeKeySpecifier)[]; +export type SettingsTypeKeySpecifier = ('autoDownloadAheadLimit' | 'autoDownloadNewChapters' | 'backupInterval' | 'backupPath' | 'backupTTL' | 'backupTime' | 'basicAuthEnabled' | 'basicAuthPassword' | 'basicAuthUsername' | 'debugLogsEnabled' | 'downloadAsCbz' | 'downloadsPath' | 'electronPath' | 'excludeCompleted' | 'excludeEntryWithUnreadChapters' | 'excludeNotStarted' | 'excludeUnreadChapters' | 'globalUpdateInterval' | 'gqlDebugLogsEnabled' | 'initialOpenInBrowserEnabled' | 'ip' | 'localSourcePath' | 'maxSourcesInParallel' | 'port' | 'socksProxyEnabled' | 'socksProxyHost' | 'socksProxyPort' | 'systemTrayEnabled' | 'updateMangas' | 'webUIChannel' | 'webUIFlavor' | 'webUIInterface' | 'webUIUpdateCheckInterval' | SettingsTypeKeySpecifier)[]; export type SettingsTypeFieldPolicy = { + autoDownloadAheadLimit?: FieldPolicy | FieldReadFunction, autoDownloadNewChapters?: FieldPolicy | FieldReadFunction, backupInterval?: FieldPolicy | FieldReadFunction, backupPath?: FieldPolicy | FieldReadFunction, @@ -608,9 +618,11 @@ export type SettingsTypeFieldPolicy = { downloadsPath?: FieldPolicy | FieldReadFunction, electronPath?: FieldPolicy | FieldReadFunction, excludeCompleted?: FieldPolicy | FieldReadFunction, + excludeEntryWithUnreadChapters?: FieldPolicy | FieldReadFunction, excludeNotStarted?: FieldPolicy | FieldReadFunction, excludeUnreadChapters?: FieldPolicy | FieldReadFunction, globalUpdateInterval?: FieldPolicy | FieldReadFunction, + gqlDebugLogsEnabled?: FieldPolicy | FieldReadFunction, initialOpenInBrowserEnabled?: FieldPolicy | FieldReadFunction, ip?: FieldPolicy | FieldReadFunction, localSourcePath?: FieldPolicy | FieldReadFunction, @@ -620,6 +632,7 @@ export type SettingsTypeFieldPolicy = { socksProxyHost?: FieldPolicy | FieldReadFunction, socksProxyPort?: FieldPolicy | FieldReadFunction, systemTrayEnabled?: FieldPolicy | FieldReadFunction, + updateMangas?: FieldPolicy | FieldReadFunction, webUIChannel?: FieldPolicy | FieldReadFunction, webUIFlavor?: FieldPolicy | FieldReadFunction, webUIInterface?: FieldPolicy | FieldReadFunction, diff --git a/src/lib/graphql/generated/graphql.ts b/src/lib/graphql/generated/graphql.ts index c8f5cb48..5f843c95 100644 --- a/src/lib/graphql/generated/graphql.ts +++ b/src/lib/graphql/generated/graphql.ts @@ -29,9 +29,11 @@ export type AboutPayload = { }; export enum BackupRestoreState { + Failure = 'FAILURE', Idle = 'IDLE', RestoringCategories = 'RESTORING_CATEGORIES', - RestoringManga = 'RESTORING_MANGA' + RestoringManga = 'RESTORING_MANGA', + Success = 'SUCCESS' } export type BackupRestoreStatus = { @@ -1216,6 +1218,7 @@ export type PageInfo = { export type PartialSettingsType = Settings & { __typename?: 'PartialSettingsType'; + autoDownloadAheadLimit?: Maybe; autoDownloadNewChapters?: Maybe; backupInterval?: Maybe; backupPath?: Maybe; @@ -1229,9 +1232,11 @@ export type PartialSettingsType = Settings & { downloadsPath?: Maybe; electronPath?: Maybe; excludeCompleted?: Maybe; + excludeEntryWithUnreadChapters?: Maybe; excludeNotStarted?: Maybe; excludeUnreadChapters?: Maybe; globalUpdateInterval?: Maybe; + gqlDebugLogsEnabled?: Maybe; initialOpenInBrowserEnabled?: Maybe; ip?: Maybe; localSourcePath?: Maybe; @@ -1241,6 +1246,7 @@ export type PartialSettingsType = Settings & { socksProxyHost?: Maybe; socksProxyPort?: Maybe; systemTrayEnabled?: Maybe; + updateMangas?: Maybe; webUIChannel?: Maybe; webUIFlavor?: Maybe; webUIInterface?: Maybe; @@ -1248,6 +1254,7 @@ export type PartialSettingsType = Settings & { }; export type PartialSettingsTypeInput = { + autoDownloadAheadLimit?: InputMaybe; autoDownloadNewChapters?: InputMaybe; backupInterval?: InputMaybe; backupPath?: InputMaybe; @@ -1261,9 +1268,11 @@ export type PartialSettingsTypeInput = { downloadsPath?: InputMaybe; electronPath?: InputMaybe; excludeCompleted?: InputMaybe; + excludeEntryWithUnreadChapters?: InputMaybe; excludeNotStarted?: InputMaybe; excludeUnreadChapters?: InputMaybe; globalUpdateInterval?: InputMaybe; + gqlDebugLogsEnabled?: InputMaybe; initialOpenInBrowserEnabled?: InputMaybe; ip?: InputMaybe; localSourcePath?: InputMaybe; @@ -1273,6 +1282,7 @@ export type PartialSettingsTypeInput = { socksProxyHost?: InputMaybe; socksProxyPort?: InputMaybe; systemTrayEnabled?: InputMaybe; + updateMangas?: InputMaybe; webUIChannel?: InputMaybe; webUIFlavor?: InputMaybe; webUIInterface?: InputMaybe; @@ -1299,7 +1309,7 @@ export type Query = { mangas: MangaNodeList; meta: GlobalMetaType; metas: GlobalMetaNodeList; - restoreStatus: BackupRestoreStatus; + restoreStatus?: Maybe; settings: SettingsType; source: SourceType; sources: SourceNodeList; @@ -1398,6 +1408,11 @@ export type QueryMetasArgs = { }; +export type QueryRestoreStatusArgs = { + id: Scalars['String']['input']; +}; + + export type QuerySourceArgs = { id: Scalars['LongString']['input']; }; @@ -1450,7 +1465,8 @@ export type RestoreBackupInput = { export type RestoreBackupPayload = { __typename?: 'RestoreBackupPayload'; clientMutationId?: Maybe; - status: BackupRestoreStatus; + id: Scalars['String']['output']; + status?: Maybe; }; export type SelectFilter = { @@ -1521,6 +1537,7 @@ export type SetSettingsPayload = { }; export type Settings = { + autoDownloadAheadLimit?: Maybe; autoDownloadNewChapters?: Maybe; backupInterval?: Maybe; backupPath?: Maybe; @@ -1534,9 +1551,11 @@ export type Settings = { downloadsPath?: Maybe; electronPath?: Maybe; excludeCompleted?: Maybe; + excludeEntryWithUnreadChapters?: Maybe; excludeNotStarted?: Maybe; excludeUnreadChapters?: Maybe; globalUpdateInterval?: Maybe; + gqlDebugLogsEnabled?: Maybe; initialOpenInBrowserEnabled?: Maybe; ip?: Maybe; localSourcePath?: Maybe; @@ -1546,6 +1565,7 @@ export type Settings = { socksProxyHost?: Maybe; socksProxyPort?: Maybe; systemTrayEnabled?: Maybe; + updateMangas?: Maybe; webUIChannel?: Maybe; webUIFlavor?: Maybe; webUIInterface?: Maybe; @@ -1554,6 +1574,7 @@ export type Settings = { export type SettingsType = Settings & { __typename?: 'SettingsType'; + autoDownloadAheadLimit: Scalars['Int']['output']; autoDownloadNewChapters: Scalars['Boolean']['output']; backupInterval: Scalars['Int']['output']; backupPath: Scalars['String']['output']; @@ -1567,9 +1588,11 @@ export type SettingsType = Settings & { downloadsPath: Scalars['String']['output']; electronPath: Scalars['String']['output']; excludeCompleted: Scalars['Boolean']['output']; + excludeEntryWithUnreadChapters: Scalars['Boolean']['output']; excludeNotStarted: Scalars['Boolean']['output']; excludeUnreadChapters: Scalars['Boolean']['output']; globalUpdateInterval: Scalars['Float']['output']; + gqlDebugLogsEnabled: Scalars['Boolean']['output']; initialOpenInBrowserEnabled: Scalars['Boolean']['output']; ip: Scalars['String']['output']; localSourcePath: Scalars['String']['output']; @@ -1579,6 +1602,7 @@ export type SettingsType = Settings & { socksProxyHost: Scalars['String']['output']; socksProxyPort: Scalars['String']['output']; systemTrayEnabled: Scalars['Boolean']['output']; + updateMangas: Scalars['Boolean']['output']; webUIChannel: WebUiChannel; webUIFlavor: WebUiFlavor; webUIInterface: WebUiInterface; @@ -2098,7 +2122,7 @@ export type RestoreBackupMutationVariables = Exact<{ }>; -export type RestoreBackupMutation = { __typename?: 'Mutation', restoreBackup: { __typename?: 'RestoreBackupPayload', clientMutationId?: string | null, status: { __typename?: 'BackupRestoreStatus', mangaProgress: number, state: BackupRestoreState, totalManga: number } } }; +export type RestoreBackupMutation = { __typename?: 'Mutation', restoreBackup: { __typename?: 'RestoreBackupPayload', clientMutationId?: string | null, id: string, status?: { __typename?: 'BackupRestoreStatus', mangaProgress: number, state: BackupRestoreState, totalManga: number } | null } }; export type CreateCategoryMutationVariables = Exact<{ input: CreateCategoryInput; @@ -2415,10 +2439,12 @@ export type ValidateBackupQueryVariables = Exact<{ export type ValidateBackupQuery = { __typename?: 'Query', validateBackup: { __typename?: 'ValidateBackupResult', missingSources: Array<{ __typename?: 'ValidateBackupSource', id: any, name: string }> } }; -export type GetRestoreStatusQueryVariables = Exact<{ [key: string]: never; }>; +export type GetRestoreStatusQueryVariables = Exact<{ + id: Scalars['String']['input']; +}>; -export type GetRestoreStatusQuery = { __typename?: 'Query', restoreStatus: { __typename?: 'BackupRestoreStatus', mangaProgress: number, state: BackupRestoreState, totalManga: number } }; +export type GetRestoreStatusQuery = { __typename?: 'Query', restoreStatus?: { __typename?: 'BackupRestoreStatus', mangaProgress: number, state: BackupRestoreState, totalManga: number } | null }; export type GetCategoriesQueryVariables = Exact<{ after?: InputMaybe; diff --git a/src/lib/graphql/mutations/BackupMutation.ts b/src/lib/graphql/mutations/BackupMutation.ts index da09b9b1..a7c05ba6 100644 --- a/src/lib/graphql/mutations/BackupMutation.ts +++ b/src/lib/graphql/mutations/BackupMutation.ts @@ -21,6 +21,7 @@ export const RESTORE_BACKUP = gql` mutation RESTORE_BACKUP($backup: Upload!) { restoreBackup(input: { backup: $backup }) { clientMutationId + id status { mangaProgress state diff --git a/src/lib/graphql/queries/BackupQuery.ts b/src/lib/graphql/queries/BackupQuery.ts index 028f815b..b0927045 100644 --- a/src/lib/graphql/queries/BackupQuery.ts +++ b/src/lib/graphql/queries/BackupQuery.ts @@ -20,8 +20,8 @@ export const VALIDATE_BACKUP = gql` `; export const GET_RESTORE_STATUS = gql` - query GET_RESTORE_STATUS { - restoreStatus { + query GET_RESTORE_STATUS($id: String!) { + restoreStatus(id: $id) { mangaProgress state totalManga diff --git a/src/lib/requests/RequestManager.ts b/src/lib/requests/RequestManager.ts index b6f0004c..49d51228 100644 --- a/src/lib/requests/RequestManager.ts +++ b/src/lib/requests/RequestManager.ts @@ -1596,9 +1596,10 @@ export class RequestManager { } public useGetBackupRestoreStatus( + id: string, options?: QueryHookOptions, ): AbortableApolloUseQueryResponse { - return this.doRequest(GQLMethod.USE_QUERY, GET_RESTORE_STATUS, undefined, options); + return this.doRequest(GQLMethod.USE_QUERY, GET_RESTORE_STATUS, { id }, options); } public getExportBackupUrl(): string { diff --git a/src/screens/settings/Backup.tsx b/src/screens/settings/Backup.tsx index 6e2273aa..44426c67 100644 --- a/src/screens/settings/Backup.tsx +++ b/src/screens/settings/Backup.tsx @@ -6,7 +6,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { useContext, useEffect, useRef, useState } from 'react'; +import { useContext, useEffect, useState } from 'react'; import List from '@mui/material/List'; import ListItemText from '@mui/material/ListItemText'; import { fromEvent } from 'file-selector'; @@ -17,9 +17,11 @@ import { requestManager } from '@/lib/requests/RequestManager.ts'; import { makeToast } from '@/components/util/Toast'; import { ListItemLink } from '@/components/util/ListItemLink'; import { NavBarContext, useSetDefaultBackTo } from '@/components/context/NavbarContext'; -import { BackupRestoreState, GetRestoreStatusQuery } from '@/lib/graphql/generated/graphql.ts'; +import { BackupRestoreState } from '@/lib/graphql/generated/graphql.ts'; import { Progress } from '@/components/util/Progress.tsx'; +let backupRestoreId: string | undefined; + export function Backup() { const { t } = useTranslation(); const { setTitle, setAction } = useContext(NavBarContext); @@ -30,15 +32,15 @@ export function Backup() { useSetDefaultBackTo('settings'); - const [isRestoring, setIsRestoring] = useState(null); - const { data } = requestManager.useGetBackupRestoreStatus({ - skip: isRestoring !== null ? !isRestoring : false, + const { data } = requestManager.useGetBackupRestoreStatus(backupRestoreId ?? '', { + skip: !backupRestoreId, pollInterval: 1000, }); - const prevRestoreStatusRef = useRef(null); + + const [, setTriggerReRender] = useState(0); const restoreProgress = (() => { - if (!isRestoring || !data) { + if (!data?.restoreStatus) { return 0; } @@ -47,37 +49,36 @@ export function Backup() { })(); useEffect(() => { - if (!data || isRestoring !== null) { + if (!data?.restoreStatus) { return; } - const isRestoreInProgress = data?.restoreStatus.state !== BackupRestoreState.Idle; - setIsRestoring(isRestoreInProgress); - }, [data?.restoreStatus.state]); + const isSuccess = data.restoreStatus.state === BackupRestoreState.Success; + const isFailure = data.restoreStatus.state === BackupRestoreState.Failure; - useEffect(() => { - if (!data) { - return; - } - - const isRestoreFinished = - isRestoring && - data.restoreStatus.mangaProgress === data.restoreStatus.totalManga && - prevRestoreStatusRef.current?.state !== BackupRestoreState.Idle; + const isRestoreFinished = isSuccess || isFailure; if (isRestoreFinished) { - setIsRestoring(false); - makeToast(t('settings.backup.label.restored_backup'), 'success'); + if (isSuccess) { + makeToast(t('settings.backup.label.restored_backup'), 'success'); + } + + if (isFailure) { + makeToast(t('settings.backup.label.backup_restore_failed'), 'error'); + } + + backupRestoreId = undefined; + setTriggerReRender(Date.now()); } - prevRestoreStatusRef.current = data.restoreStatus; - }, [data?.restoreStatus.state]); + }, [data?.restoreStatus?.state]); const submitBackup = async (file: File) => { if (file.name.toLowerCase().match(/proto\.gz$|tachibk$/g)) { makeToast(t('settings.backup.label.restoring_backup'), 'info'); try { - await requestManager.restoreBackupFile(file).response; - setIsRestoring(true); + const response = await requestManager.restoreBackupFile(file).response; + backupRestoreId = response.data?.restoreBackup.id; + setTriggerReRender(Date.now()); } catch (e) { makeToast(t('settings.backup.label.backup_restore_failed'), 'error'); } @@ -129,13 +130,13 @@ export function Backup() { document.getElementById('backup-file')?.click()} - disabled={!!isRestoring} + disabled={!!backupRestoreId} > - {isRestoring ? ( + {backupRestoreId ? ( diff --git a/versionToServerVersionMapping.json b/versionToServerVersionMapping.json index 733bcb23..80ef0844 100644 --- a/versionToServerVersionMapping.json +++ b/versionToServerVersionMapping.json @@ -1,6 +1,6 @@ [ { "uiVersion": "PREVIEW", - "serverVersion": "r1353" + "serverVersion": "r1410" } ]