Adds onStart calculator for live bubble authors

This commit is contained in:
Vitor Pamplona
2025-05-05 18:34:54 -04:00
parent 504f365ab3
commit 7accb5e2b9
@@ -38,6 +38,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.onStart
@Composable
fun observeChannel(baseChannel: Channel): State<ChannelState?> {
@@ -49,6 +50,7 @@ fun observeChannel(baseChannel: Channel): State<ChannelState?> {
.collectAsStateWithLifecycle()
}
@OptIn(ExperimentalCoroutinesApi::class)
@Composable
fun observeChannelNoteAuthors(baseChannel: Channel): State<ImmutableList<User>> {
ChannelFinderFilterAssemblerSubscription(baseChannel)
@@ -64,6 +66,11 @@ fun observeChannelNoteAuthors(baseChannel: Channel): State<ImmutableList<User>>
.mapNotNull { key, value -> value.author }
.toSet()
.toImmutableList()
}.onStart {
baseChannel.notes
.mapNotNull { key, value -> value.author }
.toSet()
.toImmutableList()
}.distinctUntilChanged()
.flowOn(Dispatchers.Default)
}