Skip to content

A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.

fix: backup and restore success toast box appears twice.

towfiqicc2a1e6c628c
diff --git a/frontend/src/services/backups.ts b/frontend/src/services/backups.ts
index b5f1407..032e569 100644
--- a/frontend/src/services/backups.ts
+++ b/frontend/src/services/backups.ts
@@ -2,6 +2,8 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { toast } from 'react-toastify';
import { API_URL } from '../utils/constants';
+const notifiedBackupProgress = new Set<string>();
+
// Generate Download
export async function generateBackupDownload({ backupId }: { backupId: string; planId: string }) {
// const header = new Headers({ 'Content-Type': 'application/json', Accept: 'application/json' });
@@ -161,11 +163,14 @@ export function useGetBackupProgress(payload: { id: string; sourceId: string; so
if (isFinished) {
const planId = progressData?.planId || payload.planId;
- if (planId) {
- console.log('Invalidate Plan and Reload It :', planId);
- queryClient.invalidateQueries({ queryKey: ['plan', planId] });
+ if (!notifiedBackupProgress.has(payload.id)) {
+ notifiedBackupProgress.add(payload.id);
+ if (planId) {
+ console.log('Invalidate Plan and Reload It :', planId);
+ queryClient.invalidateQueries({ queryKey: ['plan', planId] });
+ }
+ toast.success('Process Complete!');
}
- toast.success('Process Complete!');
return false;
}
diff --git a/frontend/src/services/restores.ts b/frontend/src/services/restores.ts
index 1114ce4..14793e3 100644
--- a/frontend/src/services/restores.ts
+++ b/frontend/src/services/restores.ts
@@ -2,6 +2,8 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { toast } from 'react-toastify';
import { API_URL } from '../utils/constants';
+const notifiedRestoreProgress = new Set<string>();
+
// Get All Restores
export async function getAllRestores() {
const url = new URL(`${API_URL}/restores`);
@@ -239,11 +241,14 @@ export function useGetRestoreProgress(payload: { id: string; sourceId: string; s
if (isFinished) {
const planId = progressData?.planId || payload.planId;
- if (planId) {
- console.log('Invalidate Plan and Reload It :', planId);
- queryClient.invalidateQueries({ queryKey: ['plan', planId] });
+ if (!notifiedRestoreProgress.has(payload.id)) {
+ notifiedRestoreProgress.add(payload.id);
+ if (planId) {
+ console.log('Invalidate Plan and Reload It :', planId);
+ queryClient.invalidateQueries({ queryKey: ['plan', planId] });
+ }
+ toast.success('Restoration Complete!');
}
- toast.success('Restoration Complete!');
return false;
}