diff --git a/src/pages/DataSettings.tsx b/src/pages/DataSettings.tsx index 133332d3..8b1fcebe 100644 --- a/src/pages/DataSettings.tsx +++ b/src/pages/DataSettings.tsx @@ -1,11 +1,10 @@ import { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; -import { Download, Trash2, AlertTriangle, Loader2, Database, HardDrive, Info } from 'lucide-react'; +import { Download, Trash2, AlertTriangle, Loader2, Database, Info } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from '@/components/ui/alert-dialog'; import { Progress } from '@/components/ui/progress'; -import { Badge } from '@/components/ui/badge'; import { useToast } from '@/hooks/useToast'; import { useFS } from '@/hooks/useFS'; import JSZip from 'jszip'; @@ -21,7 +20,6 @@ interface StorageInfo { quota: number; usage: number; usageDetails?: StorageUsageDetails; - isPersistent?: boolean; } export function DataSettings() { @@ -55,14 +53,6 @@ export function DataSettings() { // Get storage estimate const estimate = await navigator.storage.estimate(); - // Get persistence status - let isPersistent = false; - try { - isPersistent = await navigator.storage.persisted(); - } catch (error) { - console.warn('Failed to check persistence status:', error); - } - // Extract usage details safely const usageDetails: StorageUsageDetails | undefined = (estimate as StorageEstimate & { usageDetails?: StorageUsageDetails }).usageDetails; @@ -70,7 +60,6 @@ export function DataSettings() { quota: estimate.quota || 0, usage: estimate.usage || 0, usageDetails, - isPersistent, }); } catch (error) { console.error('Failed to get storage information:', error); @@ -211,112 +200,44 @@ export function DataSettings() { Data

- Export your projects or clear all local data from this browser. + Export files and manage local data.

{/* Storage Information */} - - - - - Storage Usage - - - Information about local storage usage in this browser. - - - - {storageError ? ( -
- - {storageError} + {storageError ? ( +
+ + {storageError} +
+ ) : storageInfo ? ( +
+ {/* Usage Progress */} +
+
+ Used: {formatBytes(storageInfo.usage)} + Available: {formatBytes(storageInfo.quota)}
- ) : storageInfo ? ( -
- {/* Usage Progress */} -
-
- Used: {formatBytes(storageInfo.usage)} - Available: {formatBytes(storageInfo.quota)} -
- 0 ? (storageInfo.usage / storageInfo.quota) * 100 : 0} - className="h-2" - /> -
- {storageInfo.quota > 0 - ? `${((storageInfo.usage / storageInfo.quota) * 100).toFixed(1)}% used` - : 'Usage percentage unavailable' - } -
-
+ 0 ? (storageInfo.usage / storageInfo.quota) * 100 : 0} + className="h-2" + /> +
+ {storageInfo.quota > 0 + ? `${((storageInfo.usage / storageInfo.quota) * 100).toFixed(1)}% used` + : 'Usage percentage unavailable' + } +
+
- {/* Storage Details */} -
-
-

Storage Details

-
-
- Total Used: - {formatBytes(storageInfo.usage)} -
-
- Available: - {formatBytes(storageInfo.quota)} -
- {storageInfo.usageDetails && ( - <> - {storageInfo.usageDetails.indexedDB !== undefined && ( -
- IndexedDB: - {formatBytes(storageInfo.usageDetails.indexedDB)} -
- )} - {storageInfo.usageDetails.caches !== undefined && ( -
- Cache: - {formatBytes(storageInfo.usageDetails.caches)} -
- )} - {storageInfo.usageDetails.serviceWorkerRegistrations !== undefined && ( -
- Service Workers: - {formatBytes(storageInfo.usageDetails.serviceWorkerRegistrations)} -
- )} - - )} -
-
- -
-

Storage Status

-
-
- - {storageInfo.isPersistent ? "Persistent" : "Not Persistent"} - -
-

- {storageInfo.isPersistent - ? "Data is protected from eviction by the browser." - : "Data may be cleared by the browser when storage is low." - } -

-
-
-
-
- ) : ( -
- - Loading storage information... -
- )} - - +
+ ) : ( +
+ + Loading storage information... +
+ )} {/* Export Files */}