Skip to content

Commit

Permalink
feat(chat): convert to use React
Browse files Browse the repository at this point in the history
- Change "features/chat" to support listening for new chat messages
  and storing them, removing that logic from conference.js.
- Combine chat.scss and side_toolbar_container.css, and remove unused
  scss files. Chat is the only side panel so the two concepts have
  been merged.
- Remove direct access to the chat feature from non-react and non-redux
  flows.
- Modify the i18n translate function to take in an options object.
  By default the option "wait" is set to true, but that causes
  components to mount after the parent has been notified of
  an update, which means autoscrolling down to the latest rendered
  messages does not work. With "wait" set to false, the children
  will mount and then the parent will trigger componentDidUpdate.
- Create react components for chat. Chat is the side panel
  plus the entiren chat feature. ChatInput is a child of Chat and
  is used for composing messages. ChatMessage displays one message
  and extends PureComponent to limit re-renders.
- Fix a bug where the toolbar was not showing automatically when
  chat is closed and a new message is received.
- Import react-transition-group to time the animation of the
  side panel showing/hiding and unmounting the Chat component.
  This gets around the issue of having to control autofocus if the
  component were always mounted and visibility toggled, but
  introduces not being able to store previous scroll state
  (without additional work or re-work).
  • Loading branch information
Pratik Shah authored and yanas committed Sep 26, 2018
1 parent 8adc8a0 commit b7b43e8
Show file tree
Hide file tree
Showing 44 changed files with 1,203 additions and 1,209 deletions.
40 changes: 9 additions & 31 deletions conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ import {
getLocationContextRoot,
getJitsiMeetGlobalNS
} from './react/features/base/util';
import { addMessage } from './react/features/chat';
import { showDesktopPicker } from './react/features/desktop-picker';
import { appendSuffix } from './react/features/display-name';
import {
Expand Down Expand Up @@ -424,10 +425,16 @@ class ConferenceConnector {
switch (err) {
case JitsiConferenceErrors.CHAT_ERROR:
logger.error('Chat error.', err);
if (isButtonEnabled('chat')) {
if (isButtonEnabled('chat') && !interfaceConfig.filmStripOnly) {
const [ code, msg ] = params;

APP.UI.showChatError(code, msg);
APP.store.dispatch(addMessage({
hasRead: true,
error: code,
message: msg,
timestamp: Date.now(),
type: 'error'
}));
}
break;
default:
Expand Down Expand Up @@ -1819,35 +1826,6 @@ export default {
JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED,
id => APP.store.dispatch(dominantSpeakerChanged(id, room)));

if (!interfaceConfig.filmStripOnly) {
if (isButtonEnabled('chat')) {
room.on(
JitsiConferenceEvents.MESSAGE_RECEIVED,
(id, body, ts) => {
let nick = getDisplayName(id);

if (!nick) {
nick = `${
interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME} (${
id})`;
}

APP.API.notifyReceivedChatMessage({
id,
nick,
body,
ts
});
APP.UI.addMessage(id, nick, body, ts);
}
);
APP.UI.addListener(UIEvents.MESSAGE_CREATED, message => {
APP.API.notifySendingChatMessage(message);
room.sendTextMessage(message);
});
}
}

room.on(JitsiConferenceEvents.CONNECTION_INTERRUPTED, () => {
APP.store.dispatch(localParticipantConnectionStatusChanged(
JitsiParticipantConnectionStatus.INTERRUPTED));
Expand Down
19 changes: 0 additions & 19 deletions css/_animations.scss

This file was deleted.

202 changes: 127 additions & 75 deletions css/_chat.scss
Original file line number Diff line number Diff line change
@@ -1,21 +1,58 @@
#sideToolbarContainer {
background-color: $newToolbarBackgroundColor;
display: flex;
/**
* Make the sidebar flush with the top of the toolbar. Take the size of
* the toolbar and subtract from 100%.
*/
height: calc(100% - #{$newToolbarSizeWithPadding});
left: -$sidebarWidth;
overflow: hidden;
position: absolute;
top: 0;
transition: left 0.5s;
width: $sidebarWidth;
z-index: $sideToolbarContainerZ;

/**
* The sidebar (chat) is off-screen when hidden. Move it flush to the left
* side of the window when it should be visible.
*/
&.slideInExt {
left: 0;
}

.sideToolbarContainer__inner {
box-sizing: border-box;
color: #FFF;
display: flex;
flex-direction: column;
height: 100%;
width: $sidebarWidth;
}
}

#chat_container * {
-webkit-user-select: text;
user-select: text;
}

#chatconversation {
visibility: hidden;
position: relative;
top: 15px;
padding: 5px;
text-align: left;
line-height: 20px;
box-sizing: border-box;
flex: 1;
font-size: 10pt;
width: 100%;
height: 90%;
line-height: 20px;
margin-top: 15px;
overflow: auto;
padding: 5px;
text-align: left;
width: $sidebarWidth;
word-wrap: break-word;

a {
display: block;
}

a:link {
color: rgb(184, 184, 184);
}
Expand Down Expand Up @@ -55,52 +92,59 @@
}
}

#chat_container.is-conversation-mode #chatconversation {
visibility: visible;
}

.localuser {
color: #4C9AFF
.chat-close {
background: gray;
border: 3px solid rgba(255, 255, 255, 0.1);
border-radius: 100%;
color: white;
cursor:pointer;
height: 10px;
line-height: 10px;
padding: 4px;
position: absolute;
right: 5px;
text-align: center;
top: 5px;
width: 10px;
z-index: 1;
}

.errorMessage {
color: red;
#chat-input {
background-color: $newToolbarBackgroundColor;
display: flex;
}

.remoteuser {
color: #B8C7E0;
}

.usrmsg-form {
flex: 1;
margin-left: 5px;
}

#usermsg {
background-color: $newToolbarBackgroundColor;
visibility:hidden;
position: absolute;
bottom: 0px;
right: 0px;
width: 83%;
height: 30px;
padding: 5px 5px 5px 0px;
max-height:150px;
min-height:35px;
border: 0px none;
color: white;
box-shadow: none;
border-radius:0;
box-shadow: none;
color: white;
font-size: 10pt;
line-height: 30px;
overflow: hidden;
padding: 5px 5px 5px 0px;
max-height:150px;
min-height:35px;
overflow-y: auto;
resize: none;
width: 100%;
word-break: break-word;
}

#usermsg:hover {
border: 0px none;
box-shadow: none;
}

#chat_container.is-conversation-mode #usermsg {
visibility: visible;
}

#nickname {
position: absolute;
text-align: center;
Expand All @@ -112,20 +156,7 @@
width: 95%;
}

#chat_container.is-conversation-mode #nickname {
visibility: hidden;
}

#nickinput {
margin-top: 20px;
font-size: 14px;
background: #3a3a3a;
box-shadow: inset 0 0 3px 2px #a7a7a7;
border: 1px solid #a7a7a7;
color: #a7a7a7;
}

#chat_container .username {
#chat_container .display-name {
float: left;
padding-left: 5px;
font-weight: bold;
Expand All @@ -141,41 +172,55 @@
font-size: 11px;
}

#chat_container .usermessage {
.usermessage {
padding-top: 20px;
padding-left: 5px;
}

.chatArrow {
position: absolute;
height: 15px;
left: 5px;
left: -10px;
position: absolute;
}

.chatmessage {
background-color: $newToolbarBackgroundColor;;
background-color: $newToolbarBackgroundColor;
width: 93%;
margin-left: 9px;
margin-right: auto;
border-radius: 5px;
border-top-left-radius: 0px;
margin-top: 3px;
left: 5px;
color: white;
overflow: hidden;
padding-bottom: 3px;
position: relative;

&.localuser .display-name {
color: #4C9AFF
}

&.error {
.chatArrow,
.timestamp,
.display-name {
display: none;
}

.usermessage {
color: red;
padding: 0;
}
}
}

.smiley {
height: 26px;
}

#smileys {
position: absolute;
bottom: 7px;
right: 5px;
background: white;
border-radius: 50px;
border-radius: 50%;
display: inline-block;
height: 26px;
margin: auto;
cursor: pointer;
Expand All @@ -187,33 +232,40 @@
}

#smileysarea {
position: absolute;
bottom: 0px;
left: 0px;
width: 17%;
background-color: $newToolbarBackgroundColor;
border: 0px none;
display: flex;
height: 70px;
max-height: 150px;
min-height: 35px;
min-width: 31px;
height: 40px;
padding: 0px;
max-height:150px;
min-height:35px;
border: 0px none;
background-color: $newToolbarBackgroundColor;
overflow: hidden;
visibility: hidden;
width: 17%;
}

#chat_container.is-conversation-mode #smileysarea {
visibility: visible;
.smiley-input {
position: relative;
}

#smileysContainer {
display: none;
.smileys-panel {
bottom: 100%;
box-sizing: border-box;
height: 0;
overflow: hidden;
position: absolute;
background-color: $newToolbarBackgroundColor;
border-bottom: 1px solid;
border-top: 1px solid;
width: 100%;
bottom: 10%;
transition: height 0.3s;
width: $sidebarWidth;

&.show-smileys {
height: 202px;
}

#smileysContainer {
background-color: $newToolbarBackgroundColor;
border-bottom: 1px solid;
border-top: 1px solid;
}
}

#smileysContainer .smiley {
Expand Down
Loading

0 comments on commit b7b43e8

Please sign in to comment.