mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-28 19:10:40 +00:00
websocket implementation
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
||||
const defaultState = {
|
||||
isRunningConnection: false,
|
||||
}
|
||||
|
||||
const actions = {
|
||||
runConnection: ({ commit, getters }) => {
|
||||
|
||||
commit('SET_RUNNING_COMMUNICATION')
|
||||
|
||||
Echo.private(`test.${getters.user.data.id}`)
|
||||
.listen('.Domain\\Notifications\\Events\\TestUpdate', (e) => {
|
||||
console.log(e);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
SET_RUNNING_COMMUNICATION(state) {
|
||||
state.isRunningConnection = true
|
||||
},
|
||||
}
|
||||
|
||||
const getters = {
|
||||
isRunningConnection: (state) => state.isRunningConnection,
|
||||
}
|
||||
|
||||
export default {
|
||||
state: defaultState,
|
||||
getters,
|
||||
actions,
|
||||
mutations,
|
||||
}
|
||||
+5
-1
@@ -10,7 +10,7 @@ const defaultState = {
|
||||
}
|
||||
|
||||
const actions = {
|
||||
getAppData: ({ commit, getters }) => {
|
||||
getAppData: ({ commit, getters, dispatch }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios
|
||||
.get(getters.api + '/user' + getters.sorting.URI)
|
||||
@@ -18,6 +18,10 @@ const actions = {
|
||||
resolve(response)
|
||||
|
||||
commit('RETRIEVE_USER', response.data)
|
||||
|
||||
if (! getters.isRunningConnection) {
|
||||
dispatch('runConnection')
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error)
|
||||
|
||||
Reference in New Issue
Block a user