diff options
Diffstat (limited to 'components')
-rw-r--r-- | components/preferencesContext.tsx | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/components/preferencesContext.tsx b/components/preferencesContext.tsx index 3a930af..6b7914f 100644 --- a/components/preferencesContext.tsx +++ b/components/preferencesContext.tsx @@ -27,14 +27,16 @@ export function PreferencesContextWrapper(props: { children?: ReactNode }) { applyPreferences(local_prefs_json); } - var preferencesReq = await axios.request<{ preferences: userPreferences; }>({ - method: "get", - url: `/api/user/preferences`, - headers: {"content-type": "application/json"} - }); + if (!preferences) { + var preferencesReq = await axios.request<{ preferences: userPreferences; }>({ + method: "get", + url: `/api/user/preferences`, + headers: {"content-type": "application/json"} + }); - window.localStorage.setItem("preferences", JSON.stringify(preferencesReq.data.preferences)); - setPreferences(preferencesReq.data.preferences); + window.localStorage.setItem("preferences", JSON.stringify(preferencesReq.data.preferences)); + setPreferences(preferencesReq.data.preferences); + } setGotData(true); })()}); |