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
@ -61,11 +61,11 @@ const reducer = (state = { connectedPeople: {}, liveMaps: {} }, action) => {
})
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 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