mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 08:12:15 +00:00
backend notifications implementation
This commit is contained in:
10
resources/js/store/modules/app.js
vendored
10
resources/js/store/modules/app.js
vendored
@@ -5,6 +5,8 @@ import router from '../../router'
|
||||
|
||||
const defaultState = {
|
||||
isVisibleNavigationBars: localStorage.getItem('is_navigation_bars') !== 'false',
|
||||
isVisibleNotificationCenter: false,
|
||||
notificationCount: 0,
|
||||
isDarkMode: false,
|
||||
isVisibleSidebar: localStorage.getItem('file_info_visibility') === 'true' || false,
|
||||
itemViewType: localStorage.getItem('preview_type') || 'list',
|
||||
@@ -167,10 +169,18 @@ const mutations = {
|
||||
UPDATE_DARK_MODE_STATUS(state, val) {
|
||||
state.isDarkMode = val
|
||||
},
|
||||
UPDATE_NOTIFICATION_COUNT(state, val) {
|
||||
state.notificationCount = val
|
||||
},
|
||||
TOGGLE_NOTIFICATION_CENTER(state) {
|
||||
state.isVisibleNotificationCenter = !state.isVisibleNotificationCenter
|
||||
},
|
||||
}
|
||||
|
||||
const getters = {
|
||||
isVisibleNotificationCenter: (state) => state.isVisibleNotificationCenter,
|
||||
isVisibleNavigationBars: (state) => state.isVisibleNavigationBars,
|
||||
notificationCount: (state) => state.notificationCount,
|
||||
isVisibleSidebar: (state) => state.isVisibleSidebar,
|
||||
itemViewType: (state) => state.itemViewType,
|
||||
requestedPlan: (state) => state.requestedPlan,
|
||||
|
||||
11
resources/js/store/modules/broadcasting.js
vendored
11
resources/js/store/modules/broadcasting.js
vendored
@@ -3,14 +3,15 @@ const defaultState = {
|
||||
}
|
||||
|
||||
const actions = {
|
||||
runConnection: ({ commit, getters }) => {
|
||||
runConnection: ({ commit, getters, dispatch }) => {
|
||||
|
||||
commit('SET_RUNNING_COMMUNICATION')
|
||||
|
||||
Echo.private(`test.${getters.user.data.id}`)
|
||||
.listen('.Domain\\Notifications\\Events\\TestUpdate', (e) => {
|
||||
console.log(e);
|
||||
});
|
||||
Echo.private(`App.Users.Models.User.${getters.user.data.id}`)
|
||||
.notification(() => {
|
||||
// TODO: call sound
|
||||
dispatch('getAppData')
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
8
resources/js/store/modules/userAuth.js
vendored
8
resources/js/store/modules/userAuth.js
vendored
@@ -18,6 +18,7 @@ const actions = {
|
||||
resolve(response)
|
||||
|
||||
commit('RETRIEVE_USER', response.data)
|
||||
commit('UPDATE_NOTIFICATION_COUNT', response.data.data.relationships.unreadNotifications.data.length)
|
||||
|
||||
if (! getters.isRunningConnection) {
|
||||
dispatch('runConnection')
|
||||
@@ -172,6 +173,13 @@ const mutations = {
|
||||
}
|
||||
})
|
||||
},
|
||||
PUSH_NEW_NOTIFICATION(state, notification) {
|
||||
state.user.data.relationships.unreadNotifications.data.push(notification)
|
||||
},
|
||||
FLUSH_NOTIFICATIONS(state) {
|
||||
state.user.data.relationships.readNotifications.data = []
|
||||
state.user.data.relationships.unreadNotifications.data = []
|
||||
},
|
||||
}
|
||||
|
||||
const getters = {
|
||||
|
||||
Reference in New Issue
Block a user