Skip to content

Commit 0a247da

Browse files
committed
Reload and clear data bjuttons.
1 parent 6ba2a75 commit 0a247da

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

frontend/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "localib",
33
"description": "Collects your Discogs library for offline usage",
44
"private": true,
5-
"version": "0.1.4",
5+
"version": "0.1.5",
66
"type": "module",
77
"scripts": {
88
"dev": "vite",

frontend/src/modal/Settings.tsx

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import {
1414
IonInputPasswordToggle,
1515
IonLabel,
1616
IonPopover,
17+
IonCol,
18+
IonGrid,
19+
IonRow,
20+
IonAlert,
1721
} from "@ionic/react"
1822
import { useQueryClient } from "@tanstack/react-query"
1923
import { useAuth } from "../hooks"
@@ -47,7 +51,7 @@ const Settings: React.FC<Props> = ({ open, hasUpdate, onClose, onSave }) => {
4751

4852
const handleSave = () => {
4953
saveAuth(newUsername, newPassword)
50-
queryClient.invalidateQueries()
54+
queryClient.clear()
5155
onSave()
5256
}
5357

@@ -57,6 +61,12 @@ const Settings: React.FC<Props> = ({ open, hasUpdate, onClose, onSave }) => {
5761
}
5862
}
5963

64+
const deleteData = () => {
65+
saveAuth("", "")
66+
queryClient.clear()
67+
window.location.reload()
68+
}
69+
6070
const collection = queryClient.getQueryData<IReleases[]>([`${username}collection`])
6171
const wanted = queryClient.getQueryData<IReleases[]>([`${username}want`])
6272
const collectionMissing = collection?.filter((obj) => obj.image_base64 === undefined).length ?? 0
@@ -161,6 +171,35 @@ const Settings: React.FC<Props> = ({ open, hasUpdate, onClose, onSave }) => {
161171
For some records, we need to collect further information from the Discogs system. This can take some
162172
time, so try reloading in a few hours to see it change.
163173
</IonNote>
174+
<IonGrid>
175+
<IonRow class="ion-justify-content-center">
176+
<IonCol size="auto">
177+
<IonButton onClick={handleUpdate} color="primary">
178+
Reload app
179+
</IonButton>
180+
</IonCol>
181+
<IonCol size="auto">
182+
<IonButton id="present-alert" color="danger">
183+
Remove data
184+
</IonButton>
185+
</IonCol>
186+
</IonRow>
187+
</IonGrid>
188+
<IonAlert
189+
header="This will remove your account and stored data. Are you sure?"
190+
trigger="present-alert"
191+
buttons={[
192+
{
193+
text: "Cancel",
194+
role: "cancel",
195+
},
196+
{
197+
text: "Delete",
198+
role: "confirm",
199+
handler: deleteData,
200+
},
201+
]}
202+
/>
164203
<br />
165204
<IonNote color="medium" class="ion-margin-horizontal" style={{ display: "block", textAlign: "center" }}>
166205
Made by <a href="https://subo.dev">soup-bowl</a> and{" "}

0 commit comments

Comments
 (0)