Skip to content

Commit d511f3a

Browse files
committed
Remove archive action from channel swipe actions
1 parent 0df0b42 commit d511f3a

File tree

1 file changed

+10
-40
lines changed

1 file changed

+10
-40
lines changed

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channels/list/DefaultChannelSwipeActions.kt

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,16 @@ import androidx.compose.runtime.remember
2222
import androidx.compose.runtime.rememberCoroutineScope
2323
import androidx.compose.runtime.rememberUpdatedState
2424
import androidx.compose.ui.platform.LocalContext
25+
import androidx.compose.ui.platform.LocalResources
2526
import androidx.compose.ui.res.painterResource
26-
import io.getstream.chat.android.client.extensions.isArchive
2727
import io.getstream.chat.android.client.extensions.isPinned
2828
import io.getstream.chat.android.compose.R
2929
import io.getstream.chat.android.compose.state.channels.list.ItemState
30-
import io.getstream.chat.android.compose.ui.util.isDistinct
3130
import io.getstream.chat.android.models.Channel
3231
import io.getstream.chat.android.models.ChannelCapabilities
33-
import io.getstream.chat.android.ui.common.state.channels.actions.ArchiveChannel
3432
import io.getstream.chat.android.ui.common.state.channels.actions.ChannelAction
3533
import io.getstream.chat.android.ui.common.state.channels.actions.MuteChannel
3634
import io.getstream.chat.android.ui.common.state.channels.actions.PinChannel
37-
import io.getstream.chat.android.ui.common.state.channels.actions.UnarchiveChannel
3835
import io.getstream.chat.android.ui.common.state.channels.actions.UnmuteChannel
3936
import io.getstream.chat.android.ui.common.state.channels.actions.UnpinChannel
4037
import 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
10395
private 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-
145115
private fun muteAction(
146116
channel: Channel,
147117
isMuted: Boolean,

0 commit comments

Comments
 (0)