fix unread count for topics with all messages deleted
This commit is contained in:
+1
-1
@@ -1,3 +1,3 @@
|
||||
// This is a generated file. Don't edit.
|
||||
|
||||
export const PACKAGE_VERSION = "0.23.0";
|
||||
export const PACKAGE_VERSION = "0.23.1";
|
||||
|
||||
@@ -605,8 +605,8 @@ class MessagesView extends React.Component {
|
||||
}
|
||||
|
||||
postReadNotification(seq) {
|
||||
// Ignore notifications if the app is invisible.
|
||||
if (!this.props.applicationVisible) {
|
||||
// Ignore notifications if the app is invisible or topic is not yet available.
|
||||
if (!this.props.applicationVisible || !this.state.topic) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -633,7 +633,9 @@ class MessagesView extends React.Component {
|
||||
if (n.sendAt <= now) {
|
||||
// Remove expired notification from queue.
|
||||
this.readNotificationQueue.shift();
|
||||
seq = Math.max(seq, n.seq);
|
||||
if (n.seq == 0 || Tinode.isServerAssignedSeq(n.seq)) {
|
||||
seq = Math.max(seq, n.seq);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -643,7 +645,11 @@ class MessagesView extends React.Component {
|
||||
if (seq >= 0) {
|
||||
const topic = this.props.tinode.getTopic(this.state.topic);
|
||||
if (topic) {
|
||||
topic.noteRead(seq);
|
||||
try {
|
||||
topic.noteRead(seq);
|
||||
} catch (err) {
|
||||
console.error("Failed to send read notification", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, NOTIFICATION_EXEC_INTERVAL);
|
||||
@@ -732,10 +738,17 @@ class MessagesView extends React.Component {
|
||||
|
||||
handleAllMessagesReceived(count) {
|
||||
this.setState({fetchingMessages: false});
|
||||
if (count > 0) {
|
||||
// 0 means "latest".
|
||||
this.postReadNotification(0);
|
||||
if (!count) {
|
||||
// All messages received. Nothing left to receive.
|
||||
const topic = this.props.tinode.getTopic(this.state.topic);
|
||||
if (topic) {
|
||||
// Send read notification for the absolute last message.
|
||||
this.postReadNotification(topic.seq);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// 0 means "latest received".
|
||||
this.postReadNotification(0);
|
||||
}
|
||||
|
||||
handleInfoReceipt(info) {
|
||||
|
||||
Reference in New Issue
Block a user