From d1da863d3cb4957664b16e12d28558cb6c5386c0 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Fri, 19 Jul 2024 16:14:14 -0400 Subject: [PATCH] Making sure an empty relay list uses the default list from Amethyst --- .../vitorpamplona/amethyst/model/Account.kt | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt index 07a0f0d6d..0546d0806 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/Account.kt @@ -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? { val usersRelayList = - userProfile().latestContactList?.relays()?.map { - val url = RelayUrlFormatter.normalize(it.key) + 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 + 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 + RelaySetupInfo(url, it.value.read, it.value.write, localFeedTypes) + }?.ifEmpty { null } ?: return null return usersRelayList.toTypedArray() }