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).
This commit is contained in:
jakob.scheid authored and Gitea committed 2026-08-06 12:50:33 +02:00
1 parent ff6ab7a78c
commit 04c148a3b1
4 files changed
+82 -48

No files matched your search

@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { useSettingsConfigCacheStore } from '../stores/settingsConfigCacheStore';
import { useSettingsStore } from '../stores/settingsStore';
import { getSettingRecursively } from '../utils/getSetting';
import { loadSettingsConfig } from '../utils/settingsParser';
@@ -27,10 +28,10 @@ export const useSettings = function useSettings () {
* @param {string[]} key - The settings key.
* @return The value of the setting.
*/
const getSetting = async function getSetting (key) {
const getSetting = function getSetting (key) {
const settingsStore = useSettingsStore();
const settings = await loadSettingsConfig();
const settings = useSettingsConfigCacheStore().get();
return (
settingsStore.get(key) ??
getSettingRecursively(