You've already forked AstralRinth
forked from didirus/AstralRinth
* Order notifications and followed mods Fixes modrinth/knossos#195 * Add user notification badge on avatar Closes modrinth/knossos#145 * Add loading animation * Chain calls, remove console.log * Chain calls * Fix formatting to match prettier * Remove unused userFollows * Create user vuex store * Add notification count indication on dashboard * Fix background for light mode * Move delay check to action, add force parameter * Slightly decrease notification badge opacity on dashboard * Remove SVG for image masking, use border around bubble Also adds CSS for when the dropdown is opened/hovered * Fix merge conflicts Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
36 lines
796 B
JavaScript
36 lines
796 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(
|
|
`https://api.modrinth.com/api/v1/user/${rootState.auth.user.id}/notifications`,
|
|
rootState.auth.headers
|
|
)
|
|
).data
|
|
|
|
commit('SET_NOTIFICATIONS', notifications.length)
|
|
}
|
|
},
|
|
}
|