mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-09 18:32:37 +02:00
fixing global relays selection
This commit is contained in:
@@ -1478,6 +1478,12 @@ class Account(
|
|||||||
}.toTypedArray()
|
}.toTypedArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun convertGlobalRelays(): Array<String> {
|
||||||
|
return localRelays.filter { it.feedTypes.contains(FeedType.GLOBAL) }
|
||||||
|
.map { it.url }
|
||||||
|
.toTypedArray()
|
||||||
|
}
|
||||||
|
|
||||||
fun reconnectIfRelaysHaveChanged() {
|
fun reconnectIfRelaysHaveChanged() {
|
||||||
val newRelaySet = activeRelays() ?: convertLocalRelays()
|
val newRelaySet = activeRelays() ?: convertLocalRelays()
|
||||||
if (!Client.isSameRelaySetConfig(newRelaySet)) {
|
if (!Client.isSameRelaySetConfig(newRelaySet)) {
|
||||||
|
@@ -37,6 +37,7 @@ class HomeNewThreadFeedFilter(val account: Account) : AdditiveFeedFilter<Note>()
|
|||||||
|
|
||||||
private fun innerApplyFilter(collection: Collection<Note>, ignoreAddressables: Boolean): Set<Note> {
|
private fun innerApplyFilter(collection: Collection<Note>, ignoreAddressables: Boolean): Set<Note> {
|
||||||
val isGlobal = account.defaultHomeFollowList == GLOBAL_FOLLOWS
|
val isGlobal = account.defaultHomeFollowList == GLOBAL_FOLLOWS
|
||||||
|
val gRelays = account.convertGlobalRelays()
|
||||||
val isHiddenList = showHiddenKey()
|
val isHiddenList = showHiddenKey()
|
||||||
|
|
||||||
val followingKeySet = account.selectedUsersFollowList(account.defaultHomeFollowList) ?: emptySet()
|
val followingKeySet = account.selectedUsersFollowList(account.defaultHomeFollowList) ?: emptySet()
|
||||||
@@ -51,9 +52,10 @@ class HomeNewThreadFeedFilter(val account: Account) : AdditiveFeedFilter<Note>()
|
|||||||
.asSequence()
|
.asSequence()
|
||||||
.filter { it ->
|
.filter { it ->
|
||||||
val noteEvent = it.event
|
val noteEvent = it.event
|
||||||
|
val isGlobalRelay = it.relays?.any { gRelays.contains(it) } ?: false
|
||||||
(noteEvent is TextNoteEvent || noteEvent is ClassifiedsEvent || noteEvent is RepostEvent || noteEvent is GenericRepostEvent || noteEvent is LongTextNoteEvent || noteEvent is PollNoteEvent || noteEvent is HighlightEvent || noteEvent is AudioTrackEvent) &&
|
(noteEvent is TextNoteEvent || noteEvent is ClassifiedsEvent || noteEvent is RepostEvent || noteEvent is GenericRepostEvent || noteEvent is LongTextNoteEvent || noteEvent is PollNoteEvent || noteEvent is HighlightEvent || noteEvent is AudioTrackEvent) &&
|
||||||
(!ignoreAddressables || noteEvent.kind() < 10000) &&
|
(!ignoreAddressables || noteEvent.kind() < 10000) &&
|
||||||
(isGlobal || it.author?.pubkeyHex in followingKeySet || noteEvent.isTaggedHashes(followingTagSet) || noteEvent.isTaggedGeoHashes(followingGeoSet) || noteEvent.isTaggedAddressableNotes(followingCommunities)) &&
|
((isGlobal && isGlobalRelay) || it.author?.pubkeyHex in followingKeySet || noteEvent.isTaggedHashes(followingTagSet) || noteEvent.isTaggedGeoHashes(followingGeoSet) || noteEvent.isTaggedAddressableNotes(followingCommunities)) &&
|
||||||
// && account.isAcceptable(it) // This filter follows only. No need to check if acceptable
|
// && account.isAcceptable(it) // This filter follows only. No need to check if acceptable
|
||||||
(isHiddenList || it.author?.let { !account.isHidden(it.pubkeyHex) } ?: true) &&
|
(isHiddenList || it.author?.let { !account.isHidden(it.pubkeyHex) } ?: true) &&
|
||||||
((it.event?.createdAt() ?: 0) < oneMinuteInTheFuture) &&
|
((it.event?.createdAt() ?: 0) < oneMinuteInTheFuture) &&
|
||||||
|
Reference in New Issue
Block a user