diff --git a/ayanova/src/api/initialize.js b/ayanova/src/api/initialize.js index e23578ea..2ec85e6b 100644 --- a/ayanova/src/api/initialize.js +++ b/ayanova/src/api/initialize.js @@ -753,60 +753,58 @@ function initNavPanel() { addNavItem(t("Logout"), "fa-sign-out-alt", "/login", [], key++, "logout"); } -function getUserOptions() { - return ( - window.$gz.api - .get("user-option/" + window.$gz.store.state.userId) - // eslint-disable-next-line - .then((res) => { - if (res.error) { - //In a form this would trigger a bunch of validation or error display code but for here and now: - //convert error to human readable string for display and popup a notification to user - let msg = window.$gz.api.apiErrorToHumanString(res.error); - window.$gz.store.commit( - "logItem", - "Initialize::() fetch useroptions -> error" + msg - ); - window.$gz.eventBus.$emit("notify-error", msg); - } else { - //Check if overrides and use them here - //or else use browser defaults - - let l = { - languageOverride: null, - timeZoneOverride: null, - currencyName: null, - hour12: true - }; - - //get language to use, try user set override first, if empty then browser set, if empty then default to en-us - l.languageOverride = - res.data.languageOverride || - window.$gz.locale.getBrowserFirstLanguage() || - "en-US"; - - l.timeZoneOverride = - res.data.timeZoneOverride || - window.$gz.locale.getBrowserTimeZoneName() || - "America/New_York"; - - //No browser setting for this so meh - l.currencyName = res.data.currencyName || "USD"; - if (res.data.hour12 != null) { - l.hour12 = res.data.hour12; - } - - window.$gz.store.commit("setLocale", l); - } - }) - .catch(function handleFetchUserOptionsError(error) { - window.$gz.store.commit( - "logItem", - "Initialize::() fetch useroptions -> error" + error - ); - throw error; - }) +async function getUserOptions() { + let res = await window.$gz.api.get( + "user-option/" + window.$gz.store.state.userId ); + // eslint-disable-next-line + try { + if (res.error) { + //In a form this would trigger a bunch of validation or error display code but for here and now: + //convert error to human readable string for display and popup a notification to user + let msg = window.$gz.api.apiErrorToHumanString(res.error); + window.$gz.store.commit( + "logItem", + "Initialize::() fetch useroptions -> error" + msg + ); + window.$gz.eventBus.$emit("notify-error", msg); + } else { + //Check if overrides and use them here + //or else use browser defaults + + let l = { + languageOverride: null, + timeZoneOverride: null, + currencyName: null, + hour12: true + }; + + //get language to use, try user set override first, if empty then browser set, if empty then default to en-us + l.languageOverride = + res.data.languageOverride || + window.$gz.locale.getBrowserFirstLanguage() || + "en-US"; + + l.timeZoneOverride = + res.data.timeZoneOverride || + window.$gz.locale.getBrowserTimeZoneName() || + "America/New_York"; + + //No browser setting for this so meh + l.currencyName = res.data.currencyName || "USD"; + if (res.data.hour12 != null) { + l.hour12 = res.data.hour12; + } + + window.$gz.store.commit("setLocale", l); + } + } catch (error) { + window.$gz.store.commit( + "logItem", + "Initialize::() fetch useroptions -> error" + error + ); + throw error; + } } /////////////////////////////////////