git
This commit is contained in:
parent
9ee72f7d9e
commit
9fefb7de20
2 changed files with 19 additions and 8 deletions
|
@ -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() {
|
||||
|
|
|
@ -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: {
|
||||
|
|
Loading…
Reference in a new issue