Skip to content

Commit

Permalink
fix issues with video uploading and display
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Feb 6, 2023
1 parent fc2ff79 commit eeea27c
Show file tree
Hide file tree
Showing 13 changed files with 190 additions and 166 deletions.
1 change: 1 addition & 0 deletions src/lib/utils.js
Expand Up @@ -172,6 +172,7 @@ export function deliveryMarker(received) {
case Tinode.MESSAGE_STATUS_SENDING:
return { name: 'access_time' }; // watch face
case Tinode.MESSAGE_STATUS_FAILED:
case Tinode.MESSAGE_STATUS_FATAL:
return { name: 'warning', color: 'danger-color' }; // yellow icon /!\
case Tinode.MESSAGE_STATUS_SENT:
return { name: 'done' }; // checkmark
Expand Down
21 changes: 11 additions & 10 deletions src/views/messages-view.jsx
Expand Up @@ -457,24 +457,24 @@ class MessagesView extends React.Component {
this.setState({topic: ctrl.topic});
}
this.props.onNewTopicCreated(this.props.topic, ctrl.topic);
// If there are unsent messages (except video call messages),
// try sending them now. Unsent video call messages will be dropped.
let calls = [];
topic.queuedMessages((pub) => {
// If there are unsent messages (except hard-failed and video call messages),
// try sending them now. Hard-failed and unsent video call messages will be dropped.
let discard = [];
topic.queuedMessages(pub => {
if (pub._sending) {
return;
}
if (pub.head && pub.head.webrtc) {
// Filter out unsent video call messages.
calls.push(pub.seq);
if (pub._fatal || (pub.head && pub.head.webrtc)) {
// Filter out unsent failed & video call messages.
discard.push(pub.seq);
return;
}
if (topic.isSubscribed()) {
this.retrySend(pub);
}
});
if (calls.length > 0) {
topic.delMessagesList(calls, true);
if (discard.length > 0) {
topic.delMessagesList(discard, true);
}
})
.catch(err => {
Expand Down Expand Up @@ -1057,8 +1057,8 @@ class MessagesView extends React.Component {
// Small preview to show while uploading.
b64conv[2] = imageScaled(previewBlob, VIDEO_PREVIEW_DIM, VIDEO_PREVIEW_DIM, -1, false)
.then(scaled => blobToBase64(scaled.blob));
// Convert tiny image into base64 for serialization and previewing.
Promise.all(b64conv)
// Convert tiny image into base64 for serialization and previewing.
.then(b64s => {
const [video, img, preview] = b64s;
let msg = Drafty.insertVideo(null, 0, {
Expand All @@ -1074,6 +1074,7 @@ class MessagesView extends React.Component {
size: videoBlob.size,
urlPromise: uploadCompletionPromise
});

if (caption) {
msg = Drafty.appendLineBreak(msg);
msg = Drafty.append(msg, Drafty.parse(caption));
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/chat-message.jsx
Expand Up @@ -93,7 +93,7 @@ class BaseChatMessage extends React.PureComponent {
if (this.props.received == Tinode.MESSAGE_STATUS_FAILED) {
menuItems.push('menu_item_send_retry');
}
if (this.props.userIsWriter && this.props.received > Tinode.MESSAGE_STATUS_FAILED) {
if (this.props.userIsWriter && this.props.received > Tinode.MESSAGE_STATUS_FATAL) {
menuItems.push('menu_item_reply');
if (!this.props.response) {
let immutable = false;
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/inline-video.jsx
Expand Up @@ -31,7 +31,7 @@ export default class InlineVideo extends React.PureComponent {
{this.props.onClick ?
<i className="material-icons white bigger">play_arrow</i>
:
<img src="img/broken_video.png" width="36" height="36" />}
<img src="img/broken_video.png" style={{filter: 'invert(100%)'}} width="36" height="36" />}
</div>
{duration ? <div className="duration">{duration}</div> : null}
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/widgets/received-marker.jsx
Expand Up @@ -30,7 +30,8 @@ class ReceivedMarker extends React.PureComponent {
let timestamp;
if (this.props.received <= Tinode.MESSAGE_STATUS_SENDING) {
timestamp = formatMessage(messages.message_sending);
} else if (this.props.received == Tinode.MESSAGE_STATUS_FAILED) {
} else if (this.props.received == Tinode.MESSAGE_STATUS_FAILED ||
this.props.received == Tinode.MESSAGE_STATUS_FATAL) {
timestamp = formatMessage(messages.message_sending_failed);
} else {
timestamp = this.props.timestamp.toLocaleTimeString(this.props.intl.locale, { timeStyle: 'short' });
Expand Down
18 changes: 11 additions & 7 deletions umd/index.dev.js
Expand Up @@ -3525,6 +3525,7 @@ function deliveryMarker(received) {
name: 'access_time'
};
case tinode_sdk__WEBPACK_IMPORTED_MODULE_0__.Tinode.MESSAGE_STATUS_FAILED:
case tinode_sdk__WEBPACK_IMPORTED_MODULE_0__.Tinode.MESSAGE_STATUS_FATAL:
return {
name: 'warning',
color: 'danger-color'
Expand Down Expand Up @@ -5458,21 +5459,21 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
});
}
this.props.onNewTopicCreated(this.props.topic, ctrl.topic);
let calls = [];
let discard = [];
topic.queuedMessages(pub => {
if (pub._sending) {
return;
}
if (pub.head && pub.head.webrtc) {
calls.push(pub.seq);
if (pub._fatal || pub.head && pub.head.webrtc) {
discard.push(pub.seq);
return;
}
if (topic.isSubscribed()) {
this.retrySend(pub);
}
});
if (calls.length > 0) {
topic.delMessagesList(calls, true);
if (discard.length > 0) {
topic.delMessagesList(discard, true);
}
}).catch(err => {
console.error("Failed subscription to", this.state.topic, err);
Expand Down Expand Up @@ -11030,7 +11031,7 @@ class BaseChatMessage extends (react__WEBPACK_IMPORTED_MODULE_0___default().Pure
if (this.props.received == tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Tinode.MESSAGE_STATUS_FAILED) {
menuItems.push('menu_item_send_retry');
}
if (this.props.userIsWriter && this.props.received > tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Tinode.MESSAGE_STATUS_FAILED) {
if (this.props.userIsWriter && this.props.received > tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Tinode.MESSAGE_STATUS_FATAL) {
menuItems.push('menu_item_reply');
if (!this.props.response) {
let immutable = false;
Expand Down Expand Up @@ -13590,6 +13591,9 @@ class InlineVideo extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureComp
className: "material-icons white bigger"
}, "play_arrow") : react__WEBPACK_IMPORTED_MODULE_0___default().createElement("img", {
src: "img/broken_video.png",
style: {
filter: 'invert(100%)'
},
width: "36",
height: "36"
})), duration ? react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
Expand Down Expand Up @@ -14667,7 +14671,7 @@ class ReceivedMarker extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureC
let timestamp;
if (this.props.received <= tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Tinode.MESSAGE_STATUS_SENDING) {
timestamp = formatMessage(messages.message_sending);
} else if (this.props.received == tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Tinode.MESSAGE_STATUS_FAILED) {
} else if (this.props.received == tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Tinode.MESSAGE_STATUS_FAILED || this.props.received == tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Tinode.MESSAGE_STATUS_FATAL) {
timestamp = formatMessage(messages.message_sending_failed);
} else {
timestamp = this.props.timestamp.toLocaleTimeString(this.props.intl.locale, {
Expand Down
2 changes: 1 addition & 1 deletion umd/index.dev.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion umd/index.prod.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion umd/index.prod.js.map

Large diffs are not rendered by default.

0 comments on commit eeea27c

Please sign in to comment.