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) => { globalGatewayConnection.socket.on('message', (message) => {
store.dispatch({ type: 'messagestore/addmessage', message }); store.dispatch({ type: 'messagestore/addmessage', message });
}); });
globalGatewayConnection.socket.on('clientListUpdate', (userList) => { globalGatewayConnection.socket.on('clientListUpdate', (clientListEvent) => {
store.dispatch({ type: 'presence/category/clientlistupdate', userList }); store.dispatch({ type: 'presence/category/clientlistupdate', clientListEvent });
}); });
}; };
globalGatewayConnection.onDisconnect = function() { globalGatewayConnection.onDisconnect = function() {

View file

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