diff --git a/src/pages/settings/Settings.tsx b/src/pages/settings/Settings.tsx
index 77f6ea4..64c47d0 100644
--- a/src/pages/settings/Settings.tsx
+++ b/src/pages/settings/Settings.tsx
@@ -1,5 +1,6 @@
import AccountCircleIcon from '@mui/icons-material/AccountCircle'
import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos'
+import CachedIcon from '@mui/icons-material/Cached'
import RouterIcon from '@mui/icons-material/Router'
import { useTheme } from '@mui/material'
import List from '@mui/material/List'
@@ -80,6 +81,16 @@ export const SettingsPage = () => {
{listItem('Relays')}
+ {
+ navigate(appPrivateRoutes.cacheSettings)
+ }}
+ >
+
+
+
+ {listItem('Local Cache')}
+
)
}
diff --git a/src/pages/settings/cache/index.tsx b/src/pages/settings/cache/index.tsx
new file mode 100644
index 0000000..8ac1e39
--- /dev/null
+++ b/src/pages/settings/cache/index.tsx
@@ -0,0 +1,96 @@
+import ClearIcon from '@mui/icons-material/Clear'
+import InputIcon from '@mui/icons-material/Input'
+import IosShareIcon from '@mui/icons-material/IosShare'
+import {
+ List,
+ ListItemButton,
+ ListItemIcon,
+ ListItemText,
+ ListSubheader,
+ useTheme
+} from '@mui/material'
+import { useState } from 'react'
+import { toast } from 'react-toastify'
+import { localCache } from '../../../services'
+import { LoadingSpinner } from '../../../components/LoadingSpinner'
+
+export const CacheSettingsPage = () => {
+ const theme = useTheme()
+
+ const [isLoading, setIsLoading] = useState(false)
+ const [loadingSpinnerDesc, setLoadingSpinnerDesc] = useState('')
+
+ const handleClearData = async () => {
+ setIsLoading(true)
+ setLoadingSpinnerDesc('Clearing cache data')
+ localCache
+ .clearCacheData()
+ .then(() => {
+ toast.success('cleared cached data')
+ })
+ .catch((err) => {
+ console.log('An error occurred in clearing cache data', err)
+ toast.error(err.message || 'An error occurred in clearing cache data')
+ })
+ .finally(() => {
+ setIsLoading(false)
+ })
+ }
+
+ const listItem = (label: string) => {
+ return (
+
+ )
+ }
+
+ return (
+ <>
+ {isLoading && }
+
+ Cache Setting
+
+ }
+ >
+
+
+
+
+ {listItem('Export (coming soon)')}
+
+
+
+
+
+
+ {listItem('Import (coming soon)')}
+
+
+
+
+
+
+ {listItem('Clear Cache')}
+
+
+ >
+ )
+}
diff --git a/src/routes/index.tsx b/src/routes/index.tsx
index 358b12d..b6b9baf 100644
--- a/src/routes/index.tsx
+++ b/src/routes/index.tsx
@@ -4,6 +4,7 @@ import { LandingPage } from '../pages/landing/LandingPage'
import { Login } from '../pages/login'
import { ProfilePage } from '../pages/profile'
import { SettingsPage } from '../pages/settings/Settings'
+import { CacheSettingsPage } from '../pages/settings/cache'
import { ProfileSettingsPage } from '../pages/settings/profile'
import { RelaysPage } from '../pages/settings/relays'
import { SignPage } from '../pages/sign'
@@ -17,6 +18,7 @@ export const appPrivateRoutes = {
verify: '/verify',
settings: '/settings',
profileSettings: '/settings/profile/:npub',
+ cacheSettings: '/settings/cache',
relays: '/settings/relays'
}
@@ -75,6 +77,10 @@ export const privateRoutes = [
path: appPrivateRoutes.profileSettings,
element:
},
+ {
+ path: appPrivateRoutes.cacheSettings,
+ element:
+ },
{
path: appPrivateRoutes.relays,
element:
diff --git a/src/services/cache/index.ts b/src/services/cache/index.ts
index 694c593..3fc8de0 100644
--- a/src/services/cache/index.ts
+++ b/src/services/cache/index.ts
@@ -48,6 +48,15 @@ class LocalCache {
public async deleteUserMetadata(key: string) {
await this.db.delete('userMetadata', key)
}
+
+ // Method to clear cache data
+ public async clearCacheData() {
+ // Clear the 'userMetadata' store in the IndexedDB database
+ await this.db.clear('userMetadata')
+
+ // Reload the current page to ensure any cached data is reset
+ window.location.reload()
+ }
}
// Export the single instance of LocalCache