Fixed update picture / displayName finally (hopefully)

master
Stefan Otto 2019-10-31 15:30:20 +01:00
parent 87bcd3a895
commit aac2e5f918
3 changed files with 35 additions and 1 deletions

View File

@ -330,6 +330,11 @@ export default class RoomClient
{ {
text : 'You are logged in.' text : 'You are logged in.'
})); }));
if ( store.getState().room.state !== 'new' ) // no socket yet
{
this.changeDisplayName(displayName);
this.changePicture(picture);
}
} }
_soundNotification() _soundNotification()
@ -656,6 +661,8 @@ export default class RoomClient
stateActions.addLobbyPeer(peer.peerId)); stateActions.addLobbyPeer(peer.peerId));
store.dispatch( store.dispatch(
stateActions.setLobbyPeerDisplayName(peer.displayName)); stateActions.setLobbyPeerDisplayName(peer.displayName));
store.dispatch(
stateActions.setLobbyPeerPicture(peer.picture));
}); });
(accessCode != null) && store.dispatch( (accessCode != null) && store.dispatch(
@ -1310,8 +1317,10 @@ export default class RoomClient
store.dispatch(stateActions.setInLobby(true)); store.dispatch(stateActions.setInLobby(true));
const { displayName } = store.getState().settings; const { displayName } = store.getState().settings;
const { picture } = store.getState().me;
await this.sendRequest('changeDisplayName', { displayName }); await this.sendRequest('changeDisplayName', { displayName });
await this.sendRequest('changePicture', { picture })
break; break;
} }
@ -1413,6 +1422,21 @@ export default class RoomClient
break; break;
} }
case 'lobby:changePicture':
{
const { peerId, picture } = notification.data;
store.dispatch(
stateActions.setLobbyPeerPicture(picture, peerId));
store.dispatch(requestActions.notify(
{
text : `Participant in lobby changed picture.`
}));
break;
}
case 'setAccessCode': case 'setAccessCode':
{ {
const { accessCode } = notification.data; const { accessCode } = notification.data;

View File

@ -461,6 +461,14 @@ export const setLobbyPeerDisplayName = (displayName, peerId) =>
}; };
}; };
export const setLobbyPeerPicture = (picture, peerId) =>
{
return {
type : 'SET_LOBBY_PEER_PICTURE',
payload : { picture, peerId }
};
};
export const setLobbyPeerPromotionInProgress = (peerId, flag) => export const setLobbyPeerPromotionInProgress = (peerId, flag) =>
{ {
return { return {

View File

@ -7,7 +7,8 @@ const lobbyPeer = (state = {}, action) =>
case 'SET_LOBBY_PEER_DISPLAY_NAME': case 'SET_LOBBY_PEER_DISPLAY_NAME':
return { ...state, displayName: action.payload.displayName }; return { ...state, displayName: action.payload.displayName };
case 'SET_LOBBY_PEER_PICTURE':
return { ...state, picture: action.payload.picture };
case 'SET_LOBBY_PEER_PROMOTION_IN_PROGRESS': case 'SET_LOBBY_PEER_PROMOTION_IN_PROGRESS':
return { ...state, promotionInProgress: action.payload.flag }; return { ...state, promotionInProgress: action.payload.flag };
@ -36,6 +37,7 @@ const lobbyPeers = (state = {}, action) =>
} }
case 'SET_LOBBY_PEER_DISPLAY_NAME': case 'SET_LOBBY_PEER_DISPLAY_NAME':
case 'SET_LOBBY_PEER_PICTURE':
case 'SET_LOBBY_PEER_PROMOTION_IN_PROGRESS': case 'SET_LOBBY_PEER_PROMOTION_IN_PROGRESS':
{ {
const oldLobbyPeer = state[action.payload.peerId]; const oldLobbyPeer = state[action.payload.peerId];