Added lastN to global state

master
Håvar Aambø Fosstveit 2018-10-24 13:03:05 +02:00
parent 5233debdfa
commit a4b70ebaff
3 changed files with 23 additions and 5 deletions

View File

@ -349,6 +349,8 @@ export default class RoomClient
{ {
const speakers = this._lastN.slice(0, this._lastNSpeakers); const speakers = this._lastN.slice(0, this._lastNSpeakers);
this._dispatch(stateActions.setLastN(speakers));
speakers.forEach((peerName) => speakers.forEach((peerName) =>
{ {
const peer = this._room.getPeerByName(peerName); const peer = this._room.getPeerByName(peerName);
@ -1196,6 +1198,7 @@ export default class RoomClient
if (index === -1) // We don't have this peer in the list, add if (index === -1) // We don't have this peer in the list, add
{ {
this._lastN.push(peer.name); this._lastN.push(peer.name);
this.updateSpeakers();
} }
this._handlePeer(peer); this._handlePeer(peer);

View File

@ -8,7 +8,8 @@ const initialState =
fullScreenConsumer : null, // ConsumerID fullScreenConsumer : null, // ConsumerID
toolbarsVisible : true, toolbarsVisible : true,
mode : 'democratic', mode : 'democratic',
selectedPeerName : null selectedPeerName : null,
lastN : null
}; };
const room = (state = initialState, action) => const room = (state = initialState, action) =>
@ -83,6 +84,13 @@ const room = (state = initialState, action) =>
}; };
} }
case 'SET_LASTN':
{
const { lastN } = action.payload;
return { ...state, lastN };
}
default: default:
return state; return state;
} }

View File

@ -474,7 +474,14 @@ export const loggedIn = () =>
type : 'LOGGED_IN' type : 'LOGGED_IN'
}); });
export const setSelectedPeer = (selectedPeerName) => ({ export const setSelectedPeer = (selectedPeerName) =>
type : 'SET_SELECTED_PEER', ({
payload : { selectedPeerName } type : 'SET_SELECTED_PEER',
}); payload : { selectedPeerName }
});
export const setLastN = (lastN) =>
({
type : 'SET_LASTN',
payload : { lastN }
});