Skip to content

Commit 43fde20

Browse files
committed
fix unread count for topics with all messages deleted
1 parent 4897d63 commit 43fde20

37 files changed

+9230
-9619
lines changed

package-lock.json

Lines changed: 723 additions & 680 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tinode-webapp",
33
"description": "Tinode messenger for the web",
4-
"version": "0.23.0",
4+
"version": "0.23.1",
55
"repository": {
66
"type": "git",
77
"url": "git+https://github.com/tinode/webapp.git"
@@ -72,7 +72,7 @@
7272
"react": "^18.2.0",
7373
"react-dom": "^18.2.0",
7474
"react-intl": "^6.4.4",
75-
"tinode-sdk": "^0.23.0",
75+
"tinode-sdk": "^0.23.1",
7676
"webm-duration-fix": "^1.0.4"
7777
},
7878
"devDependencies": {
@@ -84,11 +84,11 @@
8484
"babel-plugin-formatjs": "^10.5.3",
8585
"browserslist": "^4.21.10",
8686
"copy-webpack-plugin": "^11.0.0",
87-
"cssnano": "^6.0.1",
88-
"glob": "^10.3.3",
87+
"cssnano": "^7.0.0",
88+
"glob": "^11.0.0",
8989
"postcss": "^8.4.27",
90-
"postcss-cli": "^10.1.0",
90+
"postcss-cli": "^11.0.0",
9191
"webpack": "^5.88.2",
92-
"webpack-cli": "^5.1.4"
92+
"webpack-cli": "^6.0.0"
9393
}
9494
}

src/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This is a generated file. Don't edit.
22

3-
export const PACKAGE_VERSION = "0.23.0";
3+
export const PACKAGE_VERSION = "0.23.1";

src/views/messages-view.jsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,8 @@ class MessagesView extends React.Component {
605605
}
606606

607607
postReadNotification(seq) {
608-
// Ignore notifications if the app is invisible.
609-
if (!this.props.applicationVisible) {
608+
// Ignore notifications if the app is invisible or topic is not yet available.
609+
if (!this.props.applicationVisible || !this.state.topic) {
610610
return;
611611
}
612612

@@ -633,7 +633,9 @@ class MessagesView extends React.Component {
633633
if (n.sendAt <= now) {
634634
// Remove expired notification from queue.
635635
this.readNotificationQueue.shift();
636-
seq = Math.max(seq, n.seq);
636+
if (n.seq == 0 || Tinode.isServerAssignedSeq(n.seq)) {
637+
seq = Math.max(seq, n.seq);
638+
}
637639
} else {
638640
break;
639641
}
@@ -643,7 +645,11 @@ class MessagesView extends React.Component {
643645
if (seq >= 0) {
644646
const topic = this.props.tinode.getTopic(this.state.topic);
645647
if (topic) {
646-
topic.noteRead(seq);
648+
try {
649+
topic.noteRead(seq);
650+
} catch (err) {
651+
console.error("Failed to send read notification", err);
652+
}
647653
}
648654
}
649655
}, NOTIFICATION_EXEC_INTERVAL);
@@ -732,10 +738,17 @@ class MessagesView extends React.Component {
732738

733739
handleAllMessagesReceived(count) {
734740
this.setState({fetchingMessages: false});
735-
if (count > 0) {
736-
// 0 means "latest".
737-
this.postReadNotification(0);
741+
if (!count) {
742+
// All messages received. Nothing left to receive.
743+
const topic = this.props.tinode.getTopic(this.state.topic);
744+
if (topic) {
745+
// Send read notification for the absolute last message.
746+
this.postReadNotification(topic.seq);
747+
}
748+
return;
738749
}
750+
// 0 means "latest received".
751+
this.postReadNotification(0);
739752
}
740753

741754
handleInfoReceipt(info) {

umd/271.prod.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

umd/271.prod.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

umd/316.prod.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)