do the same with user actions
This commit is contained in:
parent
50044efaf9
commit
61f93ad955
1 changed files with 6 additions and 2 deletions
|
|
@ -3,7 +3,6 @@ import { defineStore } from 'pinia'
|
|||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
|
||||
import { getAnnouncements } from 'src/api/public.js'
|
||||
import { dismissAnnouncement } from 'src/api/user.js'
|
||||
|
||||
const FETCH_ANNOUNCEMENT_INTERVAL_MS = 1000 * 60 * 5
|
||||
|
||||
|
|
@ -13,6 +12,7 @@ export const useAnnouncementsStore = defineStore('announcements', {
|
|||
supportsAnnouncements: true,
|
||||
fetchAnnouncementsTimer: undefined,
|
||||
adminActions: {},
|
||||
userActions: {},
|
||||
}),
|
||||
getters: {
|
||||
unreadAnnouncementCount() {
|
||||
|
|
@ -36,6 +36,10 @@ export const useAnnouncementsStore = defineStore('announcements', {
|
|||
currentUser.privileges.has('announcements_manage_announcements')
|
||||
|
||||
try {
|
||||
if (currentUser) {
|
||||
this.userActions = await import('src/api/user.js')
|
||||
}
|
||||
|
||||
if (isAdmin) {
|
||||
this.adminActions = await import('src/api/admin.js')
|
||||
} else {
|
||||
|
|
@ -82,7 +86,7 @@ export const useAnnouncementsStore = defineStore('announcements', {
|
|||
}
|
||||
},
|
||||
markAnnouncementAsRead(id) {
|
||||
return dismissAnnouncement({
|
||||
return this.userActions.dismissAnnouncement({
|
||||
id,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue