* Switch site to use axios base url * Fix team invites * Fix find/replace setting the wrong thing * Fix analytics being blocking, small issues
36 lines
764 B
JavaScript
36 lines
764 B
JavaScript
export const state = () => ({
|
|
notifications: {
|
|
count: 0,
|
|
lastUpdated: 0,
|
|
},
|
|
})
|
|
|
|
export const mutations = {
|
|
SET_NOTIFICATIONS(state, count) {
|
|
state.notifications.count = count
|
|
state.notifications.lastUpdated = Date.now()
|
|
},
|
|
}
|
|
|
|
export const actions = {
|
|
async fetchNotifications(
|
|
{ commit, state, rootState },
|
|
{ force = false } = {}
|
|
) {
|
|
if (
|
|
rootState.auth.user &&
|
|
rootState.auth.user.id &&
|
|
(force || Date.now() - state.notifications.lastUpdated > 300000)
|
|
) {
|
|
const notifications = (
|
|
await this.$axios.get(
|
|
`user/${rootState.auth.user.id}/notifications`,
|
|
rootState.auth.headers
|
|
)
|
|
).data
|
|
|
|
commit('SET_NOTIFICATIONS', notifications.length)
|
|
}
|
|
},
|
|
}
|