Fixes the use of index relays and search relays to load users and events as well as become the default for global feeds.

This commit is contained in:
Vitor Pamplona
2025-09-11 18:36:42 -04:00
parent 1f8d0295d5
commit c06c03928e
13 changed files with 293 additions and 32 deletions
@@ -81,6 +81,9 @@ import com.vitorpamplona.amethyst.model.nip96FileStorage.FileStorageServerListSt
import com.vitorpamplona.amethyst.model.nipB7Blossom.BlossomServerListState import com.vitorpamplona.amethyst.model.nipB7Blossom.BlossomServerListState
import com.vitorpamplona.amethyst.model.serverList.MergedFollowListsState import com.vitorpamplona.amethyst.model.serverList.MergedFollowListsState
import com.vitorpamplona.amethyst.model.serverList.MergedFollowPlusMineRelayListsState import com.vitorpamplona.amethyst.model.serverList.MergedFollowPlusMineRelayListsState
import com.vitorpamplona.amethyst.model.serverList.MergedFollowPlusMineWithIndexAndSearchRelayListsState
import com.vitorpamplona.amethyst.model.serverList.MergedFollowPlusMineWithIndexRelayListsState
import com.vitorpamplona.amethyst.model.serverList.MergedFollowPlusMineWithSearchRelayListsState
import com.vitorpamplona.amethyst.model.serverList.MergedServerListState import com.vitorpamplona.amethyst.model.serverList.MergedServerListState
import com.vitorpamplona.amethyst.model.serverList.TrustedRelayListsState import com.vitorpamplona.amethyst.model.serverList.TrustedRelayListsState
import com.vitorpamplona.amethyst.model.topNavFeeds.FeedDecryptionCaches import com.vitorpamplona.amethyst.model.topNavFeeds.FeedDecryptionCaches
@@ -305,7 +308,10 @@ class Account(
// Follows Relays // Follows Relays
val followOutboxesOrProxy = FollowListOutboxOrProxyRelays(kind3FollowList, blockedRelayList, proxyRelayList, cache, scope) val followOutboxesOrProxy = FollowListOutboxOrProxyRelays(kind3FollowList, blockedRelayList, proxyRelayList, cache, scope)
val followPlusAllMine = MergedFollowPlusMineRelayListsState(followOutboxesOrProxy, nip65RelayList, privateStorageRelayList, localRelayList, indexerRelayList, scope) val followPlusAllMineWithIndex = MergedFollowPlusMineWithIndexRelayListsState(followOutboxesOrProxy, nip65RelayList, privateStorageRelayList, localRelayList, indexerRelayList, scope)
val followPlusAllMineWithSearch = MergedFollowPlusMineWithSearchRelayListsState(followOutboxesOrProxy, nip65RelayList, privateStorageRelayList, localRelayList, searchRelayList, scope)
val followPlusAllMineWithIndexAndSearch = MergedFollowPlusMineWithIndexAndSearchRelayListsState(followOutboxesOrProxy, nip65RelayList, privateStorageRelayList, localRelayList, indexerRelayList, searchRelayList, scope)
val defaultGlobalRelays = MergedFollowPlusMineRelayListsState(followOutboxesOrProxy, nip65RelayList, privateStorageRelayList, localRelayList, scope)
// keeps a cache of the outbox relays for each author // keeps a cache of the outbox relays for each author
val followsPerRelay = FollowsPerOutboxRelay(kind3FollowList, blockedRelayList, proxyRelayList, cache, scope).flow val followsPerRelay = FollowsPerOutboxRelay(kind3FollowList, blockedRelayList, proxyRelayList, cache, scope).flow
@@ -338,7 +344,7 @@ class Account(
feedFilterListName = settings.defaultHomeFollowList, feedFilterListName = settings.defaultHomeFollowList,
allFollows = allFollows.flow, allFollows = allFollows.flow,
locationFlow = geolocationFlow, locationFlow = geolocationFlow,
followsRelays = followPlusAllMine.flow, followsRelays = defaultGlobalRelays.flow,
blockedRelays = blockedRelayList.flow, blockedRelays = blockedRelayList.flow,
proxyRelays = proxyRelayList.flow, proxyRelays = proxyRelayList.flow,
caches = feedDecryptionCaches, caches = feedDecryptionCaches,
@@ -353,7 +359,7 @@ class Account(
feedFilterListName = settings.defaultStoriesFollowList, feedFilterListName = settings.defaultStoriesFollowList,
allFollows = allFollows.flow, allFollows = allFollows.flow,
locationFlow = geolocationFlow, locationFlow = geolocationFlow,
followsRelays = followPlusAllMine.flow, followsRelays = defaultGlobalRelays.flow,
blockedRelays = blockedRelayList.flow, blockedRelays = blockedRelayList.flow,
proxyRelays = proxyRelayList.flow, proxyRelays = proxyRelayList.flow,
caches = feedDecryptionCaches, caches = feedDecryptionCaches,
@@ -368,7 +374,7 @@ class Account(
feedFilterListName = settings.defaultDiscoveryFollowList, feedFilterListName = settings.defaultDiscoveryFollowList,
allFollows = allFollows.flow, allFollows = allFollows.flow,
locationFlow = geolocationFlow, locationFlow = geolocationFlow,
followsRelays = followPlusAllMine.flow, followsRelays = defaultGlobalRelays.flow,
blockedRelays = blockedRelayList.flow, blockedRelays = blockedRelayList.flow,
proxyRelays = proxyRelayList.flow, proxyRelays = proxyRelayList.flow,
caches = feedDecryptionCaches, caches = feedDecryptionCaches,
@@ -383,7 +389,7 @@ class Account(
feedFilterListName = settings.defaultNotificationFollowList, feedFilterListName = settings.defaultNotificationFollowList,
allFollows = allFollows.flow, allFollows = allFollows.flow,
locationFlow = geolocationFlow, locationFlow = geolocationFlow,
followsRelays = followPlusAllMine.flow, followsRelays = defaultGlobalRelays.flow,
blockedRelays = blockedRelayList.flow, blockedRelays = blockedRelayList.flow,
proxyRelays = proxyRelayList.flow, proxyRelays = proxyRelayList.flow,
caches = feedDecryptionCaches, caches = feedDecryptionCaches,
@@ -686,7 +692,8 @@ class Account(
fun computeRelayListToBroadcast(event: Event): Set<NormalizedRelayUrl> { fun computeRelayListToBroadcast(event: Event): Set<NormalizedRelayUrl> {
if (event is MetadataEvent || event is AdvertisedRelayListEvent) { if (event is MetadataEvent || event is AdvertisedRelayListEvent) {
return followPlusAllMine.flow.value + client.relayStatusFlow().value.available // everywhere
return followPlusAllMineWithIndex.flow.value + client.relayStatusFlow().value.available
} }
if (event is GiftWrapEvent) { if (event is GiftWrapEvent) {
val receiver = event.recipientPubKey() val receiver = event.recipientPubKey()
@@ -886,7 +893,7 @@ class Account(
} }
fun sendLiterallyEverywhere(event: Event) { fun sendLiterallyEverywhere(event: Event) {
client.send(event, outboxRelays.flow.value + indexerRelayList.flow.value + client.relayStatusFlow().value.available) client.send(event, followPlusAllMineWithIndex.flow.value + client.relayStatusFlow().value.available)
cache.justConsumeMyOwnEvent(event) cache.justConsumeMyOwnEvent(event)
} }
@@ -158,9 +158,7 @@ class TorSharedPreferences(
try { try {
// Get the preference flow and take the first value. // Get the preference flow and take the first value.
val preferences = context.sharedPreferencesDataStore.data.first() val preferences = context.sharedPreferencesDataStore.data.first()
println("AABBCC Loading TorSettings: ${preferences[TOR_SETTINGS]}")
preferences[TOR_SETTINGS]?.let { preferences[TOR_SETTINGS]?.let {
println("AABBCC Loading TorSettings: $it")
JsonMapper.mapper.readValue<TorSettings>(it) JsonMapper.mapper.readValue<TorSettings>(it)
} }
} catch (e: Exception) { } catch (e: Exception) {
@@ -171,7 +169,6 @@ class TorSharedPreferences(
suspend fun save(torSettings: TorSettings) { suspend fun save(torSettings: TorSettings) {
try { try {
println("AABBCC Saving TorSettings: $torSettings")
val str = JsonMapper.mapper.writeValueAsString(torSettings) val str = JsonMapper.mapper.writeValueAsString(torSettings)
context.sharedPreferencesDataStore.edit { preferences -> context.sharedPreferencesDataStore.edit { preferences ->
preferences[TOR_SETTINGS] = str preferences[TOR_SETTINGS] = str
@@ -23,7 +23,6 @@ package com.vitorpamplona.amethyst.model.serverList
import com.vitorpamplona.amethyst.model.edits.PrivateStorageRelayListState import com.vitorpamplona.amethyst.model.edits.PrivateStorageRelayListState
import com.vitorpamplona.amethyst.model.localRelays.LocalRelayListState import com.vitorpamplona.amethyst.model.localRelays.LocalRelayListState
import com.vitorpamplona.amethyst.model.nip02FollowLists.FollowListOutboxOrProxyRelays import com.vitorpamplona.amethyst.model.nip02FollowLists.FollowListOutboxOrProxyRelays
import com.vitorpamplona.amethyst.model.nip51Lists.indexerRelays.IndexerRelayListState
import com.vitorpamplona.amethyst.model.nip65RelayList.Nip65RelayListState import com.vitorpamplona.amethyst.model.nip65RelayList.Nip65RelayListState
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@@ -40,7 +39,6 @@ class MergedFollowPlusMineRelayListsState(
val nip65RelayList: Nip65RelayListState, val nip65RelayList: Nip65RelayListState,
val privateOutboxRelayList: PrivateStorageRelayListState, val privateOutboxRelayList: PrivateStorageRelayListState,
val localRelayList: LocalRelayListState, val localRelayList: LocalRelayListState,
val indexerRelayList: IndexerRelayListState,
val scope: CoroutineScope, val scope: CoroutineScope,
) { ) {
fun mergeLists(lists: Array<Set<NormalizedRelayUrl>>): Set<NormalizedRelayUrl> = lists.reduce { acc, set -> acc + set } fun mergeLists(lists: Array<Set<NormalizedRelayUrl>>): Set<NormalizedRelayUrl> = lists.reduce { acc, set -> acc + set }
@@ -53,7 +51,6 @@ class MergedFollowPlusMineRelayListsState(
nip65RelayList.inboxFlow, nip65RelayList.inboxFlow,
privateOutboxRelayList.flow, privateOutboxRelayList.flow,
localRelayList.flow, localRelayList.flow,
indexerRelayList.flow,
), ),
::mergeLists, ::mergeLists,
).onStart { ).onStart {
@@ -65,7 +62,6 @@ class MergedFollowPlusMineRelayListsState(
nip65RelayList.inboxFlow.value, nip65RelayList.inboxFlow.value,
privateOutboxRelayList.flow.value, privateOutboxRelayList.flow.value,
localRelayList.flow.value, localRelayList.flow.value,
indexerRelayList.flow.value,
), ),
), ),
) )
@@ -80,7 +76,6 @@ class MergedFollowPlusMineRelayListsState(
nip65RelayList.inboxFlow.value, nip65RelayList.inboxFlow.value,
privateOutboxRelayList.flow.value, privateOutboxRelayList.flow.value,
localRelayList.flow.value, localRelayList.flow.value,
indexerRelayList.flow.value,
), ),
), ),
) )
@@ -0,0 +1,92 @@
/**
* Copyright (c) 2025 Vitor Pamplona
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.vitorpamplona.amethyst.model.serverList
import com.vitorpamplona.amethyst.model.edits.PrivateStorageRelayListState
import com.vitorpamplona.amethyst.model.localRelays.LocalRelayListState
import com.vitorpamplona.amethyst.model.nip02FollowLists.FollowListOutboxOrProxyRelays
import com.vitorpamplona.amethyst.model.nip51Lists.indexerRelays.IndexerRelayListState
import com.vitorpamplona.amethyst.model.nip51Lists.searchRelays.SearchRelayListState
import com.vitorpamplona.amethyst.model.nip65RelayList.Nip65RelayListState
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.stateIn
class MergedFollowPlusMineWithIndexAndSearchRelayListsState(
val followsOutboxOrProxyRelayList: FollowListOutboxOrProxyRelays,
val nip65RelayList: Nip65RelayListState,
val privateOutboxRelayList: PrivateStorageRelayListState,
val localRelayList: LocalRelayListState,
val indexerRelayList: IndexerRelayListState,
val searchRelayListsState: SearchRelayListState,
val scope: CoroutineScope,
) {
fun mergeLists(lists: Array<Set<NormalizedRelayUrl>>): Set<NormalizedRelayUrl> = lists.reduce { acc, set -> acc + set }
val flow: StateFlow<Set<NormalizedRelayUrl>> =
combine(
listOf(
followsOutboxOrProxyRelayList.flow,
nip65RelayList.outboxFlow,
nip65RelayList.inboxFlow,
privateOutboxRelayList.flow,
localRelayList.flow,
indexerRelayList.flow,
searchRelayListsState.flow,
),
::mergeLists,
).onStart {
emit(
mergeLists(
arrayOf(
followsOutboxOrProxyRelayList.flow.value,
nip65RelayList.outboxFlow.value,
nip65RelayList.inboxFlow.value,
privateOutboxRelayList.flow.value,
localRelayList.flow.value,
indexerRelayList.flow.value,
searchRelayListsState.flow.value,
),
),
)
}.flowOn(Dispatchers.Default)
.stateIn(
scope,
SharingStarted.Eagerly,
mergeLists(
arrayOf(
followsOutboxOrProxyRelayList.flow.value,
nip65RelayList.outboxFlow.value,
nip65RelayList.inboxFlow.value,
privateOutboxRelayList.flow.value,
localRelayList.flow.value,
indexerRelayList.flow.value,
searchRelayListsState.flow.value,
),
),
)
}
@@ -0,0 +1,87 @@
/**
* Copyright (c) 2025 Vitor Pamplona
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.vitorpamplona.amethyst.model.serverList
import com.vitorpamplona.amethyst.model.edits.PrivateStorageRelayListState
import com.vitorpamplona.amethyst.model.localRelays.LocalRelayListState
import com.vitorpamplona.amethyst.model.nip02FollowLists.FollowListOutboxOrProxyRelays
import com.vitorpamplona.amethyst.model.nip51Lists.indexerRelays.IndexerRelayListState
import com.vitorpamplona.amethyst.model.nip65RelayList.Nip65RelayListState
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.stateIn
class MergedFollowPlusMineWithIndexRelayListsState(
val followsOutboxOrProxyRelayList: FollowListOutboxOrProxyRelays,
val nip65RelayList: Nip65RelayListState,
val privateOutboxRelayList: PrivateStorageRelayListState,
val localRelayList: LocalRelayListState,
val indexerRelayList: IndexerRelayListState,
val scope: CoroutineScope,
) {
fun mergeLists(lists: Array<Set<NormalizedRelayUrl>>): Set<NormalizedRelayUrl> = lists.reduce { acc, set -> acc + set }
val flow: StateFlow<Set<NormalizedRelayUrl>> =
combine(
listOf(
followsOutboxOrProxyRelayList.flow,
nip65RelayList.outboxFlow,
nip65RelayList.inboxFlow,
privateOutboxRelayList.flow,
localRelayList.flow,
indexerRelayList.flow,
),
::mergeLists,
).onStart {
emit(
mergeLists(
arrayOf(
followsOutboxOrProxyRelayList.flow.value,
nip65RelayList.outboxFlow.value,
nip65RelayList.inboxFlow.value,
privateOutboxRelayList.flow.value,
localRelayList.flow.value,
indexerRelayList.flow.value,
),
),
)
}.flowOn(Dispatchers.Default)
.stateIn(
scope,
SharingStarted.Eagerly,
mergeLists(
arrayOf(
followsOutboxOrProxyRelayList.flow.value,
nip65RelayList.outboxFlow.value,
nip65RelayList.inboxFlow.value,
privateOutboxRelayList.flow.value,
localRelayList.flow.value,
indexerRelayList.flow.value,
),
),
)
}
@@ -0,0 +1,87 @@
/**
* Copyright (c) 2025 Vitor Pamplona
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.vitorpamplona.amethyst.model.serverList
import com.vitorpamplona.amethyst.model.edits.PrivateStorageRelayListState
import com.vitorpamplona.amethyst.model.localRelays.LocalRelayListState
import com.vitorpamplona.amethyst.model.nip02FollowLists.FollowListOutboxOrProxyRelays
import com.vitorpamplona.amethyst.model.nip51Lists.searchRelays.SearchRelayListState
import com.vitorpamplona.amethyst.model.nip65RelayList.Nip65RelayListState
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.stateIn
class MergedFollowPlusMineWithSearchRelayListsState(
val followsOutboxOrProxyRelayList: FollowListOutboxOrProxyRelays,
val nip65RelayList: Nip65RelayListState,
val privateOutboxRelayList: PrivateStorageRelayListState,
val localRelayList: LocalRelayListState,
val searchRelayListsState: SearchRelayListState,
val scope: CoroutineScope,
) {
fun mergeLists(lists: Array<Set<NormalizedRelayUrl>>): Set<NormalizedRelayUrl> = lists.reduce { acc, set -> acc + set }
val flow: StateFlow<Set<NormalizedRelayUrl>> =
combine(
listOf(
followsOutboxOrProxyRelayList.flow,
nip65RelayList.outboxFlow,
nip65RelayList.inboxFlow,
privateOutboxRelayList.flow,
localRelayList.flow,
searchRelayListsState.flow,
),
::mergeLists,
).onStart {
emit(
mergeLists(
arrayOf(
followsOutboxOrProxyRelayList.flow.value,
nip65RelayList.outboxFlow.value,
nip65RelayList.inboxFlow.value,
privateOutboxRelayList.flow.value,
localRelayList.flow.value,
searchRelayListsState.flow.value,
),
),
)
}.flowOn(Dispatchers.Default)
.stateIn(
scope,
SharingStarted.Eagerly,
mergeLists(
arrayOf(
followsOutboxOrProxyRelayList.flow.value,
nip65RelayList.outboxFlow.value,
nip65RelayList.inboxFlow.value,
privateOutboxRelayList.flow.value,
localRelayList.flow.value,
searchRelayListsState.flow.value,
),
),
)
}
@@ -93,7 +93,6 @@ class TorRelayState(
trustedRelays, trustedRelays,
dmRelays, dmRelays,
) { torSettings: TorRelaySettings, trustedRelayList: Set<NormalizedRelayUrl>, dmRelayList: Set<NormalizedRelayUrl> -> ) { torSettings: TorRelaySettings, trustedRelayList: Set<NormalizedRelayUrl>, dmRelayList: Set<NormalizedRelayUrl> ->
println("AABBCC New tor evaluation: $torSettings $trustedRelayList $dmRelayList")
emit( emit(
TorRelayEvaluation( TorRelayEvaluation(
torSettings = torSettings, torSettings = torSettings,
@@ -71,7 +71,7 @@ fun filterMissingAddressables(keys: List<EventFinderQueryState>): List<RelayBase
val addressesPerRelay = val addressesPerRelay =
mapOfSet { mapOfSet {
keys.forEach { key -> keys.forEach { key ->
val default = key.account.followPlusAllMine.flow.value val default = key.account.followPlusAllMineWithSearch.flow.value
if (key.note is AddressableNote && key.note.event == null) { if (key.note is AddressableNote && key.note.event == null) {
potentialRelaysToFindAddress(key.note).ifEmpty { default }.forEach { relayUrl -> potentialRelaysToFindAddress(key.note).ifEmpty { default }.forEach { relayUrl ->
add(relayUrl, key.note.address) add(relayUrl, key.note.address)
@@ -71,7 +71,7 @@ fun filterMissingEvents(keys: List<EventFinderQueryState>): List<RelayBasedFilte
val eventsPerRelay = val eventsPerRelay =
mapOfSet { mapOfSet {
keys.forEach { key -> keys.forEach { key ->
val default = key.account.followPlusAllMine.flow.value val default = key.account.followPlusAllMineWithSearch.flow.value
if (key.note !is AddressableNote && key.note.event == null) { if (key.note !is AddressableNote && key.note.event == null) {
potentialRelaysToFindEvent(key.note).ifEmpty { default }.forEach { relayUrl -> potentialRelaysToFindEvent(key.note).ifEmpty { default }.forEach { relayUrl ->
@@ -46,7 +46,7 @@ class UserLoaderSubAssembler(
val defaultRelays = mutableSetOf<NormalizedRelayUrl>() val defaultRelays = mutableSetOf<NormalizedRelayUrl>()
keys.mapTo(mutableSetOf()) { it.account }.forEach { keys.mapTo(mutableSetOf()) { it.account }.forEach {
defaultRelays.addAll(it.followPlusAllMine.flow.value) defaultRelays.addAll(it.followPlusAllMineWithIndexAndSearch.flow.value)
it.kind3FollowList.flow.value.authors.forEach { it.kind3FollowList.flow.value.authors.forEach {
val user = LocalCache.getOrCreateUser(it) val user = LocalCache.getOrCreateUser(it)
@@ -55,27 +55,28 @@ class SearchWatcherSubAssembler(
if (mySearchString.isBlank()) return null if (mySearchString.isBlank()) return null
val defaultRelays = key.account.followPlusAllMine.flow.value val defaultRelaysWithIndexAndSearch = key.account.followPlusAllMineWithIndexAndSearch.flow.value
val defaultRelaysWithSearch = key.account.followPlusAllMineWithSearch.flow.value
val directFilters = val directFilters =
runCatching { runCatching {
if (Hex.isHex(mySearchString)) { if (Hex.isHex(mySearchString)) {
val hexKey = Hex.decode(mySearchString).toHexKey() val hexKey = Hex.decode(mySearchString).toHexKey()
filterByAuthor(hexKey, defaultRelays) + filterByEvent(hexKey, defaultRelays) filterByAuthor(hexKey, defaultRelaysWithIndexAndSearch) + filterByEvent(hexKey, defaultRelaysWithSearch)
} else { } else {
val parsed = Nip19Parser.uriToRoute(mySearchString)?.entity val parsed = Nip19Parser.uriToRoute(mySearchString)?.entity
if (parsed != null) { if (parsed != null) {
cache.consume(parsed) cache.consume(parsed)
when (parsed) { when (parsed) {
is NSec -> filterByAuthor(parsed.toPubKeyHex(), defaultRelays) is NSec -> filterByAuthor(parsed.toPubKeyHex(), defaultRelaysWithIndexAndSearch)
is NPub -> filterByAuthor(parsed.hex, defaultRelays) is NPub -> filterByAuthor(parsed.hex, defaultRelaysWithIndexAndSearch)
is NProfile -> filterByAuthor(parsed.hex, defaultRelays) is NProfile -> filterByAuthor(parsed.hex, defaultRelaysWithIndexAndSearch)
is NNote -> filterByEvent(parsed.hex, defaultRelays) is NNote -> filterByEvent(parsed.hex, defaultRelaysWithSearch)
is NEvent -> filterByEvent(parsed.hex, defaultRelays) is NEvent -> filterByEvent(parsed.hex, defaultRelaysWithSearch)
is NEmbed -> emptyList() is NEmbed -> emptyList()
is NRelay -> emptyList() is NRelay -> emptyList()
is NAddress -> filterByAddress(parsed, defaultRelays) is NAddress -> filterByAddress(parsed, defaultRelaysWithSearch)
else -> emptyList() else -> emptyList()
} }
} else { } else {
@@ -46,7 +46,7 @@ class ThreadEventLoaderSubAssembler(
since: SincePerRelayMap?, since: SincePerRelayMap?,
): List<RelayBasedFilter>? { ): List<RelayBasedFilter>? {
val branches = ThreadAssembler().findThreadFor(key.eventId) ?: return null val branches = ThreadAssembler().findThreadFor(key.eventId) ?: return null
val defaultRelays = key.account.followPlusAllMine.flow.value val defaultRelays = key.account.followPlusAllMineWithSearch.flow.value
return filterMissingEventsForThread(branches, defaultRelays) return filterMissingEventsForThread(branches, defaultRelays)
} }
@@ -94,8 +94,6 @@ class TorSettingsFlow(
fun update(torSettings: TorSettings): Boolean { fun update(torSettings: TorSettings): Boolean {
var any = false var any = false
println("AABBCC updating 1 $torSettings")
if (torType.value != torSettings.torType) { if (torType.value != torSettings.torType) {
torType.tryEmit(torSettings.torType) torType.tryEmit(torSettings.torType)
any = true any = true
@@ -150,8 +148,6 @@ class TorSettingsFlow(
any = true any = true
} }
println("AABBCC updating 2 ${toSettings()}")
return any return any
} }