fix unread count for topics with all messages deleted

This commit is contained in:
or-else
2025-04-10 16:20:33 +03:00
parent 4897d63029
commit 43fde20643
37 changed files with 8466 additions and 8855 deletions
+1 -1
View File
@@ -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";
+20 -7
View File
@@ -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) {