This commit is contained in:
hippoz 2021-02-04 16:01:49 +02:00
parent 9ee72f7d9e
commit 9fefb7de20
Signed by: hippoz
GPG key ID: 7C52899193467641
2 changed files with 19 additions and 8 deletions

View file

@ -9,8 +9,8 @@ globalGatewayConnection.onConnect = function() {
globalGatewayConnection.socket.on('message', (message) => {
store.dispatch({ type: 'messagestore/addmessage', message });
});
globalGatewayConnection.socket.on('clientListUpdate', (userList) => {
store.dispatch({ type: 'presence/category/clientlistupdate', userList });
globalGatewayConnection.socket.on('clientListUpdate', (clientListEvent) => {
store.dispatch({ type: 'presence/category/clientlistupdate', clientListEvent });
});
};
globalGatewayConnection.onDisconnect = function() {

View file

@ -5,7 +5,8 @@ const intitialState = {
categories: null,
gateway: { isConnected: false },
messages: {},
subscribedToCategories: []
subscribedToCategories: [],
categoryPresenceClientList: {}
};
const reducer = (state = intitialState, payload) => {
@ -14,14 +15,14 @@ const reducer = (state = intitialState, payload) => {
return {
...state,
user: payload.user
}
};
}
case 'categories/updatecategorylist': {
return {
...state,
categories: payload.categories
}
};
}
case 'gateway/connectionstatus': {
@ -30,7 +31,7 @@ const reducer = (state = intitialState, payload) => {
gateway: {
isConnected: payload.gateway.isConnected
}
}
};
}
case 'messagestore/addmessage': {
@ -43,7 +44,7 @@ const reducer = (state = intitialState, payload) => {
payload.message
]
}
}
};
}
case 'categories/selectcategory': {
@ -53,7 +54,17 @@ const reducer = (state = intitialState, payload) => {
...state.subscribedToCategories || [],
payload.categoryId
]
}
};
}
case 'presence/category/clientlistupdate': {
return {
...state,
categoryPresenceClientList: {
...state.categoryPresenceClientList || [],
[payload.clientListEvent.category._id]: payload.clientListEvent.clientList
}
};
}
default: {