Expose the revealed event ids as a SnapshotStateSet

Restore the snapshot backed set the store started with and declare
allowedEventIds as SnapshotStateSet so the interface says out loud that
reads of it are observable.

TimelineProtectionPresenter reads the set inside derivedStateOf, so a
plain set silently stops the timeline from re-rendering when an event is
revealed. Naming the type keeps that requirement from being mistaken for
an implementation detail.
This commit is contained in:
hayaksi1
2026-08-10 16:36:36 +03:00
parent 09efb04a8f
commit 1b833df727
@@ -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<EventId>
val allowedEventIds: SnapshotStateSet<EventId>
fun allowEvent(eventId: EventId)
}
@ContributesBinding(SessionScope::class)
@SingleIn(SessionScope::class)
class DefaultTimelineProtectionStore : TimelineProtectionStore {
private val allowedEvents = mutableStateOf(emptySet<EventId>())
private val allowedEvents = mutableStateSetOf<EventId>()
override val allowedEventIds: Set<EventId> get() = allowedEvents.value
override val allowedEventIds: SnapshotStateSet<EventId> = allowedEvents
override fun allowEvent(eventId: EventId) {
allowedEvents.value = allowedEvents.value + eventId
allowedEvents += eventId
}
}