diff --git a/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/robots/UserRobotChannelListAsserts.kt b/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/robots/UserRobotChannelListAsserts.kt index c70cb1a0a93..55607cfa434 100644 --- a/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/robots/UserRobotChannelListAsserts.kt +++ b/stream-chat-android-compose-sample/src/androidTestE2eDebug/kotlin/io/getstream/chat/android/compose/robots/UserRobotChannelListAsserts.kt @@ -18,6 +18,7 @@ package io.getstream.chat.android.compose.robots import io.getstream.chat.android.compose.pages.ChannelListPage.ChannelList.Channel import io.getstream.chat.android.compose.uiautomator.isDisplayed +import io.getstream.chat.android.compose.uiautomator.waitForText import io.getstream.chat.android.compose.uiautomator.waitToAppear import io.getstream.chat.android.compose.uiautomator.waitToDisappear import io.getstream.chat.android.e2e.test.robots.ParticipantRobot @@ -36,7 +37,7 @@ fun UserRobot.assertMessageInChannelPreview(text: String, fromCurrentUser: Boole false -> "${ParticipantRobot.name}: $text" null -> text } - assertEquals(expectedPreview, Channel.messagePreview.waitToAppear().text.trimEnd()) + assertEquals(expectedPreview, Channel.messagePreview.waitToAppear().waitForText(expectedPreview).text.trimEnd()) return this } diff --git a/stream-chat-android-compose/api/stream-chat-android-compose.api b/stream-chat-android-compose/api/stream-chat-android-compose.api index 5a3f94c62bd..2a53229cc75 100644 --- a/stream-chat-android-compose/api/stream-chat-android-compose.api +++ b/stream-chat-android-compose/api/stream-chat-android-compose.api @@ -1192,22 +1192,24 @@ public final class io/getstream/chat/android/compose/ui/components/channels/Chan public final class io/getstream/chat/android/compose/ui/components/channels/ChannelOptionItemVisibility { public static final field $stable I public fun ()V - public fun (ZZZZZZ)V - public synthetic fun (ZZZZZZILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (ZZZZZZZ)V + public synthetic fun (ZZZZZZZILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Z public final fun component2 ()Z public final fun component3 ()Z public final fun component4 ()Z public final fun component5 ()Z public final fun component6 ()Z - public final fun copy (ZZZZZZ)Lio/getstream/chat/android/compose/ui/components/channels/ChannelOptionItemVisibility; - public static synthetic fun copy$default (Lio/getstream/chat/android/compose/ui/components/channels/ChannelOptionItemVisibility;ZZZZZZILjava/lang/Object;)Lio/getstream/chat/android/compose/ui/components/channels/ChannelOptionItemVisibility; + public final fun component7 ()Z + public final fun copy (ZZZZZZZ)Lio/getstream/chat/android/compose/ui/components/channels/ChannelOptionItemVisibility; + public static synthetic fun copy$default (Lio/getstream/chat/android/compose/ui/components/channels/ChannelOptionItemVisibility;ZZZZZZZILjava/lang/Object;)Lio/getstream/chat/android/compose/ui/components/channels/ChannelOptionItemVisibility; public fun equals (Ljava/lang/Object;)Z public fun hashCode ()I public final fun isArchiveChannelVisible ()Z public final fun isDeleteChannelVisible ()Z public final fun isLeaveChannelVisible ()Z public final fun isMuteChannelVisible ()Z + public final fun isMuteUserVisible ()Z public final fun isPinChannelVisible ()Z public final fun isViewInfoVisible ()Z public fun toString ()Ljava/lang/String; diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channels/list/DefaultChannelSwipeActions.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channels/list/DefaultChannelSwipeActions.kt index 533edf74841..c633b2feffd 100644 --- a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channels/list/DefaultChannelSwipeActions.kt +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channels/list/DefaultChannelSwipeActions.kt @@ -16,27 +16,20 @@ package io.getstream.chat.android.compose.ui.channels.list -import android.content.res.Resources import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.rememberUpdatedState -import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalResources import androidx.compose.ui.res.painterResource -import io.getstream.chat.android.client.extensions.isArchive -import io.getstream.chat.android.client.extensions.isPinned import io.getstream.chat.android.compose.R import io.getstream.chat.android.compose.state.channels.list.ItemState -import io.getstream.chat.android.compose.ui.util.isDistinct +import io.getstream.chat.android.compose.ui.theme.ChatTheme import io.getstream.chat.android.models.Channel import io.getstream.chat.android.models.ChannelCapabilities -import io.getstream.chat.android.ui.common.state.channels.actions.ArchiveChannel import io.getstream.chat.android.ui.common.state.channels.actions.ChannelAction import io.getstream.chat.android.ui.common.state.channels.actions.MuteChannel -import io.getstream.chat.android.ui.common.state.channels.actions.PinChannel -import io.getstream.chat.android.ui.common.state.channels.actions.UnarchiveChannel import io.getstream.chat.android.ui.common.state.channels.actions.UnmuteChannel -import io.getstream.chat.android.ui.common.state.channels.actions.UnpinChannel import kotlinx.coroutines.launch /** @@ -44,11 +37,7 @@ import kotlinx.coroutines.launch * * Shows two actions: * - **More** (gray, left): Opens the channel options bottom sheet. - * - **Primary action** (blue, right): Archive for DMs, Mute for groups — with fallback priority. - * - * The primary action is resolved via a priority list: - * - DM: Archive → Mute → Pin - * - Group: Mute → Archive → Pin + * - **Primary action** (blue, right): Mute/Unmute channel. * * Each action is a self-executing [ChannelAction] that invokes its handler via * [LocalSwipeActionHandler]. @@ -66,7 +55,7 @@ public fun DefaultChannelSwipeActions(channelItem: ItemState.ChannelItemState) { if (moreHandler != null) { SwipeActionItem( icon = painterResource(R.drawable.stream_design_ic_more), - label = LocalContext.current.resources.getString(R.string.stream_compose_swipe_action_more), + label = LocalResources.current.getString(R.string.stream_compose_swipe_action_more), onClick = { scope.launch { coordinator?.closeAll() } moreHandler(channel) @@ -84,20 +73,16 @@ public fun DefaultChannelSwipeActions(channelItem: ItemState.ChannelItemState) { SwipeActionItem( icon = painterResource(primaryAction.icon), label = primaryAction.label, - onClick = { primaryAction.onAction() }, + onClick = primaryAction.onAction, style = SwipeActionStyle.Primary, ) } } /** - * Resolves and remembers the primary swipe action based on channel type and capabilities. - * - * DM priority: Archive → Mute → Pin. - * Group priority: Mute → Archive → Pin. + * Resolves and remembers the primary swipe action (mute/unmute channel). * - * Archive and Pin are always available (membership operations, no capability gate). - * Mute requires [ChannelCapabilities.MUTE_CHANNEL]. + * Requires [ChannelCapabilities.MUTE_CHANNEL] and `isMuteChannelVisible` in the theme. */ @Composable private fun rememberPrimarySwipeAction( @@ -105,62 +90,21 @@ private fun rememberPrimarySwipeAction( isMuted: Boolean, handler: (ChannelAction) -> Unit, ): ChannelAction? { - val resources = LocalContext.current.resources + val resources = LocalResources.current val handlerState = rememberUpdatedState(handler) - val isPinned = channel.isPinned() - val isArchived = channel.isArchive() - val canMute = channel.ownCapabilities.contains(ChannelCapabilities.MUTE_CHANNEL) - val isDM = channel.isDistinct() && channel.members.size == 2 + val canMute = ChatTheme.channelOptionsTheme.optionVisibility.isMuteChannelVisible && + channel.ownCapabilities.contains(ChannelCapabilities.MUTE_CHANNEL) - return remember(channel.cid, isMuted, isPinned, isArchived, canMute, isDM) { + return remember(channel.cid, isMuted, canMute) { + if (!canMute) return@remember null var resolved: ChannelAction? = null val onAction: () -> Unit = { resolved?.let { handlerState.value(it) } } - val archiveAction = archiveAction(channel, isArchived, resources, onAction) - val muteAction = muteAction(channel, isMuted, canMute, resources, onAction) - val pinAction = pinAction(channel, isPinned, resources, onAction) - - val candidates: List = if (isDM) { - listOf(archiveAction, muteAction, pinAction) + resolved = if (isMuted) { + UnmuteChannel(channel, resources.getString(R.string.stream_compose_swipe_action_unmute), onAction) } else { - listOf(muteAction, archiveAction, pinAction) + MuteChannel(channel, resources.getString(R.string.stream_compose_swipe_action_mute), onAction) } - - resolved = candidates.firstOrNull { it != null } resolved } } - -private fun archiveAction( - channel: Channel, - isArchived: Boolean, - resources: Resources, - onAction: () -> Unit, -): ChannelAction = if (isArchived) { - UnarchiveChannel(channel, resources.getString(R.string.stream_compose_swipe_action_unarchive), onAction) -} else { - ArchiveChannel(channel, resources.getString(R.string.stream_compose_swipe_action_archive), onAction) -} - -private fun muteAction( - channel: Channel, - isMuted: Boolean, - canMute: Boolean, - resources: Resources, - onAction: () -> Unit, -): ChannelAction? = when { - !canMute -> null - isMuted -> UnmuteChannel(channel, resources.getString(R.string.stream_compose_swipe_action_unmute), onAction) - else -> MuteChannel(channel, resources.getString(R.string.stream_compose_swipe_action_mute), onAction) -} - -private fun pinAction( - channel: Channel, - isPinned: Boolean, - resources: Resources, - onAction: () -> Unit, -): ChannelAction = if (isPinned) { - UnpinChannel(channel, resources.getString(R.string.stream_compose_swipe_action_unpin), onAction) -} else { - PinChannel(channel, resources.getString(R.string.stream_compose_swipe_action_pin), onAction) -} diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/ChannelOptionItemVisibility.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/ChannelOptionItemVisibility.kt index ade05292cea..5425373e2f8 100644 --- a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/ChannelOptionItemVisibility.kt +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/ChannelOptionItemVisibility.kt @@ -22,6 +22,7 @@ package io.getstream.chat.android.compose.ui.components.channels * @param isViewInfoVisible Visibility of the view channel info option. * @param isLeaveChannelVisible Visibility of the leave channel option. * @param isMuteChannelVisible Visibility of the mute channel option. + * @param isMuteUserVisible Visibility of the mute user option (DM channels only). * @param isArchiveChannelVisible Visibility of the archive channel option. * @param isPinChannelVisible Visibility of the pin channel option. * @param isDeleteChannelVisible Visibility of the delete channel option. @@ -32,7 +33,8 @@ public data class ChannelOptionItemVisibility( val isViewInfoVisible: Boolean = true, val isLeaveChannelVisible: Boolean = true, val isMuteChannelVisible: Boolean = true, - val isArchiveChannelVisible: Boolean = true, + val isMuteUserVisible: Boolean = true, + val isArchiveChannelVisible: Boolean = false, val isPinChannelVisible: Boolean = false, val isDeleteChannelVisible: Boolean = true, ) diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/ChannelOptions.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/ChannelOptions.kt index e0eb3d800ea..dd3b272cd40 100644 --- a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/ChannelOptions.kt +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/channels/ChannelOptions.kt @@ -50,7 +50,6 @@ import io.getstream.chat.android.ui.common.state.channels.actions.MuteUser import io.getstream.chat.android.ui.common.state.channels.actions.PinChannel import io.getstream.chat.android.ui.common.state.channels.actions.UnarchiveChannel import io.getstream.chat.android.ui.common.state.channels.actions.UnblockUser -import io.getstream.chat.android.ui.common.state.channels.actions.UnmuteChannel import io.getstream.chat.android.ui.common.state.channels.actions.UnmuteUser import io.getstream.chat.android.ui.common.state.channels.actions.UnpinChannel import io.getstream.chat.android.ui.common.state.channels.actions.ViewInfo @@ -96,8 +95,8 @@ public fun ChannelOptions( * * Actions vary by channel type: * - **DM:** View Info, Mute/Unmute User, Block/Unblock User, Archive Chat, Delete Chat - * - **Group (owner):** View Info, Mute/Unmute Group, Archive Group, Delete Group - * - **Group (member):** View Info, Mute/Unmute Group, Archive Group, Leave Group + * - **Group (owner):** View Info, Archive Group, Delete Group + * - **Group (member):** View Info, Archive Group, Leave Group * * @param selectedChannel The currently selected channel. * @param isMuted If the channel is muted or not. @@ -136,7 +135,6 @@ public fun buildDefaultChannelActions( } else { buildGroupChannelActions( selectedChannel = selectedChannel, - isMuted = isMuted, ownCapabilities = ownCapabilities, optionVisibility = optionVisibility, channelName = channelName, @@ -171,7 +169,7 @@ private fun buildDmChannelActions( onViewInfoAction = onViewInfoAction, ), buildDmMuteUserAction( - isVisible = optionVisibility.isMuteChannelVisible, + isVisible = optionVisibility.isMuteUserVisible, otherUserId = otherUserId, selectedChannel = selectedChannel, viewModel = viewModel, @@ -292,14 +290,13 @@ private fun buildDmDeleteAction( /** * Builds channel actions for group channels. - * - **Owner (has DELETE_CHANNEL):** View Info, Mute/Unmute Group, Archive Group, Delete Group - * - **Member (no DELETE_CHANNEL):** View Info, Mute/Unmute Group, Archive Group, Leave Group + * - **Owner (has DELETE_CHANNEL):** View Info, Archive Group, Delete Group + * - **Member (no DELETE_CHANNEL):** View Info, Archive Group, Leave Group */ @Suppress("LongMethod", "LongParameterList") @Composable private fun buildGroupChannelActions( selectedChannel: Channel, - isMuted: Boolean, ownCapabilities: Set, optionVisibility: ChannelOptionItemVisibility, channelName: String, @@ -308,7 +305,6 @@ private fun buildGroupChannelActions( ): List { val canLeaveChannel = ownCapabilities.contains(ChannelCapabilities.LEAVE_CHANNEL) val canDeleteChannel = ownCapabilities.contains(ChannelCapabilities.DELETE_CHANNEL) - val canMuteChannel = ownCapabilities.contains(ChannelCapabilities.MUTE_CHANNEL) return listOfNotNull( if (optionVisibility.isViewInfoVisible) { @@ -320,12 +316,6 @@ private fun buildGroupChannelActions( } else { null }, - buildGroupMuteAction( - canMuteChannel = optionVisibility.isMuteChannelVisible && canMuteChannel, - isMuted = isMuted, - selectedChannel = selectedChannel, - viewModel = viewModel, - ), buildGroupPinAction( canPinChannel = optionVisibility.isPinChannelVisible, selectedChannel = selectedChannel, @@ -479,33 +469,6 @@ private fun buildGroupArchiveAction( null -> null } -/** - * Builds the mute action for group channels, using "Mute Group" / "Unmute Group" labels. - */ -@Composable -private fun buildGroupMuteAction( - canMuteChannel: Boolean, - isMuted: Boolean, - selectedChannel: Channel, - viewModel: ChannelListViewModel, -): ChannelAction? = if (canMuteChannel) { - when (isMuted) { - true -> UnmuteChannel( - channel = selectedChannel, - label = stringResource(id = R.string.stream_compose_selected_channel_menu_unmute_group), - onAction = { viewModel.unmuteChannel(selectedChannel) }, - ) - - false -> MuteChannel( - channel = selectedChannel, - label = stringResource(id = R.string.stream_compose_selected_channel_menu_mute_group), - onAction = { viewModel.muteChannel(selectedChannel) }, - ) - } -} else { - null -} - /** * Preview of [ChannelOptions]. * diff --git a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/viewmodel/channels/ChannelListViewModel.kt b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/viewmodel/channels/ChannelListViewModel.kt index 5dc2fcdea15..1af53274e6e 100644 --- a/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/viewmodel/channels/ChannelListViewModel.kt +++ b/stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/viewmodel/channels/ChannelListViewModel.kt @@ -52,7 +52,6 @@ import io.getstream.chat.android.models.querysort.QuerySortByField import io.getstream.chat.android.models.querysort.QuerySorter import io.getstream.chat.android.ui.common.state.channels.actions.ChannelAction import io.getstream.chat.android.ui.common.utils.extensions.defaultChannelListFilter -import io.getstream.chat.android.ui.common.utils.extensions.isOneToOne import io.getstream.log.taggedLogger import io.getstream.result.call.toUnitCall import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -434,8 +433,7 @@ public class ChannelListViewModel( channelMutes, typingChannels, channelDraftMessages, - globalMuted, - ) { state, channelMutes, typingChannels, channelDraftMessages, userMutes -> + ) { state, channelMutes, typingChannels, channelDraftMessages -> when (state) { ChannelsStateData.NoQueryActive, ChannelsStateData.Loading, @@ -460,8 +458,6 @@ public class ChannelListViewModel( channelItems = createChannelItems( channels = state.channels, channelMutes = channelMutes, - userMutes = userMutes, - currentUser = user.value, typingEvents = typingChannels, draftMessages = channelDraftMessages.takeIf { isDraftMessageEnabled } ?: emptyMap(), ), @@ -805,41 +801,25 @@ public class ChannelListViewModel( * * @param channels The channels to show. * @param channelMutes The list of channels muted for the current user. - * @param userMutes The list of users muted by the current user. - * @param currentUser The currently logged in user. + * */ - @Suppress("LongParameterList") private fun createChannelItems( channels: List, channelMutes: List, - userMutes: List, - currentUser: User?, typingEvents: Map, draftMessages: Map, ): List { val mutedChannelIds = channelMutes.map { channelMute -> channelMute.channel?.cid }.toSet() - val mutedUserIds = userMutes.mapNotNullTo(mutableSetOf()) { it.target?.id } return channels.map { ItemState.ChannelItemState( channel = it, - isMuted = it.cid in mutedChannelIds || it.isOneToOneMutedByUser(currentUser, mutedUserIds), + isMuted = it.cid in mutedChannelIds, typingUsers = typingEvents[it.cid]?.users ?: emptyList(), draftMessage = draftMessages[it.cid], ) } } - /** - * Checks if a 1:1 channel is muted via user mute (i.e. the other member is muted). - */ - private fun Channel.isOneToOneMutedByUser(currentUser: User?, mutedUserIds: Set) = - if (mutedUserIds.isEmpty() || currentUser == null || !isOneToOne(currentUser)) { - false - } else { - val otherUser = members.find { it.user.id != currentUser.id }?.user - otherUser != null && otherUser.id in mutedUserIds - } - internal companion object { /** * Default value of number of channels to return when querying channels. diff --git a/stream-chat-android-compose/src/main/res/values/strings.xml b/stream-chat-android-compose/src/main/res/values/strings.xml index 0f316e61c1a..dbea5b2238d 100644 --- a/stream-chat-android-compose/src/main/res/values/strings.xml +++ b/stream-chat-android-compose/src/main/res/values/strings.xml @@ -36,13 +36,9 @@ Start a chat - Pin - Unpin Mute Unmute More - Archive - Unarchive No results for \"%1$s\" @@ -54,8 +50,6 @@ Unpin Group Leave group Do you want to leave the %1$s group? - Mute Group - Unmute Group Mute User Unmute User Block User diff --git a/stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/viewmodel/channels/ChannelListViewModelTest.kt b/stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/viewmodel/channels/ChannelListViewModelTest.kt index 05f1d044ce0..151364f9cd1 100644 --- a/stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/viewmodel/channels/ChannelListViewModelTest.kt +++ b/stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/viewmodel/channels/ChannelListViewModelTest.kt @@ -36,9 +36,7 @@ import io.getstream.chat.android.models.ChannelMute import io.getstream.chat.android.models.FilterObject import io.getstream.chat.android.models.Filters import io.getstream.chat.android.models.InitializationState -import io.getstream.chat.android.models.Member import io.getstream.chat.android.models.Message -import io.getstream.chat.android.models.Mute import io.getstream.chat.android.models.OrFilterObject import io.getstream.chat.android.models.SearchMessagesResult import io.getstream.chat.android.models.TypingEvent @@ -193,68 +191,6 @@ internal class ChannelListViewModelTest { verify(chatClient).unmuteChannel("messaging", "channel1") } - @Test - fun `Given a DM with a muted user Should mark the channel as muted`() = runTest { - val viewModel = Fixture() - .givenCurrentUser(currentUser) - .givenChannelsQuery() - .givenChannelsState( - channelsStateData = ChannelsStateData.Result(listOf(directChannel)), - loading = false, - ) - .givenChannelMutes() - .givenUserMutes(listOf(otherUserMute)) - .givenTypingChannels() - .get(this) - - val channelItem = viewModel.channelsState.channelItems.first() as ItemState.ChannelItemState - assertTrue(channelItem.isMuted) - } - - @Test - fun `Given a DM without a muted user Should not mark the channel as muted`() = runTest { - val viewModel = Fixture() - .givenCurrentUser(currentUser) - .givenChannelsQuery() - .givenChannelsState( - channelsStateData = ChannelsStateData.Result(listOf(directChannel)), - loading = false, - ) - .givenChannelMutes() - .givenTypingChannels() - .get(this) - - val channelItem = viewModel.channelsState.channelItems.first() as ItemState.ChannelItemState - assertFalse(channelItem.isMuted) - } - - @Test - fun `Given a group channel with a muted user Should not mark the channel as muted`() = runTest { - val groupChannel = Channel( - type = "messaging", - id = "groupChannel", - members = listOf( - Member(user = currentUser), - Member(user = otherUser), - Member(user = User(id = "thirdUser")), - ), - ) - val viewModel = Fixture() - .givenCurrentUser(currentUser) - .givenChannelsQuery() - .givenChannelsState( - channelsStateData = ChannelsStateData.Result(listOf(groupChannel)), - loading = false, - ) - .givenChannelMutes() - .givenUserMutes(listOf(otherUserMute)) - .givenTypingChannels() - .get(this) - - val channelItem = viewModel.channelsState.channelItems.first() as ItemState.ChannelItemState - assertFalse(channelItem.isMuted) - } - @Test fun `Given channel list in content state When selecting a channel and dismissing the menu Should hide the menu`() = runTest { @@ -633,10 +569,6 @@ internal class ChannelListViewModelTest { whenever(globalState.channelMutes) doReturn MutableStateFlow(channelMutes) } - fun givenUserMutes(userMutes: List = emptyList()) = apply { - whenever(globalState.muted) doReturn MutableStateFlow(userMutes) - } - fun givenTypingChannels(typingChannels: Map = emptyMap()) = apply { whenever(globalState.typingChannels) doReturn MutableStateFlow(typingChannels) } @@ -717,9 +649,6 @@ internal class ChannelListViewModelTest { ) private val querySort = QuerySortByField.descByName("lastUpdated") - private val currentUser = User(id = "currentUser") - private val otherUser = User(id = "otherUser") - private val channel1: Channel = Channel( type = "messaging", id = "channel1", @@ -728,20 +657,5 @@ internal class ChannelListViewModelTest { type = "messaging", id = "channel2", ) - private val directChannel = Channel( - type = "messaging", - id = "!members-currentUser-otherUser", - members = listOf( - Member(user = currentUser), - Member(user = otherUser), - ), - ) - private val otherUserMute = Mute( - user = currentUser, - target = otherUser, - createdAt = Date(), - updatedAt = Date(), - expires = null, - ) } } diff --git a/stream-chat-android-ui-common/api/stream-chat-android-ui-common.api b/stream-chat-android-ui-common/api/stream-chat-android-ui-common.api index 6c803ce7241..826a2d718f9 100644 --- a/stream-chat-android-ui-common/api/stream-chat-android-ui-common.api +++ b/stream-chat-android-ui-common/api/stream-chat-android-ui-common.api @@ -1770,7 +1770,6 @@ public final class io/getstream/chat/android/ui/common/state/channels/actions/Ar public fun getIcon ()I public fun getLabel ()Ljava/lang/String; public fun getOnAction ()Lkotlin/jvm/functions/Function0; - public fun getRequiredCapability ()Ljava/lang/String; public fun isDestructive ()Z } @@ -1782,7 +1781,6 @@ public final class io/getstream/chat/android/ui/common/state/channels/actions/Bl public fun getIcon ()I public fun getLabel ()Ljava/lang/String; public fun getOnAction ()Lkotlin/jvm/functions/Function0; - public fun getRequiredCapability ()Ljava/lang/String; public fun isDestructive ()Z } @@ -1792,13 +1790,11 @@ public abstract interface class io/getstream/chat/android/ui/common/state/channe public abstract fun getIcon ()I public abstract fun getLabel ()Ljava/lang/String; public abstract fun getOnAction ()Lkotlin/jvm/functions/Function0; - public fun getRequiredCapability ()Ljava/lang/String; public fun isDestructive ()Z } public final class io/getstream/chat/android/ui/common/state/channels/actions/ChannelAction$DefaultImpls { public static fun getConfirmationPopup (Lio/getstream/chat/android/ui/common/state/channels/actions/ChannelAction;)Lio/getstream/chat/android/ui/common/state/channels/actions/ConfirmationPopup; - public static fun getRequiredCapability (Lio/getstream/chat/android/ui/common/state/channels/actions/ChannelAction;)Ljava/lang/String; public static fun isDestructive (Lio/getstream/chat/android/ui/common/state/channels/actions/ChannelAction;)Z } @@ -1827,7 +1823,6 @@ public final class io/getstream/chat/android/ui/common/state/channels/actions/De public fun getIcon ()I public fun getLabel ()Ljava/lang/String; public fun getOnAction ()Lkotlin/jvm/functions/Function0; - public fun getRequiredCapability ()Ljava/lang/String; public fun isDestructive ()Z } @@ -1840,7 +1835,6 @@ public final class io/getstream/chat/android/ui/common/state/channels/actions/Le public fun getIcon ()I public fun getLabel ()Ljava/lang/String; public fun getOnAction ()Lkotlin/jvm/functions/Function0; - public fun getRequiredCapability ()Ljava/lang/String; public fun isDestructive ()Z } @@ -1852,7 +1846,6 @@ public final class io/getstream/chat/android/ui/common/state/channels/actions/Mu public fun getIcon ()I public fun getLabel ()Ljava/lang/String; public fun getOnAction ()Lkotlin/jvm/functions/Function0; - public fun getRequiredCapability ()Ljava/lang/String; public fun isDestructive ()Z } @@ -1864,7 +1857,6 @@ public final class io/getstream/chat/android/ui/common/state/channels/actions/Mu public fun getIcon ()I public fun getLabel ()Ljava/lang/String; public fun getOnAction ()Lkotlin/jvm/functions/Function0; - public fun getRequiredCapability ()Ljava/lang/String; public fun isDestructive ()Z } @@ -1876,7 +1868,6 @@ public final class io/getstream/chat/android/ui/common/state/channels/actions/Pi public fun getIcon ()I public fun getLabel ()Ljava/lang/String; public fun getOnAction ()Lkotlin/jvm/functions/Function0; - public fun getRequiredCapability ()Ljava/lang/String; public fun isDestructive ()Z } @@ -1888,7 +1879,6 @@ public final class io/getstream/chat/android/ui/common/state/channels/actions/Un public fun getIcon ()I public fun getLabel ()Ljava/lang/String; public fun getOnAction ()Lkotlin/jvm/functions/Function0; - public fun getRequiredCapability ()Ljava/lang/String; public fun isDestructive ()Z } @@ -1900,7 +1890,6 @@ public final class io/getstream/chat/android/ui/common/state/channels/actions/Un public fun getIcon ()I public fun getLabel ()Ljava/lang/String; public fun getOnAction ()Lkotlin/jvm/functions/Function0; - public fun getRequiredCapability ()Ljava/lang/String; public fun isDestructive ()Z } @@ -1912,7 +1901,6 @@ public final class io/getstream/chat/android/ui/common/state/channels/actions/Un public fun getIcon ()I public fun getLabel ()Ljava/lang/String; public fun getOnAction ()Lkotlin/jvm/functions/Function0; - public fun getRequiredCapability ()Ljava/lang/String; public fun isDestructive ()Z } @@ -1924,7 +1912,6 @@ public final class io/getstream/chat/android/ui/common/state/channels/actions/Un public fun getIcon ()I public fun getLabel ()Ljava/lang/String; public fun getOnAction ()Lkotlin/jvm/functions/Function0; - public fun getRequiredCapability ()Ljava/lang/String; public fun isDestructive ()Z } @@ -1936,7 +1923,6 @@ public final class io/getstream/chat/android/ui/common/state/channels/actions/Un public fun getIcon ()I public fun getLabel ()Ljava/lang/String; public fun getOnAction ()Lkotlin/jvm/functions/Function0; - public fun getRequiredCapability ()Ljava/lang/String; public fun isDestructive ()Z } @@ -1948,7 +1934,6 @@ public final class io/getstream/chat/android/ui/common/state/channels/actions/Vi public fun getIcon ()I public fun getLabel ()Ljava/lang/String; public fun getOnAction ()Lkotlin/jvm/functions/Function0; - public fun getRequiredCapability ()Ljava/lang/String; public fun isDestructive ()Z } diff --git a/stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/state/channels/actions/ChannelAction.kt b/stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/state/channels/actions/ChannelAction.kt index 9a0783a45ab..eda9a316b29 100644 --- a/stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/state/channels/actions/ChannelAction.kt +++ b/stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/state/channels/actions/ChannelAction.kt @@ -18,7 +18,6 @@ package io.getstream.chat.android.ui.common.state.channels.actions import androidx.annotation.DrawableRes import io.getstream.chat.android.models.Channel -import io.getstream.chat.android.models.ChannelCapabilities import io.getstream.chat.android.ui.common.R /** @@ -28,7 +27,6 @@ import io.getstream.chat.android.ui.common.R * @property channel The channel this action targets. * @property icon Drawable resource for the action icon. * @property label Human-readable label for the action. - * @property requiredCapability Optional channel capability required to show this action. * @property confirmationPopup Optional confirmation dialog to show before executing. * @property isDestructive Whether this action is destructive (e.g. delete). * @property onAction The handler to execute when the action is confirmed. @@ -39,7 +37,6 @@ public interface ChannelAction { @get:DrawableRes public val icon: Int public val label: String - public val requiredCapability: String? get() = null public val confirmationPopup: ConfirmationPopup? get() = null public val isDestructive: Boolean get() = false public val onAction: () -> Unit @@ -68,7 +65,6 @@ public class LeaveGroup( ) : ChannelAction { @DrawableRes override val icon: Int = R.drawable.stream_design_ic_leave - override val requiredCapability: String = ChannelCapabilities.LEAVE_CHANNEL override val isDestructive: Boolean = true } @@ -82,7 +78,6 @@ public class MuteChannel( ) : ChannelAction { @DrawableRes override val icon: Int = R.drawable.stream_design_ic_mute - override val requiredCapability: String = ChannelCapabilities.MUTE_CHANNEL } /** @@ -95,7 +90,6 @@ public class UnmuteChannel( ) : ChannelAction { @DrawableRes override val icon: Int = R.drawable.stream_design_ic_audio - override val requiredCapability: String = ChannelCapabilities.MUTE_CHANNEL } /** @@ -109,7 +103,6 @@ public class DeleteConversation( ) : ChannelAction { @DrawableRes override val icon: Int = R.drawable.stream_design_ic_delete - override val requiredCapability: String = ChannelCapabilities.DELETE_CHANNEL override val isDestructive: Boolean = true }