diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/protection/TimelineProtectionStore.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/protection/TimelineProtectionStore.kt index 019f4eabd6..aa6655cb86 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/protection/TimelineProtectionStore.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/protection/TimelineProtectionStore.kt @@ -7,25 +7,26 @@ package io.element.android.features.messages.impl.timeline.protection -import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.mutableStateSetOf +import androidx.compose.runtime.snapshots.SnapshotStateSet import dev.zacsweers.metro.ContributesBinding import dev.zacsweers.metro.SingleIn import io.element.android.libraries.di.SessionScope import io.element.android.libraries.matrix.api.core.EventId interface TimelineProtectionStore { - val allowedEventIds: Set + val allowedEventIds: SnapshotStateSet fun allowEvent(eventId: EventId) } @ContributesBinding(SessionScope::class) @SingleIn(SessionScope::class) class DefaultTimelineProtectionStore : TimelineProtectionStore { - private val allowedEvents = mutableStateOf(emptySet()) + private val allowedEvents = mutableStateSetOf() - override val allowedEventIds: Set get() = allowedEvents.value + override val allowedEventIds: SnapshotStateSet = allowedEvents override fun allowEvent(eventId: EventId) { - allowedEvents.value = allowedEvents.value + eventId + allowedEvents += eventId } }