Skip to content

Message members from the member bottom sheet of channel info screen #5797

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

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

andremion
Copy link
Contributor

@andremion andremion commented May 28, 2025

🎯 Goal

Support messaging a member from the group channel info screen

🛠 Implementation details

Messaging a member from the group channel info screen can enter two possible funnels:

  • When there is an existing direct channel between the current user and the clicked member, the app navigates directly to the messages screen.
  • When there is no direct channel for those users, the app opens a draft channel screen, and after sending the first message, the channel is converted to a non-draft channel and navigates to the messages screen.

The draft view controller and its state, and events are part of the ui-common, so it can be reused by the ui-components SDK. The draft screens and view model are not.

🎨 UI Changes

Starting a new chat Messaging an existing chat
phone_new_message.webm
phone_more_messages.webm

🧪 Testing

  • Open a group chat
  • Click on the top bar title
  • Click on a member
  • Click on the Message option in the member bottom sheet

🎉 GIF

gif

@andremion andremion added the compose Jetpack Compose label May 28, 2025
@andremion andremion requested a review from Copilot May 28, 2025 09:36
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 adds messaging functionality from the member modal sheet on the channel info screen. Key changes include new tests for handling member message events (with and without distinct channels), updates to view events and controllers to support direct channel creation/navigation, and adjustments to UI layout in compose screens and sample activities to facilitate the new behavior.

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoViewControllerTest.kt Added tests to verify message member events, covering distinct and non-distinct channel scenarios.
stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoMemberViewControllerTest.kt Modified tests to check the updated MessageMember event with member and distinct channel properties.
stream-chat-android-ui-common/src/main/res/values/strings.xml Introduced a new error string for direct channel creation failures.
stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoViewEvent.kt Added NavigateToChannel event and a NewDirectChannelError to better indicate messaging navigation outcomes.
stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoViewController.kt Updated onMemberViewEvent to conditionally create a direct channel if no distinct channel is provided, ensuring proper message navigation.
stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoMemberViewEvent.kt Updated the MessageMember event to use memberId and distinctCid for clearer messaging intent.
stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoMemberViewController.kt Refactored state management to query for distinct channels and update options accordingly.
stream-chat-android-compose/... Adjusted mandatory UI modifiers and navigation parameters in compose screens and sample activities for improved layout and navigation handling.

Copy link
Contributor

github-actions bot commented May 28, 2025

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 3.16 MB 3.16 MB 0.00 MB 🟢
stream-chat-android-offline 3.38 MB 3.38 MB 0.00 MB 🟢
stream-chat-android-ui-components 10.39 MB 10.42 MB 0.03 MB 🟢
stream-chat-android-compose 12.46 MB 12.51 MB 0.05 MB 🟢

@andremion andremion force-pushed the AND-567-message-members-from-the-member-modal-sheet-of-channel-info-screen branch from ca9cbd2 to df73b7c Compare May 29, 2025 07:54
@andremion andremion requested a review from Copilot May 29, 2025 08:07
@andremion andremion marked this pull request as ready for review May 29, 2025 08:07
@andremion andremion requested a review from a team as a code owner May 29, 2025 08:07
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 introduces the functionality for messaging a member from the group channel info screen by adding a new event with member-specific parameters and by incorporating a draft channel flow when no direct channel exists. It also refactors the state management in the ChannelInfoMemberViewController and updates several Compose UI screens and navigation flows to support the draft channel funnel.

Reviewed Changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoMemberViewEvent.kt Updated MessageMember event with new parameters (memberId and distinctCid) for improved navigation handling.
stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoMemberViewController.kt Refactored state flow by replacing an internal MutableStateFlow with a flow transformation that now includes querying for a distinct channel.
stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/channel/draft/* Introduced draft channel events, actions, and a dedicated view controller and view state to support the draft channel funnel when messaging a member.
stream-chat-android-compose/* and sample modules Updated UI components, navigation flows, and API interfaces to integrate the new messaging and draft channel functionality.
stream-chat-android-compose-sample/src/main/AndroidManifest.xml Registered the new DraftChannelActivity.

Comment on lines +89 to +91
}.map { (channelData, member, distinctChannel) ->
this.member = member
this.distinctCid = distinctChannel?.cid
Copy link
Preview

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

Avoid performing side-effects (e.g. updating 'this.member' and 'this.distinctCid') inside flow transformation functions. Consider assigning these values to local variables and handling side-effects separately to improve clarity and avoid potential concurrency issues.

Copilot uses AI. Check for mistakes.

}

runCatching {
requireNotNull(chatClient.getCurrentUser()?.id) { "User not connected" }
Copy link
Preview

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

Consider handling the case where currentUser might be null more gracefully so that the flow always emits a value (or error event) rather than relying solely on a requireNotNull check that may throw. This could help maintain a consistent flow state in scenarios where the user is disconnected.

Copilot uses AI. Check for mistakes.

@andremion andremion changed the title Message members from the member modal sheet of channel info screen Message members from the member bottom sheet of channel info screen May 29, 2025
@andremion andremion force-pushed the AND-567-message-members-from-the-member-modal-sheet-of-channel-info-screen branch 2 times, most recently from 92b9fdf to cfb57f5 Compare May 30, 2025 12:47
@andremion andremion force-pushed the AND-556-compose-members-info-flow-of-the-channel-info-screen branch from b2cb345 to c8d360f Compare May 30, 2025 12:52
@andremion andremion force-pushed the AND-567-message-members-from-the-member-modal-sheet-of-channel-info-screen branch from cfb57f5 to 5275e91 Compare May 30, 2025 12:53
Base automatically changed from AND-556-compose-members-info-flow-of-the-channel-info-screen to develop June 4, 2025 09:34
andremion added 12 commits June 4, 2025 10:36
…teIn`

This commit refactors the `state` property in `ChannelInfoMemberViewController` to utilize the `stateIn` operator. This simplifies the state management by directly transforming the upstream flow into a `StateFlow`.

The `onChannelInfoData` function is removed as its logic is now incorporated into the `map` operation within the `stateIn` flow.
The `channelId` parameter, representing only the ID part of a channel identifier, has been replaced with `cid` or `distinctCid`, which represent the full channel identifier (e.g., `messaging:channelId`).

This change affects:
- `ChannelInfoViewEvent.NavigateToChannel`
- `ChannelInfoMemberViewEvent.MessageMember`
- Related event handling in `ChannelInfoViewController` and `ChannelInfoMemberViewController`
- Sample app usage in `ChatsActivity` and `GroupChannelInfoActivity`

This ensures clarity and consistency when referring to channel identifiers.
The `queryChannels` call in the `ChannelInfoMemberViewControllerTest` has been updated to use a `QueryChannelsRequest` object instead of an `any()` matcher. This ensures that the test accurately reflects the actual call being made by the `ChannelInfoMemberViewController`.
…teIn`

This commit refactors the `state` property in `ChannelInfoMemberViewController` to utilize the `stateIn` operator. This simplifies the state management by directly transforming the upstream flow into a `StateFlow`.

The `onChannelInfoData` function is removed as its logic is now incorporated into the `map` operation within the `stateIn` flow.
…channel

When messaging a member from the channel info screen, the app will now navigate to a draft channel instead of immediately creating a new direct channel. This allows the user to compose a message before the channel is actually created.

This change also introduces the following new components:
- `DraftChannelViewController`: Manages the state and events for the draft channel screen.
- `DraftChannelViewState`: Represents the state of the draft channel screen.
- `DraftChannelViewAction`: Represents user actions on the draft channel screen.
- `DraftChannelViewEvent`: Represents side effects from the draft channel screen.
- `DraftChannelScreen`: The composable UI for the draft channel.
- `DraftChannelActivity`: The activity that hosts the draft channel screen.
@andremion andremion force-pushed the AND-567-message-members-from-the-member-modal-sheet-of-channel-info-screen branch from 5275e91 to 117de3f Compare June 4, 2025 09:36
Copy link

sonarqubecloud bot commented Jun 4, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
47.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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

Successfully merging this pull request may close these issues.

1 participant