merge conflict resolved

This commit is contained in:
or-else
2022-07-19 08:55:44 -07:00
6 changed files with 55 additions and 7 deletions
+17 -2
View File
@@ -403,15 +403,25 @@ class MessagesView extends React.Component {
this.setState({topic: ctrl.topic}); this.setState({topic: ctrl.topic});
} }
this.props.onNewTopicCreated(this.props.topic, ctrl.topic); this.props.onNewTopicCreated(this.props.topic, ctrl.topic);
// If there are unsent messages, try sending them now. // 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) => { topic.queuedMessages((pub) => {
if (pub._sending) { if (pub._sending) {
return; return;
} }
if (pub.head && pub.head.webrtc) {
// Filter out unsent video call messages.
calls.push(pub.seq);
return;
}
if (topic.isSubscribed()) { if (topic.isSubscribed()) {
this.retrySend(pub); this.retrySend(pub);
} }
}); });
if (calls.length > 0) {
topic.delMessagesList(calls, true);
}
}) })
.catch((err) => { .catch((err) => {
console.error("Failed subscription to", this.state.topic, err); console.error("Failed subscription to", this.state.topic, err);
@@ -760,7 +770,12 @@ class MessagesView extends React.Component {
// Retry sending a message. // Retry sending a message.
retrySend(pub) { retrySend(pub) {
this.props.sendMessage(pub.content, undefined, undefined, pub.head); this.props.sendMessage(pub.content, undefined, undefined, pub.head)
.then(() => {
// All good. Remove the original message draft from the cache.
const topic = this.props.tinode.getTopic(this.state.topic);
topic.delMessagesList([pub.seq], true);
});
} }
// Send attachment as Drafty message: // Send attachment as Drafty message:
+11 -1
View File
@@ -1007,15 +1007,25 @@ class TinodeWeb extends React.Component {
const subscribePromise = const subscribePromise =
topic.subscribe() topic.subscribe()
.then(() => { .then(() => {
// If there are unsent messages, try sending them now. // 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 => { topic.queuedMessages(pub => {
if (pub._sending || pub.seq == msg.seq) { if (pub._sending || pub.seq == msg.seq) {
return; return;
} }
if (pub.head && pub.head.webrtc) {
// Filter out unsent video call messages.
calls.push(pub.seq);
return;
}
if (topic.isSubscribed()) { if (topic.isSubscribed()) {
topic.publishMessage(pub); topic.publishMessage(pub);
} }
}); });
if (calls.length > 0) {
topic.delMessagesList(calls, true);
}
}); });
completion.push(subscribePromise); completion.push(subscribePromise);
} }
+24 -1
View File
@@ -5855,15 +5855,25 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
} }
this.props.onNewTopicCreated(this.props.topic, ctrl.topic); this.props.onNewTopicCreated(this.props.topic, ctrl.topic);
let calls = [];
topic.queuedMessages(pub => { topic.queuedMessages(pub => {
if (pub._sending) { if (pub._sending) {
return; return;
} }
if (pub.head && pub.head.webrtc) {
calls.push(pub.seq);
return;
}
if (topic.isSubscribed()) { if (topic.isSubscribed()) {
this.retrySend(pub); this.retrySend(pub);
} }
}); });
if (calls.length > 0) {
topic.delMessagesList(calls, true);
}
}).catch(err => { }).catch(err => {
console.error("Failed subscription to", this.state.topic, err); console.error("Failed subscription to", this.state.topic, err);
this.props.onError(err.message, 'err'); this.props.onError(err.message, 'err');
@@ -6245,7 +6255,10 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
} }
retrySend(pub) { retrySend(pub) {
this.props.sendMessage(pub.content, undefined, undefined, pub.head); this.props.sendMessage(pub.content, undefined, undefined, pub.head).then(() => {
const topic = this.props.tinode.getTopic(this.state.topic);
topic.delMessagesList([pub.seq], true);
});
} }
sendFileAttachment(file) { sendFileAttachment(file) {
@@ -8586,15 +8599,25 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
if (!topic.isSubscribed()) { if (!topic.isSubscribed()) {
const subscribePromise = topic.subscribe().then(() => { const subscribePromise = topic.subscribe().then(() => {
let calls = [];
topic.queuedMessages(pub => { topic.queuedMessages(pub => {
if (pub._sending || pub.seq == msg.seq) { if (pub._sending || pub.seq == msg.seq) {
return; return;
} }
if (pub.head && pub.head.webrtc) {
calls.push(pub.seq);
return;
}
if (topic.isSubscribed()) { if (topic.isSubscribed()) {
topic.publishMessage(pub); topic.publishMessage(pub);
} }
}); });
if (calls.length > 0) {
topic.delMessagesList(calls, true);
}
}); });
completion.push(subscribePromise); completion.push(subscribePromise);
} }
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long