Skip to content

Commit a9b4c12

Browse files
authored
Show "Leave Conversation" and "Add Member" only for group channels (#5960)
* Show Leave Conversation and Add Member options for group channels only and update tests * CHANGELOG
1 parent 676a931 commit a9b4c12

11 files changed

+104
-17
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Fix `Message.channelInfo` not populated when parsing `message.new` event. [#5953
7070
## stream-chat-android-ui-components
7171
### 🐞 Fixed
7272
- Fix mute/unmute instant command icons. [#5938](https://github.com/GetStream/stream-chat-android/pull/5938)
73+
- Show "Leave Conversation" and "Add Member" only for group channels. [#5960](https://github.com/GetStream/stream-chat-android/pull/5960)
7374

7475
### ⬆️ Improved
7576

@@ -83,7 +84,8 @@ Fix `Message.channelInfo` not populated when parsing `message.new` event. [#5953
8384
## stream-chat-android-compose
8485
### 🐞 Fixed
8586
- Fix mute/unmute instant command icons. [#5938](https://github.com/GetStream/stream-chat-android/pull/5938)
86-
- Fix recompositions of `MessageListStartOfTheChannelItemContent`. [#5944](https://github.com/GetStream/stream-chat-android/pull/5944)
87+
- Fix recompositions of `MessageListStartOfTheChannelItemContent`. [#5944](https://github.com/GetStream/stream-chat-android/pull/5944)
88+
- Show "Leave Conversation" and "Add Member" only for group channels. [#5960](https://github.com/GetStream/stream-chat-android/pull/5960)
8789

8890
### ⬆️ Improved
8991
- Improve `SwipeToReply` component in scroller containers. [#5946](https://github.com/GetStream/stream-chat-android/pull/5946)

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channel/info/DirectChannelInfoScreen.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ internal fun DirectChannelInfoContent() {
282282
ChannelInfoViewState.Content.Option.HideChannel(isHidden = false),
283283
ChannelInfoViewState.Content.Option.PinnedMessages,
284284
ChannelInfoViewState.Content.Option.Separator,
285-
ChannelInfoViewState.Content.Option.LeaveChannel,
286285
ChannelInfoViewState.Content.Option.DeleteChannel,
287286
),
288287
),

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channel/info/GroupChannelInfoScreen.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,6 @@ internal fun GroupChannelInfoCollapsedMembers() {
413413
ChannelInfoViewState.Content.Option.PinnedMessages,
414414
ChannelInfoViewState.Content.Option.Separator,
415415
ChannelInfoViewState.Content.Option.LeaveChannel,
416-
ChannelInfoViewState.Content.Option.DeleteChannel,
417416
),
418417
),
419418
)
@@ -456,7 +455,6 @@ internal fun GroupChannelInfoExpandedMembers() {
456455
ChannelInfoViewState.Content.Option.PinnedMessages,
457456
ChannelInfoViewState.Content.Option.Separator,
458457
ChannelInfoViewState.Content.Option.LeaveChannel,
459-
ChannelInfoViewState.Content.Option.DeleteChannel,
460458
),
461459
),
462460
)
Loading
Loading
Loading
Loading
Loading
Loading

stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoViewController.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,9 @@ private fun buildChannelOptionList(
447447
isMuted: Boolean,
448448
isHidden: Boolean,
449449
) = buildList {
450-
if (channelData.ownCapabilities.contains(ChannelCapabilities.UPDATE_CHANNEL_MEMBERS)) {
450+
if (channelData.isGroupChannel &&
451+
channelData.ownCapabilities.contains(ChannelCapabilities.UPDATE_CHANNEL_MEMBERS)
452+
) {
451453
add(ChannelInfoViewState.Content.Option.AddMember)
452454
}
453455
if (singleMember != null) {
@@ -468,11 +470,14 @@ private fun buildChannelOptionList(
468470
add(ChannelInfoViewState.Content.Option.MediaAttachments)
469471
add(ChannelInfoViewState.Content.Option.FilesAttachments)
470472
add(ChannelInfoViewState.Content.Option.Separator)
471-
if (channelData.ownCapabilities.contains(ChannelCapabilities.LEAVE_CHANNEL)) {
472-
add(ChannelInfoViewState.Content.Option.LeaveChannel)
473-
}
474-
if (channelData.ownCapabilities.contains(ChannelCapabilities.DELETE_CHANNEL)) {
475-
add(ChannelInfoViewState.Content.Option.DeleteChannel)
473+
if (channelData.isGroupChannel) {
474+
if (channelData.ownCapabilities.contains(ChannelCapabilities.LEAVE_CHANNEL)) {
475+
add(ChannelInfoViewState.Content.Option.LeaveChannel)
476+
}
477+
} else {
478+
if (channelData.ownCapabilities.contains(ChannelCapabilities.DELETE_CHANNEL)) {
479+
add(ChannelInfoViewState.Content.Option.DeleteChannel)
480+
}
476481
}
477482
}
478483

0 commit comments

Comments
 (0)