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 { useOAuthStore } from 'src/stores/oauth.js'
|
||||||
|
|
||||||
import { getAnnouncements } from 'src/api/public.js'
|
import { getAnnouncements } from 'src/api/public.js'
|
||||||
import { dismissAnnouncement } from 'src/api/user.js'
|
|
||||||
|
|
||||||
const FETCH_ANNOUNCEMENT_INTERVAL_MS = 1000 * 60 * 5
|
const FETCH_ANNOUNCEMENT_INTERVAL_MS = 1000 * 60 * 5
|
||||||
|
|
||||||
|
|
@ -13,6 +12,7 @@ export const useAnnouncementsStore = defineStore('announcements', {
|
||||||
supportsAnnouncements: true,
|
supportsAnnouncements: true,
|
||||||
fetchAnnouncementsTimer: undefined,
|
fetchAnnouncementsTimer: undefined,
|
||||||
adminActions: {},
|
adminActions: {},
|
||||||
|
userActions: {},
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
unreadAnnouncementCount() {
|
unreadAnnouncementCount() {
|
||||||
|
|
@ -36,6 +36,10 @@ export const useAnnouncementsStore = defineStore('announcements', {
|
||||||
currentUser.privileges.has('announcements_manage_announcements')
|
currentUser.privileges.has('announcements_manage_announcements')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (currentUser) {
|
||||||
|
this.userActions = await import('src/api/user.js')
|
||||||
|
}
|
||||||
|
|
||||||
if (isAdmin) {
|
if (isAdmin) {
|
||||||
this.adminActions = await import('src/api/admin.js')
|
this.adminActions = await import('src/api/admin.js')
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -82,7 +86,7 @@ export const useAnnouncementsStore = defineStore('announcements', {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
markAnnouncementAsRead(id) {
|
markAnnouncementAsRead(id) {
|
||||||
return dismissAnnouncement({
|
return this.userActions.dismissAnnouncement({
|
||||||
id,
|
id,
|
||||||
credentials: useOAuthStore().token,
|
credentials: useOAuthStore().token,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue