try re-sending pending messages on reconnect

This commit is contained in:
or-else
2018-10-06 11:47:41 +03:00
parent 44039f9a82
commit ca212fb038
+13 -4
View File
@@ -3866,21 +3866,26 @@ class MessagesView extends React.Component {
}); });
if (!topic.isSubscribed() && tryToResubscribe) { if (!topic.isSubscribed() && tryToResubscribe) {
// Don't request the tags. They are useless unless the user
// is the owner and is editing the topic.
let getQuery = topic.startMetaQuery() let getQuery = topic.startMetaQuery()
.withLaterDesc() .withLaterDesc()
.withLaterSub() .withLaterSub()
.withLaterData(MESSAGES_PAGE) .withLaterData(MESSAGES_PAGE)
.withLaterDel(); .withLaterDel();
let setQuery = newGroupTopic ? props.newGroupTopicParams : undefined; let setQuery = newGroupTopic ? props.newGroupTopicParams : undefined;
// Don't request the tags. They are useless unless the user
// is the owner and is editing the topic.
// getQuery = topic.getType() == 'grp' ? getQuery.withTags() : getQuery;
// Show "loading" spinner. // Show "loading" spinner.
this.setState({ fetchingMessages: true }); this.setState({ fetchingMessages: true });
topic.subscribe(getQuery.build(), setQuery) topic.subscribe(getQuery.build(), setQuery)
.then((ctrl) => { .then((ctrl) => {
this.setState({topic: ctrl.topic}); this.setState({topic: ctrl.topic});
this.props.onNewTopicCreated(props.topic, ctrl.topic); this.props.onNewTopicCreated(props.topic, ctrl.topic);
// If there are unsent messages, try sending them now.
topic.queuedMessages((pub) => {
if (!pub._sending) {
topic.publishMessage(pub);
}
});
}) })
.catch((err) => { .catch((err) => {
this.props.onError(err.message, "err"); this.props.onError(err.message, "err");
@@ -3889,7 +3894,11 @@ class MessagesView extends React.Component {
avatar: null, avatar: null,
readOnly: true, readOnly: true,
writeOnly: true, writeOnly: true,
fetchingMessages: false fetchingMessages: false,
messages: [],
onlineSubs: [],
typingIndicator: false,
imagePreview: null
}); });
}); });
} }