Skip to content

Commit 3aec416

Browse files
committed
#210 add is-settings-loading prop to settings-store
1 parent 43c6d68 commit 3aec416

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

app.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ import "./src/assets/index.css";
77
import "./src/assets/vendor";
88
import { useEventsStore, useSettingsStore } from "~/src/shared/stores";
99
10-
useSettingsStore().initialize();
10+
await useSettingsStore().initialize();
1111
useEventsStore().initialize();
1212
</script>

src/shared/stores/settings/settings-store.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
export const useSettingsStore = defineStore("settingsStore", {
1717
state: () => ({
1818
apiVersion: '',
19+
isSettingsLoading: false,
1920
auth: {
2021
isEnabled: false,
2122
loginUrl: '/login',
@@ -26,19 +27,21 @@ export const useSettingsStore = defineStore("settingsStore", {
2627
isVisibleEventCounts: getStoredEventsCountVisibility(),
2728
}),
2829
actions: {
29-
initialize() {
30+
async initialize() {
31+
this.isSettingsLoading = true
3032
const {api: { getSettings }} = useSettings();
3133

32-
getSettings().then(({ version, auth } = {} as TSettings) => {
33-
if (version) {
34-
this.apiVersion = version
35-
}
34+
const { version, auth }: TSettings = await getSettings()
35+
if (version) {
36+
this.apiVersion = version
37+
}
3638

37-
if (auth) {
38-
this.auth.isEnabled = auth.enabled;
39-
this.auth.loginUrl = auth.login_url;
40-
}
41-
})
39+
if (auth) {
40+
this.auth.isEnabled = auth.enabled;
41+
this.auth.loginUrl = auth.login_url;
42+
}
43+
44+
this.isSettingsLoading = false
4245
},
4346
changeTheme() {
4447
this.themeType = this.themeType === THEME_MODES.DARK

0 commit comments

Comments
 (0)