Improve performance of setttings toggles

I was awaiting the result of the sqlite operations
when really I should have just set the state immediately,
and done the operations in the background.
This commit is contained in:
Brandon Presley 2022-12-30 20:37:08 +13:00
parent e51aad21f3
commit 3fdc5900e3
1 changed files with 2 additions and 2 deletions

View File

@ -79,8 +79,8 @@ export default function SettingsPage() {
const changeString = useCallback(
async (key: keyof Settings, value: string) => {
await settingsRepo.save({...settings, [key]: value})
setValue(key, value)
await settingsRepo.save({...settings, [key]: value})
switch (key) {
case 'date':
return toast('Changed date format')
@ -107,8 +107,8 @@ export default function SettingsPage() {
const changeBoolean = useCallback(
async (key: keyof Settings, value: boolean) => {
await settingsRepo.save({...settings, [key]: value})
setValue(key, value)
await settingsRepo.save({...settings, [key]: value})
switch (key) {
case 'alarm':
if (value) toast('Timers will now run after each set.')