diff --git a/bfrontend/src/Gateway/globalGatewayConnection.js b/bfrontend/src/Gateway/globalGatewayConnection.js index b65fbb1..c577294 100644 --- a/bfrontend/src/Gateway/globalGatewayConnection.js +++ b/bfrontend/src/Gateway/globalGatewayConnection.js @@ -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() { diff --git a/bfrontend/src/store.js b/bfrontend/src/store.js index 66e0a9e..41c4f2e 100644 --- a/bfrontend/src/store.js +++ b/bfrontend/src/store.js @@ -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: {