mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
Use toImmutableSet instead of toPersistentSet
This commit is contained in:
+2
-2
@@ -142,7 +142,7 @@ import io.element.android.libraries.textcomposer.model.TextEditorState
|
|||||||
import io.element.android.libraries.ui.strings.CommonStrings
|
import io.element.android.libraries.ui.strings.CommonStrings
|
||||||
import io.element.android.wysiwyg.link.Link
|
import io.element.android.wysiwyg.link.Link
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.collections.immutable.toPersistentSet
|
import kotlinx.collections.immutable.toImmutableSet
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import kotlin.time.Duration.Companion.milliseconds
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
|
||||||
@@ -774,7 +774,7 @@ internal fun MessagesViewSelectionModePreview() = ElementPreview {
|
|||||||
.filter { SelectionAction.Forward.canApplyTo(it) }
|
.filter { SelectionAction.Forward.canApplyTo(it) }
|
||||||
.take(2)
|
.take(2)
|
||||||
.mapNotNull { it.eventId }
|
.mapNotNull { it.eventId }
|
||||||
.toPersistentSet()
|
.toImmutableSet()
|
||||||
MessagesView(
|
MessagesView(
|
||||||
state = aMessagesState(
|
state = aMessagesState(
|
||||||
timelineState = aTimelineState(
|
timelineState = aTimelineState(
|
||||||
|
|||||||
+2
-2
@@ -16,7 +16,7 @@ import io.element.android.features.messages.impl.timeline.model.event.canBeForwa
|
|||||||
import io.element.android.libraries.matrix.api.core.EventId
|
import io.element.android.libraries.matrix.api.core.EventId
|
||||||
import io.element.android.libraries.ui.strings.CommonStrings
|
import io.element.android.libraries.ui.strings.CommonStrings
|
||||||
import kotlinx.collections.immutable.ImmutableSet
|
import kotlinx.collections.immutable.ImmutableSet
|
||||||
import kotlinx.collections.immutable.toPersistentSet
|
import kotlinx.collections.immutable.toImmutableSet
|
||||||
|
|
||||||
/** Maximum number of messages that can be selected at once. */
|
/** Maximum number of messages that can be selected at once. */
|
||||||
const val MAX_SELECTION_COUNT = 10
|
const val MAX_SELECTION_COUNT = 10
|
||||||
@@ -57,7 +57,7 @@ fun SelectionAction.canApplyTo(event: TimelineItem.Event): Boolean = when (this)
|
|||||||
*/
|
*/
|
||||||
fun SelectionState.deselect(eventIds: Set<EventId>): SelectionState = when (this) {
|
fun SelectionState.deselect(eventIds: Set<EventId>): SelectionState = when (this) {
|
||||||
SelectionState.Disabled -> this
|
SelectionState.Disabled -> this
|
||||||
is SelectionState.Active -> copy(selectedEventIds = (selectedEventIds - eventIds).toPersistentSet())
|
is SelectionState.Active -> copy(selectedEventIds = (selectedEventIds - eventIds).toImmutableSet())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+2
-2
@@ -75,7 +75,7 @@ import kotlinx.collections.immutable.ImmutableList
|
|||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.collections.immutable.persistentSetOf
|
import kotlinx.collections.immutable.persistentSetOf
|
||||||
import kotlinx.collections.immutable.toImmutableList
|
import kotlinx.collections.immutable.toImmutableList
|
||||||
import kotlinx.collections.immutable.toPersistentSet
|
import kotlinx.collections.immutable.toImmutableSet
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
@@ -285,7 +285,7 @@ class TimelinePresenter(
|
|||||||
snackbarDispatcher.post(SnackbarMessage(CommonStrings.screen_room_maximum_messages_selected))
|
snackbarDispatcher.post(SnackbarMessage(CommonStrings.screen_room_maximum_messages_selected))
|
||||||
current
|
current
|
||||||
}
|
}
|
||||||
else -> current.copy(selectedEventIds = (selected + event.eventId).toPersistentSet())
|
else -> current.copy(selectedEventIds = (selected + event.eventId).toImmutableSet())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is TimelineEvent.ExitSelectionMode -> {
|
is TimelineEvent.ExitSelectionMode -> {
|
||||||
|
|||||||
+2
-2
@@ -16,7 +16,7 @@ import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
|||||||
import io.element.android.libraries.matrix.test.AN_EVENT_ID_2
|
import io.element.android.libraries.matrix.test.AN_EVENT_ID_2
|
||||||
import io.element.android.libraries.matrix.test.AN_EVENT_ID_3
|
import io.element.android.libraries.matrix.test.AN_EVENT_ID_3
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.collections.immutable.toPersistentSet
|
import kotlinx.collections.immutable.toImmutableSet
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class SelectionStateTest {
|
class SelectionStateTest {
|
||||||
@@ -84,6 +84,6 @@ class SelectionStateTest {
|
|||||||
|
|
||||||
private fun anActiveSelection(eventIds: List<EventId> = emptyList()) = SelectionState.Active(
|
private fun anActiveSelection(eventIds: List<EventId> = emptyList()) = SelectionState.Active(
|
||||||
action = SelectionAction.Forward,
|
action = SelectionAction.Forward,
|
||||||
selectedEventIds = eventIds.toPersistentSet(),
|
selectedEventIds = eventIds.toImmutableSet(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user