4 Commits
Author SHA1 Message Date
jakob.scheidandGitea 6fa9206258 test(settings): add test cases for empty setting value return value 2026-08-06 12:49:51 +02:00
jakob.scheidandGitea 623b162cc6 feat(settings): make setting value function synchronous
Added a store to cache the settings configuration. The getSetting
function from useSettings is now synchronous and uses this cache.
The settings cache is set when loading the settings initially
(asnychronously).
2026-08-06 12:49:51 +02:00
jakob.scheidandGitea 098d54521d test(settings): add tests for useSettings composable
Added some tests for the getSetting function from the useSettings
composable.
2026-08-06 12:49:51 +02:00
jakob.scheidandGitea c1986d9c2b feat(settings): add composable for settings values
Added the composable useSettings that provides the function getSetting.
This function returns the set value of the setting, or otherwise the
default value. If there is no default value, it returns undefined.
2026-08-06 12:49:51 +02:00
2 changed files with 2 additions and 13 deletions
+1 -2
View File
@@ -26,7 +26,7 @@ import { useRoute } from 'vue-router';
const route = useRoute(); const route = useRoute();
const { getColorScheme, updateColorScheme } = useColorScheme(); const { getColorScheme, updateColorScheme } = useColorScheme();
const colorScheme = ref(null); const colorScheme = ref(getColorScheme());
provide('colorScheme', colorScheme); provide('colorScheme', colorScheme);
watch(colorScheme, (newValue) => { watch(colorScheme, (newValue) => {
updateColorScheme(newValue); updateColorScheme(newValue);
@@ -46,7 +46,6 @@ watch(colorScheme, (newValue) => {
document.body.classList.remove('color-scheme-auto'); document.body.classList.remove('color-scheme-auto');
} }
}); });
colorScheme.value = getColorScheme();
watchEffect(() => updatePageTitle(route)); watchEffect(() => updatePageTitle(route));
</script> </script>
@@ -40,15 +40,5 @@ export const useSettings = function useSettings () {
); );
}; };
/** return { getSetting };
* Sets the value of a specific setting.
* @param {string[]} key - The setting key.
* @param value - The new value for the setting.
*/
const setSetting = function setSetting (key, value) {
const settingsStore = useSettingsStore();
settingsStore.set(key.join('.'), value);
};
return { getSetting, setSetting };
}; };