Skip to content

Commit

Permalink
Making sure an empty relay list uses the default list from Amethyst
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorpamplona committed Jul 19, 2024
1 parent 15ab955 commit d1da863
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2761,19 +2761,22 @@ class Account(
// Takes a User's relay list and adds the types of feeds they are active for.
fun activeRelays(): Array<RelaySetupInfo>? {
val usersRelayList =
userProfile().latestContactList?.relays()?.map {
val url = RelayUrlFormatter.normalize(it.key)

val localFeedTypes =
localRelays.firstOrNull { localRelay -> RelayUrlFormatter.normalize(localRelay.url) == url }?.feedTypes?.minus(setOf(FeedType.SEARCH, FeedType.WALLET_CONNECT))
?: Constants.defaultRelays
.filter { defaultRelay -> defaultRelay.url == url }
.firstOrNull()
?.feedTypes
?: Constants.activeTypesGlobalChats

RelaySetupInfo(url, it.value.read, it.value.write, localFeedTypes)
} ?: return null
userProfile()
.latestContactList
?.relays()
?.map {
val url = RelayUrlFormatter.normalize(it.key)

val localFeedTypes =
localRelays.firstOrNull { localRelay -> RelayUrlFormatter.normalize(localRelay.url) == url }?.feedTypes?.minus(setOf(FeedType.SEARCH, FeedType.WALLET_CONNECT))
?: Constants.defaultRelays
.filter { defaultRelay -> defaultRelay.url == url }
.firstOrNull()
?.feedTypes
?: Constants.activeTypesGlobalChats

RelaySetupInfo(url, it.value.read, it.value.write, localFeedTypes)
}?.ifEmpty { null } ?: return null

return usersRelayList.toTypedArray()
}
Expand Down

0 comments on commit d1da863

Please sign in to comment.