Skip to content

Commit cfad19b

Browse files
committed
Show alert after confirmation, not before.
1 parent 37a081a commit cfad19b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

frontend/src/pages/Settings.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const SettingsPage: React.FC<{ hasUpdate: boolean; onUpdate: () => void }> = ({
4040
const [storageInfo, setStorageInfo] = useState<{ usage: string; quota: string } | undefined>()
4141
const [imageQuality, setImageQuality, clearImagequality] = useSettings<boolean>("ImagesAreHQ", false)
4242
const [deviceTheme, setDeviceTheme] = useSettings<DeviceMode>("DeviceTheme", "ios")
43+
const [restartAlert, setRestartAlert] = useState<boolean>(false)
4344
const appVersion = import.meta.env.VITE_VER ?? "Unknown"
4445
const ionConfig = getConfig()
4546
const currentMode = ionConfig?.get("mode") || "ios"
@@ -135,11 +136,13 @@ const SettingsPage: React.FC<{ hasUpdate: boolean; onUpdate: () => void }> = ({
135136
<IonList inset={true}>
136137
<IonItem color={lightMode}>
137138
<IonSelect
138-
id="changed-theme"
139139
label="Theme mode"
140140
interface="action-sheet"
141141
value={deviceTheme}
142-
onIonChange={(e) => setDeviceTheme(e.detail.value)}
142+
onIonChange={(e) => {
143+
setDeviceTheme(e.detail.value)
144+
setRestartAlert(true)
145+
}}
143146
>
144147
<IonSelectOption value="ios">Apple</IonSelectOption>
145148
<IonSelectOption value="md">Android (beta)</IonSelectOption>
@@ -226,9 +229,10 @@ const SettingsPage: React.FC<{ hasUpdate: boolean; onUpdate: () => void }> = ({
226229
]}
227230
/>
228231
<IonAlert
229-
trigger="changed-theme"
232+
isOpen={restartAlert}
233+
onDidDismiss={() => setRestartAlert(false)}
230234
header="Reload required"
231-
message="For changes to take effect, you will need to reload the app."
235+
message="For these changes to take effect, you will need to reload the app."
232236
buttons={["OK"]}
233237
/>
234238
<IonNote color="medium" class="ion-margin-horizontal" style={{ display: "block", textAlign: "center" }}>

0 commit comments

Comments
 (0)