Skip to content

Commit ce3066c

Browse files
committed
reset app command
1 parent fe16e31 commit ce3066c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

frontend/src/components/CommandCenter.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
openChangeEmailDialog,
1111
openDeleteAccountDialog,
1212
removeAllSessions,
13+
resetApp,
1314
} from '../state/user'
1415
import {hostingMode} from '../config'
1516
import {selectCommandCenterDisabled, setCommandCenterOpen, useSelector} from '../state/store'
@@ -215,6 +216,11 @@ export const CommandCenter = () => {
215216
label: 'Third Party Licenses',
216217
onClick: () => window.open('/licenses.html', '_blank'),
217218
},
219+
{
220+
id: 'resetApp',
221+
label: 'Reset App (delete all local data)',
222+
onClick: resetApp,
223+
},
218224
]
219225

220226
const enabledCommands = commands.filter((c) => !c.disabled)

frontend/src/state/user.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {syncNotes} from './notes'
2323
import {Feature} from '../business/models'
2424
import {parseSubscriptionToken} from '../business/misc'
2525
import {hostingMode} from '../config'
26+
import {openConfirmModalWithBackHandler} from '../helpers/openConfirmModal'
2627

2728
export type UserState = {
2829
user: {
@@ -732,6 +733,22 @@ export const removeAllSessions = async () => {
732733
}
733734
}
734735

736+
export const resetApp = () =>
737+
openConfirmModalWithBackHandler({
738+
id: 'resetApp',
739+
title: 'Reset App',
740+
children: 'Are you sure you want to delete all local data?',
741+
labels: {
742+
confirm: 'Reset',
743+
cancel: 'Cancel',
744+
},
745+
onConfirm: async () => {
746+
await db.delete()
747+
localStorage.clear()
748+
window.location.reload()
749+
},
750+
})
751+
735752
// subscriptions
736753
export const registerUserSubscriptions = () => {
737754
subscribe(

0 commit comments

Comments
 (0)