2021-10-13 03:07:42 +02:00
|
|
|
|
|
|
|
export const state = () => ({
|
2022-11-24 21:44:09 +01:00
|
|
|
usersOnline: []
|
2021-10-13 03:07:42 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
export const getters = {
|
2021-10-23 03:08:02 +02:00
|
|
|
getIsUserOnline: state => id => {
|
2022-11-24 21:44:09 +01:00
|
|
|
return state.usersOnline.find(u => u.id === id)
|
2021-10-23 03:08:02 +02:00
|
|
|
}
|
2021-10-13 03:07:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export const actions = {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export const mutations = {
|
2022-11-24 21:44:09 +01:00
|
|
|
setUsersOnline(state, usersOnline) {
|
|
|
|
state.usersOnline = usersOnline
|
2021-10-23 03:08:02 +02:00
|
|
|
},
|
2022-11-24 21:44:09 +01:00
|
|
|
updateUserOnline(state, user) {
|
|
|
|
var index = state.usersOnline.findIndex(u => u.id === user.id)
|
2021-10-13 03:07:42 +02:00
|
|
|
if (index >= 0) {
|
2022-11-24 21:44:09 +01:00
|
|
|
state.usersOnline.splice(index, 1, user)
|
2021-10-13 03:07:42 +02:00
|
|
|
} else {
|
2022-11-24 21:44:09 +01:00
|
|
|
state.usersOnline.push(user)
|
2021-10-13 03:07:42 +02:00
|
|
|
}
|
|
|
|
},
|
2022-11-24 21:44:09 +01:00
|
|
|
removeUserOnline(state, user) {
|
|
|
|
state.usersOnline = state.usersOnline.filter(u => u.id !== user.id)
|
2021-10-13 03:07:42 +02:00
|
|
|
}
|
|
|
|
}
|