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