First working version of lobby.

This commit is contained in:
Håvar Aambø Fosstveit
2019-10-16 14:09:29 +02:00
parent 66a2becf63
commit 513f0efa0b
9 changed files with 207 additions and 118 deletions
+7 -2
View File
@@ -3,11 +3,14 @@ const lobbyPeer = (state = {}, action) =>
switch (action.type)
{
case 'ADD_LOBBY_PEER':
return { peerId: action.payload.peerId };
return { id: action.payload.peerId };
case 'SET_LOBBY_PEER_DISPLAY_NAME':
return { ...state, displayName: action.payload.displayName };
case 'SET_LOBBY_PEER_PROMOTION_IN_PROGRESS':
return { ...state, promotionInProgress: action.payload.flag };
default:
return state;
}
@@ -33,12 +36,14 @@ const lobbyPeers = (state = {}, action) =>
}
case 'SET_LOBBY_PEER_DISPLAY_NAME':
case 'SET_LOBBY_PEER_PROMOTION_IN_PROGRESS':
{
const oldLobbyPeer = state[action.payload.peerId];
if (!oldLobbyPeer)
{
throw new Error('no Peer found');
// Tried to update non-existant lobbyPeer. Has probably been promoted, or left.
return state;
}
return { ...state, [oldLobbyPeer.id]: lobbyPeer(oldLobbyPeer, action) };
+2
View File
@@ -3,6 +3,7 @@ import room from './room';
import me from './me';
import producers from './producers';
import peers from './peers';
import lobbyPeers from './lobbyPeers';
import consumers from './consumers';
import peerVolumes from './peerVolumes';
import notifications from './notifications';
@@ -16,6 +17,7 @@ export default combineReducers({
me,
producers,
peers,
lobbyPeers,
consumers,
peerVolumes,
notifications,