Add avatars to user list

master
Torjus 2018-07-18 13:59:52 +02:00
parent c416d0c402
commit 3a43443011
7 changed files with 51 additions and 19 deletions

View File

@ -174,6 +174,16 @@ export default class RoomClient
}); });
} }
changeProfilePicture(picture)
{
logger.debug('changeProfilePicture() [picture: "%s"]', picture);
this._protoo.send('change-profile-picture', { picture }).catch((error) =>
{
logger.error('shareProfilePicure() | failed: %o', error);
});
}
sendChatMessage(chatMessage) sendChatMessage(chatMessage)
{ {
logger.debug('sendChatMessage() [chatMessage:"%s"]', chatMessage); logger.debug('sendChatMessage() [chatMessage:"%s"]', chatMessage);
@ -1051,6 +1061,17 @@ export default class RoomClient
break; break;
} }
case 'profile-picture-changed':
{
accept();
const { peerName, picture } = request.data;
this._dispatch(stateActions.setPeerPicture(peerName, picture));
break;
}
// This means: server wants to change MY user information // This means: server wants to change MY user information
case 'auth': case 'auth':
{ {
@ -1061,6 +1082,7 @@ export default class RoomClient
{ {
this.changeDisplayName(request.data.name); this.changeDisplayName(request.data.name);
this.changeProfilePicture(request.data.picture);
this._dispatch(stateActions.setPicture(request.data.picture)); this._dispatch(stateActions.setPicture(request.data.picture));
this._dispatch(requestActions.notify( this._dispatch(requestActions.notify(

View File

@ -50,8 +50,8 @@ class MessageList extends Component
{ {
const messageTime = new Date(message.time); const messageTime = new Date(message.time);
const picture = message.sender === 'response' ? const picture = (message.sender === 'response' ?
message.picture : this.props.myPicture; message.picture : this.props.myPicture) || 'resources/images/avatar-empty.jpeg';
return ( return (
<div className='message' key={i}> <div className='message' key={i}>

View File

@ -38,9 +38,12 @@ const ListPeer = (props) =>
!screenConsumer.remotelyPaused !screenConsumer.remotelyPaused
); );
const picture = peer.picture || 'resources/images/avatar-empty.jpeg';
return ( return (
<div data-component='ListPeer'> <div data-component='ListPeer'>
<img className='avatar' /> <img className='avatar' src={picture} />
<div className='peer-info'> <div className='peer-info'>
{peer.displayName} {peer.displayName}
</div> </div>

View File

@ -1,6 +1,6 @@
import omit from 'lodash/omit'; import omit from 'lodash/omit';
const peer = (state, action) => const peer = (state = {}, action) =>
{ {
switch (action.type) switch (action.type)
{ {
@ -36,6 +36,11 @@ const peer = (state, action) =>
return { ...state, consumers }; return { ...state, consumers };
} }
case 'SET_PEER_PICTURE':
{
return { ...state, picture: action.payload.picture };
}
default: default:
return state; return state;
} }
@ -60,6 +65,7 @@ const peers = (state = {}, action) =>
case 'SET_PEER_AUDIO_IN_PROGRESS': case 'SET_PEER_AUDIO_IN_PROGRESS':
case 'SET_PEER_SCREEN_IN_PROGRESS': case 'SET_PEER_SCREEN_IN_PROGRESS':
case 'SET_PEER_RAISE_HAND_STATE': case 'SET_PEER_RAISE_HAND_STATE':
case 'SET_PEER_PICTURE':
case 'ADD_CONSUMER': case 'ADD_CONSUMER':
{ {
const oldPeer = state[action.payload.peerName]; const oldPeer = state[action.payload.peerName];

View File

@ -424,3 +424,9 @@ export const setPicture = (picture) =>
type : 'SET_PICTURE', type : 'SET_PICTURE',
payload : { picture } payload : { picture }
}); });
export const setPeerPicture = (peerName, picture) =>
({
type : 'SET_PEER_PICTURE',
payload : { peerName, picture }
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -15,6 +15,8 @@
} }
[data-component='ListPeer'] { [data-component='ListPeer'] {
display: flex;
> .controls { > .controls {
float: right; float: right;
display: flex; display: flex;
@ -110,23 +112,16 @@
} }
> .avatar { > .avatar {
padding: 8px 16px; border-radius: 50%;
float: left; height: 2rem;
width: auto;
border: none;
display: block;
outline: 0;
border-radius: 50%;
vertical-align: middle;
} }
> .peer-info { > .peer-info {
font-size: 1.4vmin; font-size: 1.4vmin;
float: left; border: none;
width: auto; display: flex;
border: none; padding: 0.6vmin;
display: block; flex-grow: 1;
outline: 0; align-items: center;
padding: 0.6vmin;
} }
} }