some quick fixes for realtime server after devins refactor

This commit is contained in:
Connor Turland 2016-10-21 18:04:18 -04:00
parent be8efa6025
commit abb997c75c
2 changed files with 8 additions and 8 deletions

View file

@ -7,7 +7,7 @@ global = require('./global'),
stunservers = [{"url": "stun:stun.l.google.com:19302"}]
const { createStore } = require('redux')
const { reducer } = require('./reducer')
const reducer = require('./reducer')
let store = createStore(reducer)

View file

@ -9,7 +9,7 @@ const {
const NOT_IN_CONVERSATION = 0
const IN_CONVERSATION = 1
const addMapperToMap = (map, userId) => { return { ...map, [userId]: NOT_IN_CONVERSATION }}
const addMapperToMap = (map, userId) => { return Object.assign({}, map, { [userId]: NOT_IN_CONVERSATION })}
const reducer = (state = { connectedPeople: {}, liveMaps: {} }, action) => {
const { type, payload } = action
@ -29,7 +29,7 @@ const reducer = (state = { connectedPeople: {}, liveMaps: {} }, action) => {
}
}),
liveMaps: Object.assign({}, liveMaps, {
[payload.mapid]: addMapperToMap(map || {}, payload.userid)
[payload.mapid]: addMapperToMap(map || {}, payload.userid)
})
})
case LEAVE_MAP:
@ -46,7 +46,7 @@ const reducer = (state = { connectedPeople: {}, liveMaps: {} }, action) => {
// update the user (payload.id is user id) in the given map to be marked in the conversation
return Object.assign({}, state, {
liveMaps: Object.assign({}, liveMaps, {
[payload.mapid]: Object.assign({}, map, {
[payload.mapid]: Object.assign({}, map, {
[payload.id]: IN_CONVERSATION
})
})
@ -60,12 +60,12 @@ const reducer = (state = { connectedPeople: {}, liveMaps: {} }, action) => {
liveMaps: Object.assign({}, liveMaps, { map: newMap })
})
case 'DISCONNECT':
const mapWithoutUser = omit(map, payload.userid)
const newMap = callWillFinish ? mapValues(mapWithoutUser, () => NOT_IN_CONVERSATION) : mapWithoutUser
const newLiveMaps = mapWillEmpty ? omit(liveMaps, payload.mapid) : Object.assign({}, liveMaps, { [payload.mapid]: newMap })
const mapWithoutUser = omit(map, payload.userid)
const newMapWithoutUser = callWillFinish ? mapValues(mapWithoutUser, () => NOT_IN_CONVERSATION) : mapWithoutUser
const newLiveMapsWithoutUser = mapWillEmpty ? omit(liveMaps, payload.mapid) : Object.assign({}, liveMaps, { [payload.mapid]: newMapWithoutUser })
return {
connectedPeople: omit(connectedPeople, payload.userid),
liveMaps: omitBy(newLiveMaps, isNil)
liveMaps: omitBy(newLiveMapsWithoutUser, isNil)
}
default:
return state