feat: make settings typed and store "12" and "24" over "12-hour" and "24-hour" internally

This commit is contained in:
Twig 2025-07-12 22:39:26 +02:00
parent eb49450756
commit 195322f3b0
No known key found for this signature in database
5 changed files with 32 additions and 11 deletions

View file

@ -24,14 +24,14 @@
<p class="subtitle">TIME FORMAT</p>
<div class="icons">
<RadioButtons :button-count="3" :text-strings="timeFormatTextStrings"
:default-button-index="settingLoad('timeFormat')?.index ?? 0" :callback="onTimeFormatClicked"></RadioButtons>
:default-button-index="settingsLoad().timeFormat?.index ?? 0" :callback="onTimeFormatClicked"></RadioButtons>
</div>
</div>
</template>
<script lang="ts" setup>
import RadioButtons from '~/components/UserInterface/RadioButtons.vue';
import VerticalSpacer from '~/components/UserInterface/VerticalSpacer.vue';
import type { TimeFormat } from '~/types/settings';
import settingSave from '~/utils/settingSave';
const runtimeConfig = useRuntimeConfig()
@ -79,7 +79,18 @@ async function fetchThemes() {
await fetchThemes()
async function onTimeFormatClicked(index: number) {
settingSave("timeFormat", {index, timeFormat: timeFormatTextStrings[index].toLowerCase()})
let format: "auto" | "12" | "24" = "auto"
if (index == 0) {
format = "auto"
} else if (index == 1) {
format = "12"
} else if (index == 2) {
format = "24"
}
const timeFormat: TimeFormat = {index, format}
settingSave("timeFormat", timeFormat)
}
</script>