@@ -22,19 +22,16 @@ import androidx.compose.runtime.remember
2222import androidx.compose.runtime.rememberCoroutineScope
2323import androidx.compose.runtime.rememberUpdatedState
2424import androidx.compose.ui.platform.LocalContext
25+ import androidx.compose.ui.platform.LocalResources
2526import androidx.compose.ui.res.painterResource
26- import io.getstream.chat.android.client.extensions.isArchive
2727import io.getstream.chat.android.client.extensions.isPinned
2828import io.getstream.chat.android.compose.R
2929import io.getstream.chat.android.compose.state.channels.list.ItemState
30- import io.getstream.chat.android.compose.ui.util.isDistinct
3130import io.getstream.chat.android.models.Channel
3231import io.getstream.chat.android.models.ChannelCapabilities
33- import io.getstream.chat.android.ui.common.state.channels.actions.ArchiveChannel
3432import io.getstream.chat.android.ui.common.state.channels.actions.ChannelAction
3533import io.getstream.chat.android.ui.common.state.channels.actions.MuteChannel
3634import io.getstream.chat.android.ui.common.state.channels.actions.PinChannel
37- import io.getstream.chat.android.ui.common.state.channels.actions.UnarchiveChannel
3835import io.getstream.chat.android.ui.common.state.channels.actions.UnmuteChannel
3936import io.getstream.chat.android.ui.common.state.channels.actions.UnpinChannel
4037import kotlinx.coroutines.launch
@@ -44,11 +41,7 @@ import kotlinx.coroutines.launch
4441 *
4542 * Shows two actions:
4643 * - **More** (gray, left): Opens the channel options bottom sheet.
47- * - **Primary action** (blue, right): Archive for DMs, Mute for groups — with fallback priority.
48- *
49- * The primary action is resolved via a priority list:
50- * - DM: Archive → Mute → Pin
51- * - Group: Mute → Archive → Pin
44+ * - **Primary action** (blue, right): Mute with fallback to Pin.
5245 *
5346 * Each action is a self-executing [ChannelAction] that invokes its handler via
5447 * [LocalSwipeActionHandler].
@@ -91,57 +84,34 @@ public fun DefaultChannelSwipeActions(channelItem: ItemState.ChannelItemState) {
9184}
9285
9386/* *
94- * Resolves and remembers the primary swipe action based on channel type and capabilities.
87+ * Resolves and remembers the primary swipe action based on channel capabilities.
9588 *
96- * DM priority: Archive → Mute → Pin.
97- * Group priority: Mute → Archive → Pin.
89+ * Priority: Mute → Pin.
9890 *
99- * Archive and Pin are always available (membership operations , no capability gate).
91+ * Pin is always available (membership operation , no capability gate).
10092 * Mute requires [ChannelCapabilities.MUTE_CHANNEL].
10193 */
10294@Composable
10395private fun rememberPrimarySwipeAction (
10496 channel : Channel ,
10597 isMuted : Boolean ,
10698 handler : (ChannelAction ) -> Unit ,
107- ): ChannelAction ? {
108- val resources = LocalContext .current.resources
99+ ): ChannelAction {
100+ val resources = LocalResources .current
109101 val handlerState = rememberUpdatedState(handler)
110102 val isPinned = channel.isPinned()
111- val isArchived = channel.isArchive()
112103 val canMute = channel.ownCapabilities.contains(ChannelCapabilities .MUTE_CHANNEL )
113- val isDM = channel.isDistinct() && channel.members.size == 2
114104
115- return remember(channel.cid, isMuted, isPinned, isArchived, canMute, isDM ) {
105+ return remember(channel.cid, isMuted, isPinned, canMute) {
116106 var resolved: ChannelAction ? = null
117107 val onAction: () -> Unit = { resolved?.let { handlerState.value(it) } }
118108
119- val archiveAction = archiveAction(channel, isArchived, resources, onAction)
120- val muteAction = muteAction(channel, isMuted, canMute, resources, onAction)
121- val pinAction = pinAction(channel, isPinned, resources, onAction)
122-
123- val candidates: List <ChannelAction ?> = if (isDM) {
124- listOf (archiveAction, muteAction, pinAction)
125- } else {
126- listOf (muteAction, archiveAction, pinAction)
127- }
128-
129- resolved = candidates.firstOrNull { it != null }
109+ resolved = muteAction(channel, isMuted, canMute, resources, onAction)
110+ ? : pinAction(channel, isPinned, resources, onAction)
130111 resolved
131112 }
132113}
133114
134- private fun archiveAction (
135- channel : Channel ,
136- isArchived : Boolean ,
137- resources : Resources ,
138- onAction : () -> Unit ,
139- ): ChannelAction = if (isArchived) {
140- UnarchiveChannel (channel, resources.getString(R .string.stream_compose_swipe_action_unarchive), onAction)
141- } else {
142- ArchiveChannel (channel, resources.getString(R .string.stream_compose_swipe_action_archive), onAction)
143- }
144-
145115private fun muteAction (
146116 channel : Channel ,
147117 isMuted : Boolean ,
0 commit comments