Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Fix `Message.channelInfo` not populated when parsing `message.new` event. [#5953
## stream-chat-android-ui-components
### 🐞 Fixed
- Fix mute/unmute instant command icons. [#5938](https://github.com/GetStream/stream-chat-android/pull/5938)
- Show "Leave Conversation" and "Add Member" only for group channels. [#5960](https://github.com/GetStream/stream-chat-android/pull/5960)

### ⬆️ Improved

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

### ⬆️ Improved
- Improve `SwipeToReply` component in scroller containers. [#5946](https://github.com/GetStream/stream-chat-android/pull/5946)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@ internal fun DirectChannelInfoContent() {
ChannelInfoViewState.Content.Option.HideChannel(isHidden = false),
ChannelInfoViewState.Content.Option.PinnedMessages,
ChannelInfoViewState.Content.Option.Separator,
ChannelInfoViewState.Content.Option.LeaveChannel,
ChannelInfoViewState.Content.Option.DeleteChannel,
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ internal fun GroupChannelInfoCollapsedMembers() {
ChannelInfoViewState.Content.Option.PinnedMessages,
ChannelInfoViewState.Content.Option.Separator,
ChannelInfoViewState.Content.Option.LeaveChannel,
ChannelInfoViewState.Content.Option.DeleteChannel,
),
),
)
Expand Down Expand Up @@ -456,7 +455,6 @@ internal fun GroupChannelInfoExpandedMembers() {
ChannelInfoViewState.Content.Option.PinnedMessages,
ChannelInfoViewState.Content.Option.Separator,
ChannelInfoViewState.Content.Option.LeaveChannel,
ChannelInfoViewState.Content.Option.DeleteChannel,
),
),
)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,9 @@ private fun buildChannelOptionList(
isMuted: Boolean,
isHidden: Boolean,
) = buildList {
if (channelData.ownCapabilities.contains(ChannelCapabilities.UPDATE_CHANNEL_MEMBERS)) {
if (channelData.isGroupChannel &&
channelData.ownCapabilities.contains(ChannelCapabilities.UPDATE_CHANNEL_MEMBERS)
) {
add(ChannelInfoViewState.Content.Option.AddMember)
}
if (singleMember != null) {
Expand All @@ -468,11 +470,14 @@ private fun buildChannelOptionList(
add(ChannelInfoViewState.Content.Option.MediaAttachments)
add(ChannelInfoViewState.Content.Option.FilesAttachments)
add(ChannelInfoViewState.Content.Option.Separator)
if (channelData.ownCapabilities.contains(ChannelCapabilities.LEAVE_CHANNEL)) {
add(ChannelInfoViewState.Content.Option.LeaveChannel)
}
if (channelData.ownCapabilities.contains(ChannelCapabilities.DELETE_CHANNEL)) {
add(ChannelInfoViewState.Content.Option.DeleteChannel)
if (channelData.isGroupChannel) {
if (channelData.ownCapabilities.contains(ChannelCapabilities.LEAVE_CHANNEL)) {
add(ChannelInfoViewState.Content.Option.LeaveChannel)
}
} else {
if (channelData.ownCapabilities.contains(ChannelCapabilities.DELETE_CHANNEL)) {
add(ChannelInfoViewState.Content.Option.DeleteChannel)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,89 @@ internal class ChannelInfoViewControllerTest {
}
}

@Suppress("LongMethod")
@Test
fun `direct channel options`() = runTest {
val currentMember = randomMember()
val otherMember = randomMember()
val channel = randomChannel(
id = "!members-${currentMember.getUserId()},${otherMember.getUserId()}",
createdBy = otherMember.user,
members = listOf(currentMember, otherMember),
memberCount = 2,
ownCapabilities = emptySet(),
)
val fixture = Fixture()
.given(
currentUser = currentMember.user,
channel = channel,
)
val sut = fixture.get(backgroundScope)

sut.state.test {
skipItems(1) // Skip initial state

assertEquals(
ChannelInfoViewState.Content(
owner = channel.createdBy,
members = ExpandableList(
items = listOf(otherMember),
minimumVisibleItems = 5,
),
options = listOf(
ChannelInfoViewState.Content.Option.UserInfo(user = otherMember.user),
ChannelInfoViewState.Content.Option.HideChannel(isHidden = false),
ChannelInfoViewState.Content.Option.PinnedMessages,
ChannelInfoViewState.Content.Option.MediaAttachments,
ChannelInfoViewState.Content.Option.FilesAttachments,
ChannelInfoViewState.Content.Option.Separator,
),
),
awaitItem(),
)

val updatedChannel = channel.copy(
ownCapabilities = setOf(
ChannelCapabilities.UPDATE_CHANNEL_MEMBERS,
ChannelCapabilities.UPDATE_CHANNEL,
ChannelCapabilities.BAN_CHANNEL_MEMBERS,
ChannelCapabilities.MUTE_CHANNEL,
ChannelCapabilities.LEAVE_CHANNEL,
ChannelCapabilities.DELETE_CHANNEL,
),
)
fixture.given(channel = updatedChannel)

assertEquals(
ChannelInfoViewState.Content(
owner = updatedChannel.createdBy,
members = ExpandableList(
items = listOf(otherMember),
minimumVisibleItems = 5,
),
options = listOf(
ChannelInfoViewState.Content.Option.UserInfo(user = otherMember.user),
ChannelInfoViewState.Content.Option.MuteChannel(isMuted = false),
ChannelInfoViewState.Content.Option.HideChannel(isHidden = false),
ChannelInfoViewState.Content.Option.PinnedMessages,
ChannelInfoViewState.Content.Option.MediaAttachments,
ChannelInfoViewState.Content.Option.FilesAttachments,
ChannelInfoViewState.Content.Option.Separator,
ChannelInfoViewState.Content.Option.DeleteChannel,
),
),
awaitItem(),
)
}
}

@Suppress("LongMethod")
@Test
fun `channel options`() = runTest {
val channel = randomChannel(ownCapabilities = emptySet())
fun `group channel options`() = runTest {
val channel = randomChannel(
members = randomMembers(10),
ownCapabilities = emptySet(),
)
val fixture = Fixture().given(channel = channel)
val sut = fixture.get(backgroundScope)

Expand All @@ -291,7 +371,10 @@ internal class ChannelInfoViewControllerTest {
assertEquals(
ChannelInfoViewState.Content(
owner = channel.createdBy,
members = emptyMembers(),
members = ExpandableList(
items = channel.members,
minimumVisibleItems = 5,
),
options = listOf(
ChannelInfoViewState.Content.Option.RenameChannel(name = channel.name, isReadOnly = true),
ChannelInfoViewState.Content.Option.HideChannel(isHidden = false),
Expand Down Expand Up @@ -319,7 +402,10 @@ internal class ChannelInfoViewControllerTest {
assertEquals(
ChannelInfoViewState.Content(
owner = updatedChannel.createdBy,
members = emptyMembers(),
members = ExpandableList(
items = channel.members,
minimumVisibleItems = 5,
),
options = listOf(
ChannelInfoViewState.Content.Option.AddMember,
ChannelInfoViewState.Content.Option.RenameChannel(
Expand All @@ -333,7 +419,6 @@ internal class ChannelInfoViewControllerTest {
ChannelInfoViewState.Content.Option.FilesAttachments,
ChannelInfoViewState.Content.Option.Separator,
ChannelInfoViewState.Content.Option.LeaveChannel,
ChannelInfoViewState.Content.Option.DeleteChannel,
),
),
awaitItem(),
Expand Down Expand Up @@ -997,7 +1082,6 @@ internal class ChannelInfoViewControllerTest {
ChannelInfoViewState.Content.Option.MediaAttachments,
ChannelInfoViewState.Content.Option.FilesAttachments,
ChannelInfoViewState.Content.Option.Separator,
ChannelInfoViewState.Content.Option.DeleteChannel,
),
),
awaitItem(),
Expand Down Expand Up @@ -1036,7 +1120,6 @@ internal class ChannelInfoViewControllerTest {
ChannelInfoViewState.Content.Option.MediaAttachments,
ChannelInfoViewState.Content.Option.FilesAttachments,
ChannelInfoViewState.Content.Option.Separator,
ChannelInfoViewState.Content.Option.DeleteChannel,
),
),
awaitItem(),
Expand Down
Loading