Skip to content

Commit e2f8fd2

Browse files
committed
chore: remove redundant store
1 parent 7f2a227 commit e2f8fd2

27 files changed

+979
-1164
lines changed

app/@layouts/components/NavbarShortcuts.vue

Lines changed: 0 additions & 41 deletions
This file was deleted.

app/@layouts/components/UserProfile.vue

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@ import { PerfectScrollbar } from 'vue3-perfect-scrollbar'
44
55
const { t } = useI18n()
66
const authStore = useAuthStore()
7-
const tokenDeviceStore = useTokenDeviceStore()
87
const userEmail = computed(() => authStore.currentUser?.email)
98
const userAvatar = computed(() => authStore.currentUser?.picture)
109
const userFullname = computed(() => authStore.currentUser?.name)
1110
const userRole = computed(() => authStore.currentUser?.roles?.[0] || authStore.currentUser?.organization_roles?.[0] || t('User'))
1211
1312
async function logout() {
1413
try {
15-
if (authStore.currentUser)
16-
await tokenDeviceStore.clearTokenDevice()
17-
18-
await authStore.signOut()
14+
await navigateTo({ path: '/sign-out' }, { external: true })
1915
2016
navigateTo({ name: 'auth-login' })
2117
}
@@ -51,12 +47,12 @@ const userProfileList = computed<Array<{
5147
title: t('Pricing'),
5248
to: { name: 'settings-pricing' },
5349
},
54-
{
55-
type: 'navItem',
56-
icon: 'ri-question-line',
57-
title: 'FAQ',
58-
to: { name: 'faq' },
59-
},
50+
// {
51+
// type: 'navItem',
52+
// icon: 'ri-question-line',
53+
// title: 'FAQ',
54+
// to: { name: 'faq' },
55+
// },
6056
])
6157
</script>
6258

app/@layouts/components/layout/DefaultLayoutWithHorizontalNav.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const config = useRuntimeConfig()
3030
<NavBarI18n />
3131

3232
<NavbarThemeSwitcher />
33-
<NavbarShortcuts />
3433
<NavBarNotifications class="me-2" />
3534
<UserProfile />
3635
</template>

app/@layouts/components/layout/DefaultLayoutWithVerticalNav.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ watch([
3939

4040
<NavBarI18n />
4141
<NavbarThemeSwitcher />
42-
<NavbarShortcuts />
4342
<NavBarNotifications class="me-2" />
4443
<UserProfile />
4544
</div>

app/app.vue

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { useTheme } from 'vuetify'
3-
import { getMessaging, onMessage } from 'firebase/messaging'
3+
import { getMessaging, getToken } from 'firebase/messaging'
44
import ScrollToTop from '@base/@core/components/ScrollToTop.vue'
55
import initCore from '@base/@core/initCore'
66
import { initConfigStore, useConfigStore } from '@base/@core/stores/config'
@@ -18,14 +18,27 @@ const { global } = useTheme()
1818
if (isMobile)
1919
configStore.appContentLayoutNav = 'vertical'
2020
21-
onBeforeMount(async () => {
22-
if (!isInAppBrowser()) {
23-
onMessage(getMessaging(), () => {
24-
// TODO: Handle incoming messages
25-
// console.log('Client message:', payload)
26-
// const linkSplits = payload.fcmOptions?.link?.split('/projects/')
27-
// notify(payload.notification?.body as string, { type: 'primary', link: `/projects/${linkSplits![1]}` })
28-
})
21+
const config = useRuntimeConfig()
22+
23+
const tokenDevice = useLocalStorage<string | null>('tokenDevice', null)
24+
25+
const notificationApi = useApiNotification()
26+
27+
onMounted(async () => {
28+
if (!isInAppBrowser() && !tokenDevice.value) {
29+
try {
30+
if (Notification.permission !== 'granted')
31+
await Notification.requestPermission()
32+
33+
const authStore = useAuthStore()
34+
35+
if (Notification.permission === 'granted' && authStore.currentUser) {
36+
const token = await getToken(getMessaging(), { vapidKey: config.public.firebase.keyPair })
37+
38+
notificationApi.createTokenDevice(token)
39+
}
40+
}
41+
catch {}
2942
}
3043
})
3144
</script>

app/components/account-settings/AccountSettingsAccount.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const config = useRuntimeConfig()
55
66
const inputFileRef = ref<HTMLElement>()
77
8+
const authApi = useApiAuth()
9+
810
const authStore = useAuthStore()
911
const formFile = ref<File | null>(null)
1012
@@ -97,7 +99,7 @@ async function handleSubmit() {
9799
if (formFile.value && authStore.currentUser)
98100
avatarUrl = await uploadToS3(formFile.value, authStore.currentUser.sub)
99101
100-
await authStore.updateProfile({
102+
await authApi.updateProfile({
101103
...formData.value,
102104
avatar: avatarUrl,
103105
})

app/middleware/01.health.global.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ export default defineNuxtRouteMiddleware(async (to) => {
22
if (to.meta.public || import.meta.prerender)
33
return
44

5-
const healthStore = useHealthStore()
6-
75
try {
8-
await healthStore.fetchHealthCheck()
6+
await useApiHealth().fetchHealthCheck()
97
}
108
catch {
119
throw createError({

app/middleware/02.authentication.global.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,11 @@ export default defineNuxtRouteMiddleware(async (to) => {
22
if (to.meta.public)
33
return
44

5-
if (to.meta.auth || to.meta.auth === undefined) {
5+
if (to.meta.auth) {
66
const authStore = useAuthStore()
77

8-
if (authStore.currentUser) {
9-
if (to.meta.unauthenticatedOnly)
10-
return navigateTo('/')
11-
12-
try {
13-
await authStore.fetchToken()
14-
}
15-
catch {
16-
notifyError({
17-
content: 'Failed to retrieve user token.',
18-
})
19-
}
20-
}
21-
else if (!to.meta.unauthenticatedOnly) {
22-
return navigateTo('/auth/login')
8+
if (!authStore.currentUser) {
9+
return navigateTo({ path: '/sign-in' }, { external: true })
2310
}
2411
}
2512
})

0 commit comments

Comments
 (0)