More UI tweaks (calls).

1. Localize video call messages.
2. Display call message previews correctly.
This commit is contained in:
aforge
2022-04-21 21:10:00 -07:00
parent ad98bec73e
commit 0daef53c87
5 changed files with 33 additions and 7 deletions
+5
View File
@@ -204,3 +204,8 @@ export function cancelablePromise(promise) {
}, },
}; };
}; };
// Returns true if specified mime type represents a Tinode video call.
export function isVideoCall(mime) {
return mime == 'application/tinode-video-call';
}
+12 -5
View File
@@ -9,7 +9,7 @@ import LetterTile from './letter-tile.jsx';
import ReceivedMarker from './received-marker.jsx' import ReceivedMarker from './received-marker.jsx'
import { fullFormatter } from '../lib/formatters.js'; import { fullFormatter } from '../lib/formatters.js';
import { sanitizeUrl } from '../lib/utils.js'; import { isVideoCall, sanitizeUrl } from '../lib/utils.js';
class BaseChatMessage extends React.PureComponent { class BaseChatMessage extends React.PureComponent {
constructor(props) { constructor(props) {
@@ -147,12 +147,19 @@ class BaseChatMessage extends React.PureComponent {
<FormattedMessage id="deleted_content" <FormattedMessage id="deleted_content"
defaultMessage="content deleted" description="Shown when messages are deleted" /> defaultMessage="content deleted" description="Shown when messages are deleted" />
</i></> </i></>
} else if (this.props.mimeType == "application/tinode-video-call") { } else if (isVideoCall(this.props.mimeType)) {
// Video calls. // Video calls.
const direction = this.props.response ? "call_received" : "call_made"; const direction = this.props.response ? "call_received" : "call_made";
const text = this.props.response ? "Incoming Call" : "Outgoing Call"; const text = this.props.response ?
content = <><i className="material-icons" style={{color:this.props.content == "disconnected" ? "red" : "green"}}>{direction}</i>{text} <FormattedMessage id="calls_incoming"
(<FormattedDuration seconds={this.props.duration / 1000} format="{hours} {minutes} {seconds}" />) defaultMessage="Incoming Call" description="Incoming call label" /> :
<FormattedMessage id="calls_outgoing"
defaultMessage="Outgoing Call" description="Outgoing call label" />;
const isCallDropped = this.props.content == "disconnected";
content = <><i className="material-icons" style={{color: isCallDropped ? "red" : "green"}}>{direction}</i>{text}
{ !isCallDropped ?
[' (', <FormattedDuration seconds={this.props.duration / 1000} format="{hours} {minutes} {seconds}" />, ')'] :
null}
</> </>
} else if (typeof content != 'string') { } else if (typeof content != 'string') {
content = <><i className="material-icons gray">warning_amber</i> <i className="gray"> content = <><i className="material-icons gray">warning_amber</i> <i className="gray">
+7
View File
@@ -10,6 +10,7 @@ import Contact from './contact.jsx';
import ContactAction from './contact-action.jsx'; import ContactAction from './contact-action.jsx';
import { makeImageUrl } from '../lib/blob-helpers.js'; import { makeImageUrl } from '../lib/blob-helpers.js';
import { isVideoCall } from '../lib/utils.js'
import { MESSAGE_PREVIEW_LENGTH } from '../config.js'; import { MESSAGE_PREVIEW_LENGTH } from '../config.js';
@@ -78,12 +79,16 @@ class ContactList extends React.Component {
c.private.join(',') : (c.private ? c.private.comment : null); c.private.join(',') : (c.private ? c.private.comment : null);
let preview; let preview;
let forwarded; let forwarded;
let previewIsVideoCall;
let previewIsResponse;
let deliveryStatus; let deliveryStatus;
if (!this.props.showMode && c.latestMessage) { if (!this.props.showMode && c.latestMessage) {
const msg = c.latestMessage(true); const msg = c.latestMessage(true);
if (msg) { if (msg) {
forwarded = msg.head ? msg.head.forwarded : null; forwarded = msg.head ? msg.head.forwarded : null;
deliveryStatus = msg._status || c.msgStatus(msg, true); deliveryStatus = msg._status || c.msgStatus(msg, true);
previewIsVideoCall = msg.head ? isVideoCall(msg.head.mime) : null;
previewIsResponse = msg.from != this.props.myUserId;
if (msg.content) { if (msg.content) {
preview = typeof msg.content == 'string' ? preview = typeof msg.content == 'string' ?
msg.content.substr(0, MESSAGE_PREVIEW_LENGTH) : msg.content.substr(0, MESSAGE_PREVIEW_LENGTH) :
@@ -99,6 +104,8 @@ class ContactList extends React.Component {
avatar={makeImageUrl(c.public ? c.public.photo : null)} avatar={makeImageUrl(c.public ? c.public.photo : null)}
comment={comment} comment={comment}
preview={preview} preview={preview}
previewIsVideoCall={previewIsVideoCall}
previewIsResponse={previewIsResponse}
forwarded={forwarded} forwarded={forwarded}
received={deliveryStatus} received={deliveryStatus}
unread={this.props.showUnread ? c.unread : 0} unread={this.props.showUnread ? c.unread : 0}
+4 -1
View File
@@ -71,7 +71,10 @@ class Contact extends React.Component {
// The this.props.preview contains alreay shortened Drafty or string. // The this.props.preview contains alreay shortened Drafty or string.
let preview; let preview;
if (typeof this.props.preview == 'string') { if (this.props.previewIsVideoCall) {
preview = <><i className='material-icons'>{this.props.previewIsResponse ? 'call_received' : 'call_made'}</i>
<i className='material-icons'>video_call</i></>;
} else if (typeof this.props.preview == 'string') {
preview = this.props.preview; preview = this.props.preview;
} else if (Drafty.isValid(this.props.preview)) { } else if (Drafty.isValid(this.props.preview)) {
preview = React.createElement(React.Fragment, null, Drafty.format(this.props.preview, previewFormatter, preview = React.createElement(React.Fragment, null, Drafty.format(this.props.preview, previewFormatter,
+5 -1
View File
@@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import { FormattedMessage } from 'react-intl';
import LetterTile from '../widgets/letter-tile.jsx'; import LetterTile from '../widgets/letter-tile.jsx';
@@ -363,7 +364,10 @@ export default class RtcPanel extends React.PureComponent {
<div className="video-container-panel"> <div className="video-container-panel">
<div className="video-elem"> <div className="video-elem">
<video id="localVideo" ref={this.localRef} autoPlay muted playsInline></video> <video id="localVideo" ref={this.localRef} autoPlay muted playsInline></video>
<div className="video-title">You</div> <div className="video-title">
<FormattedMessage id="calls_you_label"
defaultMessage="You" description="Shown over the local video screen" />
</div>
</div> </div>
<div className="video-elem"> <div className="video-elem">
<video id="remoteVideo" ref={this.remoteRef} autoPlay playsInline></video> <video id="remoteVideo" ref={this.remoteRef} autoPlay playsInline></video>