mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-10-31 16:22:49 +00:00
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:
+4
-4
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user