Fixes lack of feed updates for those that didn't follow any communities

This commit is contained in:
Vitor Pamplona
2025-08-21 20:11:44 -04:00
parent 499316687f
commit 1f2a153f47
5 changed files with 23 additions and 6 deletions

View File

@@ -70,7 +70,12 @@ class OutboxRelaySetState(
usersToLoad
.transformLatest { followList ->
val flows: List<StateFlow<NoteState>> = allRelayListFlows(followList)
val relayListFlows = combineAllFlows(flows)
val relayListFlows =
if (flows.isEmpty()) {
MutableStateFlow(emptySet())
} else {
combineAllFlows(flows)
}
emitAll(relayListFlows)
}.onStart {
emit(

View File

@@ -27,6 +27,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
import com.vitorpamplona.quartz.nip72ModCommunities.definition.CommunityDefinitionEvent
import com.vitorpamplona.quartz.utils.mapOfSet
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.combine
class CommunityRelayLoader {
@@ -81,8 +82,12 @@ class CommunityRelayLoader {
?.stateFlow
}
return combine(noteMetadataFlows) { communityNotes ->
transformation(communitiesPerRelay(communityNotes, cache))
return if (noteMetadataFlows.isEmpty()) {
MutableStateFlow(transformation(emptyMap()))
} else {
combine(noteMetadataFlows) { communityNotes ->
transformation(communitiesPerRelay(communityNotes, cache))
}
}
}
}

View File

@@ -28,6 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
import com.vitorpamplona.quartz.utils.mapOfSet
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.combine
class OutboxRelayLoader {
@@ -86,8 +87,12 @@ class OutboxRelayLoader {
note.flow().metadata.stateFlow
}
return combine(noteMetadataFlows) { outboxRelays ->
transformation(authorsPerRelay(outboxRelays, cache))
return if (noteMetadataFlows.isEmpty()) {
MutableStateFlow(transformation(emptyMap()))
} else {
combine(noteMetadataFlows) { outboxRelays ->
transformation(authorsPerRelay(outboxRelays, cache))
}
}
}
}

View File

@@ -86,6 +86,7 @@ class AllFollowsByOutboxTopNavFilter(
} else {
MutableStateFlow(emptyMap())
}
val communitiesPerRelay =
if (communities != null) {
CommunityRelayLoader.toCommunitiesPerRelayFlow(communities, cache) { it }
@@ -116,6 +117,7 @@ class AllFollowsByOutboxTopNavFilter(
} else {
emptyMap()
}
val communitiesPerRelay =
if (communities != null) {
CommunityRelayLoader.communitiesPerRelaySnapshot(communities, cache) { it }

View File

@@ -222,7 +222,7 @@ class AccountViewModel(
}
}
if (flows != null) {
if (!flows.isNullOrEmpty()) {
combine(flows) {
it.any { it }
}