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:
2026-08-06 12:50:33 +02:00
committed by Gitea
parent ff6ab7a78c
commit 04c148a3b1
4 changed files with 82 additions and 48 deletions
@@ -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(