Skip to content

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

Open
@errom502

Description

@errom502

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions