stream-chat-android icon indicating copy to clipboard operation
stream-chat-android copied to clipboard

getUnreadMessagesCount not working

Open lukicmarko opened this issue 2 years ago • 2 comments

Describe the bug getUnreadMessagesCount returns a valid number if get channel using chatClient.queryChannel but if I call chatClient.queryChannels it returns 0.

Working:

                  chatClient.queryChannel(
                      channelType = event.channelType,
                      channelId = event.channelId,
                      request = QueryChannelRequest().withState(),
                  ).enqueue { result ->
                      if (result.isSuccess) {
                          val channel = result.data()
                          val unreadCount = channel.getUnreadMessagesCount(forUserId = "myuserid") //Returns valid data

                     }
                 }

Not working:

        val request = QueryChannelsRequest(
            filter = Filters.and(
                Filters.eq("type", "messaging"),
                Filters.`in`("members", listOf("luciano3"))
            ),
            offset = 0,
            limit = 1000,
        ).withState().apply {
            // Watches the channels automatically
            watch = true
            state = true
        }

        chatClient.queryChannels(request).enqueue { result ->
            if (result.isSuccess) {
                val channels: List<Channel> = result.data()
                channels.forEach {
                    println("Channel: " + it.cid + "Unread count per channel: " + it.unreadCount)
                    val unreadCount = it.getUnreadMessagesCount(forUserId = "myuserid") //Returns 0
                }
            } else {
                // Handle result.error()
            }
        }

SDK version 5.17.6

To Reproduce Steps to reproduce the behavior: Send a message from one device to another (no chat screen is opened) Expected behavior expect that getUnreadMessagesCount returns number >0

Device: Vendor and model: Samsung Galaxy S8 Android version: 9 Vendor and model: Simulator Pixel 4 Android version: 13 (API 33)

lukicmarko avatar Aug 15 '23 11:08 lukicmarko

I am facing the same issue

shrutisaxenawebknot avatar Dec 01 '23 12:12 shrutisaxenawebknot

Is it solved in new version i.e. V6

Yatish1910 avatar Dec 26 '23 13:12 Yatish1910