mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2025-12-30 11:22:31 +00:00
- 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).
143 lines
3.5 KiB
JavaScript
143 lines
3.5 KiB
JavaScript
// @flow
|
|
|
|
import { FieldTextStateless } from '@atlaskit/field-text';
|
|
import React, { Component } from 'react';
|
|
import { connect } from 'react-redux';
|
|
|
|
import { translate } from '../../base/i18n';
|
|
import {
|
|
getLocalParticipant,
|
|
participantDisplayNameChanged
|
|
} from '../../base/participants';
|
|
|
|
/**
|
|
* The type of the React {@code Component} props of {@DisplayNameForm}.
|
|
*/
|
|
type Props = {
|
|
|
|
/**
|
|
* The ID of the local participant.
|
|
*/
|
|
_localParticipantId: string,
|
|
|
|
/**
|
|
* Invoked to set the local participant display name.
|
|
*/
|
|
dispatch: Dispatch<*>,
|
|
|
|
/**
|
|
* Invoked to obtain translated strings.
|
|
*/
|
|
t: Function
|
|
};
|
|
|
|
/**
|
|
* The type of the React {@code Component} state of {@DisplayNameForm}.
|
|
*/
|
|
type State = {
|
|
|
|
/**
|
|
* User provided display name when the input text is provided in the view.
|
|
*/
|
|
displayName: string
|
|
};
|
|
|
|
/**
|
|
* React Component for requesting the local participant to set a display name.
|
|
*
|
|
* @extends Component
|
|
*/
|
|
class DisplayNameForm extends Component<Props, State> {
|
|
state = {
|
|
displayName: ''
|
|
};
|
|
|
|
/**
|
|
* Initializes a new {@code DisplayNameForm} instance.
|
|
*
|
|
* @param {Object} props - The read-only properties with which the new
|
|
* instance is to be initialized.
|
|
*/
|
|
constructor(props: Props) {
|
|
super(props);
|
|
|
|
// Bind event handlers so they are only bound once for every instance.
|
|
this._onDisplayNameChange = this._onDisplayNameChange.bind(this);
|
|
this._onSubmit = this._onSubmit.bind(this);
|
|
}
|
|
|
|
/**
|
|
* Implements React's {@link Component#render()}.
|
|
*
|
|
* @inheritdoc
|
|
* @returns {ReactElement}
|
|
*/
|
|
render() {
|
|
const { t } = this.props;
|
|
|
|
return (
|
|
<div id = 'nickname'>
|
|
<span>{ this.props.t('chat.nickname.title') }</span>
|
|
<form onSubmit = { this._onSubmit }>
|
|
<FieldTextStateless
|
|
autoFocus = { true }
|
|
id = 'nickinput'
|
|
onChange = { this._onDisplayNameChange }
|
|
placeholder = { t('chat.nickname.popover') }
|
|
type = 'text'
|
|
value = { this.state.displayName } />
|
|
</form>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
_onDisplayNameChange: (Object) => void;
|
|
|
|
/**
|
|
* Dispatches an action update the entered display name.
|
|
*
|
|
* @param {event} event - Keyboard event.
|
|
* @private
|
|
* @returns {void}
|
|
*/
|
|
_onDisplayNameChange(event: Object) {
|
|
this.setState({ displayName: event.target.value });
|
|
}
|
|
|
|
_onSubmit: (Object) => void;
|
|
|
|
/**
|
|
* Dispatches an action to hit enter to change your display name.
|
|
*
|
|
* @param {event} event - Keyboard event
|
|
* that will check if user has pushed the enter key.
|
|
* @private
|
|
* @returns {void}
|
|
*/
|
|
_onSubmit(event: Object) {
|
|
event.preventDefault();
|
|
|
|
this.props.dispatch(participantDisplayNameChanged(
|
|
this.props._localParticipantId,
|
|
this.state.displayName));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Maps (parts of) the Redux state to the associated props for the
|
|
* {@code DisplayNameForm} component.
|
|
*
|
|
* @param {Object} state - The Redux state.
|
|
* @private
|
|
* @returns {{
|
|
* _localParticipantId: string
|
|
* }}
|
|
*/
|
|
function _mapStateToProps(state) {
|
|
return {
|
|
_localParticipantId: getLocalParticipant(state).id
|
|
};
|
|
}
|
|
|
|
export default translate(connect(_mapStateToProps)(DisplayNameForm));
|