Checks if the relay list in NIP-28 groups is empty and uses default when needed.
This commit is contained in:
+10
-7
@@ -29,7 +29,7 @@ import com.vitorpamplona.quartz.nip01Core.relay.filters.Filter
|
|||||||
import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent
|
import com.vitorpamplona.quartz.nip28PublicChat.admin.ChannelCreateEvent
|
||||||
import com.vitorpamplona.quartz.utils.mapOfSet
|
import com.vitorpamplona.quartz.utils.mapOfSet
|
||||||
|
|
||||||
fun filterFollowingPublicChats(
|
fun filterFollowingPublicChatsCreationEvent(
|
||||||
followingChannels: Set<HexKey>,
|
followingChannels: Set<HexKey>,
|
||||||
since: SincePerRelayMap?,
|
since: SincePerRelayMap?,
|
||||||
): List<RelayBasedFilter>? {
|
): List<RelayBasedFilter>? {
|
||||||
@@ -38,13 +38,16 @@ fun filterFollowingPublicChats(
|
|||||||
val relayRoomDTags =
|
val relayRoomDTags =
|
||||||
mapOfSet {
|
mapOfSet {
|
||||||
followingChannels.forEach { channelId ->
|
followingChannels.forEach { channelId ->
|
||||||
val relays =
|
val channel = LocalCache.getPublicChatChannelIfExists(channelId)
|
||||||
LocalCache.getPublicChatChannelIfExists(channelId)?.relays()
|
if (channel?.event == null) {
|
||||||
?: LocalCache.relayHints.hintsForEvent(channelId).ifEmpty { null }
|
val relays =
|
||||||
?: Constants.eventFinderRelays
|
channel?.relays()?.ifEmpty { null }
|
||||||
|
?: LocalCache.relayHints.hintsForEvent(channelId).ifEmpty { null }
|
||||||
|
?: Constants.eventFinderRelays
|
||||||
|
|
||||||
relays.forEach { relayUrl ->
|
relays.forEach { relayUrl ->
|
||||||
add(relayUrl, channelId)
|
add(relayUrl, channelId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@ fun filterLastMessageFollowingPublicChats(
|
|||||||
mapOfSet {
|
mapOfSet {
|
||||||
followingChannels.forEach { channelId ->
|
followingChannels.forEach { channelId ->
|
||||||
val relays =
|
val relays =
|
||||||
LocalCache.getPublicChatChannelIfExists(channelId)?.relays()
|
LocalCache.getPublicChatChannelIfExists(channelId)?.relays()?.ifEmpty { null }
|
||||||
?: LocalCache.relayHints.hintsForEvent(channelId).ifEmpty { null }
|
?: LocalCache.relayHints.hintsForEvent(channelId).ifEmpty { null }
|
||||||
?: Constants.eventFinderRelays
|
?: Constants.eventFinderRelays
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -43,7 +43,7 @@ class FollowingPublicChatSubAssembler(
|
|||||||
): List<RelayBasedFilter>? =
|
): List<RelayBasedFilter>? =
|
||||||
listOfNotNull(
|
listOfNotNull(
|
||||||
filterLastMessageFollowingPublicChats(key.account.publicChatList.flowSet.value, since),
|
filterLastMessageFollowingPublicChats(key.account.publicChatList.flowSet.value, since),
|
||||||
filterFollowingPublicChats(key.account.publicChatList.flowSet.value, since),
|
filterFollowingPublicChatsCreationEvent(key.account.publicChatList.flowSet.value, since),
|
||||||
).flatten()
|
).flatten()
|
||||||
|
|
||||||
override fun user(key: ChatroomListState) = key.account.userProfile()
|
override fun user(key: ChatroomListState) = key.account.userProfile()
|
||||||
|
|||||||
Reference in New Issue
Block a user