Skip to content

Conversation

VelikovPetar
Copy link
Contributor

🎯 Goal

We are incorrectly increasing the channel unread count locally for muted channels on message.new and notification.message_new events. This PR fixes that behaviour and aligns the behaviour to iOS and follows the documentation: https://getstream.io/chat/docs/android/muting_channels/

Additionally, it fixes a bug where the channelState.muted state was not initially set properly after QueryChannels.

Resolves: https://linear.app/stream/issue/AND-736/analyse-wrong-unread-count-for-muted-channels

🛠 Implementation details

  • Prevents increasing of the local unread count for the channel if the channel is muted
  • Syncs the mute state when the ChannelLogicState is initialised, to ensure that the correct state is present at all times

🎨 UI Changes

Before After
before.mov
after.mov

🧪 Testing

  1. Mute a channel
  2. Write messages in the same channel from a different user
  3. Ensure the unread count is not increased (verify by reloading the channel list)

@VelikovPetar VelikovPetar requested a review from Copilot October 3, 2025 16:32
@VelikovPetar VelikovPetar marked this pull request as ready for review October 3, 2025 16:32
@VelikovPetar VelikovPetar requested a review from a team as a code owner October 3, 2025 16:32
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes incorrect behavior where unread counts were being increased for muted channels, aligning Android behavior with iOS and documentation. It prevents local unread count increases for muted channels and ensures proper mute state initialization.

  • Prevents unread count increases for muted channels in updateCurrentUserRead
  • Adds initialization of mute state in ChannelStateLogic constructor
  • Renames and improves mute state synchronization method

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
ChannelStateLogic.kt Main fix to prevent unread count increases for muted channels and initialize mute state
ChannelLogic.kt Updates method call to use renamed syncMuteState method
ChannelStateLogicTest.kt Adds comprehensive test coverage for muted channel behavior
CHANGELOG.md Documents the bug fix in changelog

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

mutableState.read.value
?.takeUnless { it.lastReceivedEventDate.after(eventReceivedDate) }
?.takeUnless { processedMessageIds.get(message.id) == true }
?.takeUnless { processedMessageIds[message.id] == true }
Copy link
Preview

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This change from .get(message.id) to [message.id] is functionally equivalent but the original .get() method was more explicit about the operation being performed on what appears to be a cache/map structure.

Suggested change
?.takeUnless { processedMessageIds[message.id] == true }
?.takeUnless { processedMessageIds.get(message.id) == true }

Copilot uses AI. Check for mistakes.

Copy link
Contributor

github-actions bot commented Oct 3, 2025

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 3.23 MB 3.23 MB 0.00 MB 🟢
stream-chat-android-offline 3.45 MB 3.45 MB 0.00 MB 🟢
stream-chat-android-ui-components 10.53 MB 10.53 MB 0.00 MB 🟢
stream-chat-android-compose 12.75 MB 12.75 MB 0.00 MB 🟢

Copy link

sonarqubecloud bot commented Oct 3, 2025

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

Successfully merging this pull request may close these issues.

2 participants