Hold the revealed event ids in a plain set

The store no longer needs a mutableStateSetOf: an ordinary Set kept in a
mutableStateOf does the same job, and matches DefaultMediaPreviewConfigStateStore.

The Compose state itself has to stay. TimelineProtectionPresenter derives
ProtectionState from the store inside a derivedStateOf, so the set must be a
snapshot object for a reveal to invalidate it and reach the timeline. Backing it
with a plain mutableSetOf leaves the presenter with nothing to observe and it
stops emitting after ShowContent.
This commit is contained in:
hayaksi1
2026-08-10 10:59:22 +03:00
parent 6533a10ab9
commit 09efb04a8f
@@ -7,7 +7,7 @@
package io.element.android.features.messages.impl.timeline.protection
import androidx.compose.runtime.mutableStateSetOf
import androidx.compose.runtime.mutableStateOf
import dev.zacsweers.metro.ContributesBinding
import dev.zacsweers.metro.SingleIn
import io.element.android.libraries.di.SessionScope
@@ -21,11 +21,11 @@ interface TimelineProtectionStore {
@ContributesBinding(SessionScope::class)
@SingleIn(SessionScope::class)
class DefaultTimelineProtectionStore : TimelineProtectionStore {
private val allowedEvents = mutableStateSetOf<EventId>()
private val allowedEvents = mutableStateOf(emptySet<EventId>())
override val allowedEventIds: Set<EventId> = allowedEvents
override val allowedEventIds: Set<EventId> get() = allowedEvents.value
override fun allowEvent(eventId: EventId) {
allowedEvents += eventId
allowedEvents.value = allowedEvents.value + eventId
}
}