Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In-app unread message counter does not account for deleted messages #898

Open
errom502 opened this issue Feb 21, 2024 · 1 comment
Open
Labels

Comments

@errom502
Copy link

errom502 commented Feb 21, 2024

The change works correctly when the message is published, but when you publish a few messages and delete one or more messages, the counter doesn't change. Also if user1 is offline and user 2 does the same actions, when user 1 became online and he got incorrect counter anyway.
1m

2m

Possible server-side solution:
It's about case when user1 is offline and he needs to get correct unread msg count when he'll be online.
The problem of this solution is extra load on the database by one more query.
The result of this solution is correct unread count that can be send to the front-side.

  1. Counting the number of unread messages.
    This action have to be in {get} query, when we receive subs meta of "me" topic. (
    func (t *Topic) replyGetSub(sess *Session, asUid types.Uid, authLevel auth.Level, asChan bool, msg *ClientComMessage) error {
    ). In that function we use MsgTopicSub structure, this structure has fields "ReadSeqId" and "SeqId".
    unread_Count = Seqid - ReadSeqid
  2. Counting the number of deleted messages: make query into db and take seq of messages between ReadSeqid and Seqid.
  3. Counting the correct number.
    unread_Count - numb_of_deleted_msg

Tinode version: master 0.22.10

@errom502 errom502 added the bug label Feb 21, 2024
@or-else or-else changed the title changing the unread message counter In-app unread message counter does not account for deleted messages Feb 21, 2024
@or-else
Copy link
Contributor

or-else commented Feb 21, 2024

Yes, it's a known problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants