Skip to content

Commit b76f36d

Browse files
committed
centralize init of authstore
1 parent 63ca911 commit b76f36d

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

packages/standalone-ui/src/components/CourseHeader.vue

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,10 @@ const props = defineProps<{
3434
3535
const { mobile } = useDisplay();
3636
const isMobile = computed(() => mobile.value);
37-
const authStore = useAuthStore();
3837
3938
const menuItems = ref([
4039
{ text: 'Home', path: '/' },
4140
{ text: 'Study', path: '/study' },
4241
{ text: 'Progress', path: '/progress' },
4342
]);
44-
45-
onMounted(async () => {
46-
// Initialize the auth store with the user database if not already done
47-
if (!authStore.isInitialized) {
48-
const userDB = getDataLayer().getUserDB();
49-
await authStore.init();
50-
}
51-
});
5243
</script>

packages/standalone-ui/src/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ import { aliases, mdi } from 'vuetify/iconsets/mdi';
1616
// data layer
1717
import { initializeDataLayer } from '@vue-skuilder/db';
1818

19+
// auth store
20+
import { useAuthStore } from '@vue-skuilder/common-ui';
21+
1922
(async () => {
2023
await initializeDataLayer({
2124
type: 'pouch',
@@ -51,5 +54,7 @@ import { initializeDataLayer } from '@vue-skuilder/db';
5154
const { piniaPlugin } = await import('@vue-skuilder/common-ui');
5255
app.use(piniaPlugin, { pinia });
5356

57+
await useAuthStore().init();
58+
5459
app.mount('#app');
5560
})();

packages/standalone-ui/src/views/HomeView.vue

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,4 @@ const authStore = useAuthStore();
3232
const authDialogOpen = ref(false);
3333
3434
const isLoggedIn = computed(() => authStore.isLoggedIn);
35-
36-
onMounted(async () => {
37-
// Initialize the auth store with the user database
38-
if (!authStore.isInitialized) {
39-
const userDB = getDataLayer().getUserDB();
40-
await authStore.init(userDB);
41-
}
42-
});
4335
</script>

0 commit comments

Comments
 (0)