Fixes kind3 relay lists connecting with Search and Wallet connect types.
This commit is contained in:
@@ -2685,12 +2685,12 @@ class Account(
|
|||||||
val url = RelayUrlFormatter.normalize(it.key)
|
val url = RelayUrlFormatter.normalize(it.key)
|
||||||
|
|
||||||
val localFeedTypes =
|
val localFeedTypes =
|
||||||
localRelays.firstOrNull { localRelay -> RelayUrlFormatter.normalize(localRelay.url) == url }?.feedTypes
|
localRelays.firstOrNull { localRelay -> RelayUrlFormatter.normalize(localRelay.url) == url }?.feedTypes?.minus(setOf(FeedType.SEARCH, FeedType.WALLET_CONNECT))
|
||||||
?: Constants.defaultRelays
|
?: Constants.defaultRelays
|
||||||
.filter { defaultRelay -> defaultRelay.url == url }
|
.filter { defaultRelay -> defaultRelay.url == url }
|
||||||
.firstOrNull()
|
.firstOrNull()
|
||||||
?.feedTypes
|
?.feedTypes
|
||||||
?: FeedType.values().toSet()
|
?: Constants.activeTypesGlobalChats
|
||||||
|
|
||||||
RelaySetupInfo(url, it.value.read, it.value.write, localFeedTypes)
|
RelaySetupInfo(url, it.value.read, it.value.write, localFeedTypes)
|
||||||
} ?: return null
|
} ?: return null
|
||||||
@@ -2698,7 +2698,7 @@ class Account(
|
|||||||
return usersRelayList.toTypedArray()
|
return usersRelayList.toTypedArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun convertLocalRelays(): Array<RelaySetupInfo> = localRelays.map { RelaySetupInfo(RelayUrlFormatter.normalize(it.url), it.read, it.write, it.feedTypes) }.toTypedArray()
|
fun convertLocalRelays(): Array<RelaySetupInfo> = localRelays.map { RelaySetupInfo(RelayUrlFormatter.normalize(it.url), it.read, it.write, it.feedTypes.minus(setOf(FeedType.SEARCH, FeedType.WALLET_CONNECT))) }.toTypedArray()
|
||||||
|
|
||||||
fun activeGlobalRelays(): Array<String> =
|
fun activeGlobalRelays(): Array<String> =
|
||||||
connectToRelays.value
|
connectToRelays.value
|
||||||
|
|||||||
+2
-1
@@ -88,6 +88,7 @@ import com.vitorpamplona.amethyst.ui.theme.largeRelayIconModifier
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
||||||
import com.vitorpamplona.amethyst.ui.theme.warningColor
|
import com.vitorpamplona.amethyst.ui.theme.warningColor
|
||||||
import com.vitorpamplona.ammolite.relays.Constants
|
import com.vitorpamplona.ammolite.relays.Constants
|
||||||
|
import com.vitorpamplona.ammolite.relays.Constants.activeTypesGlobalChats
|
||||||
import com.vitorpamplona.ammolite.relays.FeedType
|
import com.vitorpamplona.ammolite.relays.FeedType
|
||||||
import com.vitorpamplona.ammolite.relays.RelayBriefInfoCache
|
import com.vitorpamplona.ammolite.relays.RelayBriefInfoCache
|
||||||
import com.vitorpamplona.ammolite.relays.RelayStat
|
import com.vitorpamplona.ammolite.relays.RelayStat
|
||||||
@@ -753,7 +754,7 @@ fun Kind3RelayEditBox(
|
|||||||
url = RelayUrlFormatter.normalize(url),
|
url = RelayUrlFormatter.normalize(url),
|
||||||
read = read,
|
read = read,
|
||||||
write = write,
|
write = write,
|
||||||
feedTypes = FeedType.entries.toSet(),
|
feedTypes = activeTypesGlobalChats,
|
||||||
relayStat = RelayStat(),
|
relayStat = RelayStat(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
+15
-18
@@ -25,6 +25,7 @@ import androidx.lifecycle.viewModelScope
|
|||||||
import com.vitorpamplona.amethyst.model.Account
|
import com.vitorpamplona.amethyst.model.Account
|
||||||
import com.vitorpamplona.amethyst.service.Nip11CachedRetriever
|
import com.vitorpamplona.amethyst.service.Nip11CachedRetriever
|
||||||
import com.vitorpamplona.ammolite.relays.Constants
|
import com.vitorpamplona.ammolite.relays.Constants
|
||||||
|
import com.vitorpamplona.ammolite.relays.Constants.activeTypesGlobalChats
|
||||||
import com.vitorpamplona.ammolite.relays.FeedType
|
import com.vitorpamplona.ammolite.relays.FeedType
|
||||||
import com.vitorpamplona.ammolite.relays.RelaySetupInfo
|
import com.vitorpamplona.ammolite.relays.RelaySetupInfo
|
||||||
import com.vitorpamplona.ammolite.relays.RelayStats
|
import com.vitorpamplona.ammolite.relays.RelayStats
|
||||||
@@ -99,7 +100,7 @@ class Kind3RelayListViewModel : ViewModel() {
|
|||||||
.filter { defaultRelay -> defaultRelay.url == it.key }
|
.filter { defaultRelay -> defaultRelay.url == it.key }
|
||||||
.firstOrNull()
|
.firstOrNull()
|
||||||
?.feedTypes
|
?.feedTypes
|
||||||
?: FeedType.values().toSet().toImmutableSet()
|
?: activeTypesGlobalChats.toImmutableSet()
|
||||||
|
|
||||||
Kind3BasicRelaySetupInfo(
|
Kind3BasicRelaySetupInfo(
|
||||||
url = RelayUrlFormatter.normalize(it.key),
|
url = RelayUrlFormatter.normalize(it.key),
|
||||||
@@ -108,8 +109,7 @@ class Kind3RelayListViewModel : ViewModel() {
|
|||||||
feedTypes = localInfoFeedTypes,
|
feedTypes = localInfoFeedTypes,
|
||||||
relayStat = RelayStats.get(it.key),
|
relayStat = RelayStats.get(it.key),
|
||||||
)
|
)
|
||||||
}
|
}.distinctBy { it.url }
|
||||||
.distinctBy { it.url }
|
|
||||||
.sortedBy { it.relayStat.receivedBytes }
|
.sortedBy { it.relayStat.receivedBytes }
|
||||||
.reversed()
|
.reversed()
|
||||||
} else {
|
} else {
|
||||||
@@ -122,8 +122,7 @@ class Kind3RelayListViewModel : ViewModel() {
|
|||||||
feedTypes = it.feedTypes,
|
feedTypes = it.feedTypes,
|
||||||
relayStat = RelayStats.get(it.url),
|
relayStat = RelayStats.get(it.url),
|
||||||
)
|
)
|
||||||
}
|
}.distinctBy { it.url }
|
||||||
.distinctBy { it.url }
|
|
||||||
.sortedBy { it.relayStat.receivedBytes }
|
.sortedBy { it.relayStat.receivedBytes }
|
||||||
.reversed()
|
.reversed()
|
||||||
}
|
}
|
||||||
@@ -134,16 +133,16 @@ class Kind3RelayListViewModel : ViewModel() {
|
|||||||
hasModified = true
|
hasModified = true
|
||||||
|
|
||||||
_relays.update {
|
_relays.update {
|
||||||
defaultRelays.map {
|
defaultRelays
|
||||||
Kind3BasicRelaySetupInfo(
|
.map {
|
||||||
url = RelayUrlFormatter.normalize(it.url),
|
Kind3BasicRelaySetupInfo(
|
||||||
read = it.read,
|
url = RelayUrlFormatter.normalize(it.url),
|
||||||
write = it.write,
|
read = it.read,
|
||||||
feedTypes = it.feedTypes,
|
write = it.write,
|
||||||
relayStat = RelayStats.get(it.url),
|
feedTypes = it.feedTypes,
|
||||||
)
|
relayStat = RelayStats.get(it.url),
|
||||||
}
|
)
|
||||||
.distinctBy { it.url }
|
}.distinctBy { it.url }
|
||||||
.sortedBy { it.relayStat.receivedBytes }
|
.sortedBy { it.relayStat.receivedBytes }
|
||||||
.reversed()
|
.reversed()
|
||||||
}
|
}
|
||||||
@@ -223,6 +222,4 @@ fun <T> Iterable<T>.updated(
|
|||||||
fun <T> togglePresenceInSet(
|
fun <T> togglePresenceInSet(
|
||||||
set: Set<T>,
|
set: Set<T>,
|
||||||
item: T,
|
item: T,
|
||||||
): Set<T> {
|
): Set<T> = if (set.contains(item)) set.minus(item) else set.plus(item)
|
||||||
return if (set.contains(item)) set.minus(item) else set.plus(item)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class Relay(
|
|||||||
val url: String,
|
val url: String,
|
||||||
val read: Boolean = true,
|
val read: Boolean = true,
|
||||||
val write: Boolean = true,
|
val write: Boolean = true,
|
||||||
val activeTypes: Set<FeedType> = FeedType.values().toSet(),
|
val activeTypes: Set<FeedType>,
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
// waits 3 minutes to reconnect once things fail
|
// waits 3 minutes to reconnect once things fail
|
||||||
|
|||||||
Reference in New Issue
Block a user