Fixes missing relays certain internal lists

This commit is contained in:
Vitor Pamplona
2024-05-31 19:47:40 -04:00
parent 1bbcb97d54
commit d307bb0e49
4 changed files with 7 additions and 12 deletions
@@ -269,7 +269,7 @@ class Account(
mappedRelaySet = mappedRelaySet =
mappedRelaySet.map { mappedRelaySet.map {
if (searchRelaySet.contains(it.url)) { if (searchRelaySet.contains(it.url)) {
Relay(it.url, true, false, it.activeTypes + FeedType.SEARCH) Relay(it.url, true, it.write || false, it.activeTypes + FeedType.SEARCH)
} else { } else {
it it
} }
@@ -2606,18 +2606,14 @@ class Account(
} }
fun activeGlobalRelays(): Array<String> { fun activeGlobalRelays(): Array<String> {
return (activeRelays() ?: convertLocalRelays()) return connectToRelays.value
.filter { it.activeTypes.contains(FeedType.GLOBAL) } .filter { it.activeTypes.contains(FeedType.GLOBAL) }
.map { it.url } .map { it.url }
.toTypedArray() .toTypedArray()
} }
fun activeWriteRelays(): List<Relay> { fun activeWriteRelays(): List<Relay> {
return (activeRelays() ?: convertLocalRelays()).filter { it.write } return connectToRelays.value.filter { it.write }
}
fun activeAllRelays(): List<Relay> {
return ((activeRelays() ?: convertLocalRelays()).toList())
} }
fun isAllHidden(users: Set<HexKey>): Boolean { fun isAllHidden(users: Set<HexKey>): Boolean {
@@ -181,8 +181,7 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
?.followList ?.followList
?.get(account.defaultNotificationFollowList.value) ?.get(account.defaultNotificationFollowList.value)
?.relayList ?.relayList
?: account.activeRelays()?.associate { it.url to EOSETime(TimeUtils.oneWeekAgo()) } ?: account.connectToRelays.value.associate { it.url to EOSETime(TimeUtils.oneWeekAgo()) }
?: account.convertLocalRelays().associate { it.url to EOSETime(TimeUtils.oneWeekAgo()) }
return TypedFilter( return TypedFilter(
types = COMMON_FEED_TYPES, types = COMMON_FEED_TYPES,
@@ -214,7 +213,7 @@ object NostrAccountDataSource : NostrDataSource("AccountData") {
?.followList ?.followList
?.get(account.defaultNotificationFollowList.value) ?.get(account.defaultNotificationFollowList.value)
?.relayList ?.relayList
?: account.activeRelays()?.associate { it.url to EOSETime(TimeUtils.oneWeekAgo()) } ?: account.connectToRelays.value.associate { it.url to EOSETime(TimeUtils.oneWeekAgo()) }
?: account.convertLocalRelays().associate { it.url to EOSETime(TimeUtils.oneWeekAgo()) } ?: account.convertLocalRelays().associate { it.url to EOSETime(TimeUtils.oneWeekAgo()) }
return TypedFilter( return TypedFilter(
@@ -79,7 +79,7 @@ fun RelaySelectionDialog(
var relays by remember { var relays by remember {
mutableStateOf( mutableStateOf(
accountViewModel.account.activeAllRelays().map { accountViewModel.account.connectToRelays.value.map {
RelayList( RelayList(
relay = it, relay = it,
relayInfo = RelayBriefInfoCache.RelayBriefInfo(it.url), relayInfo = RelayBriefInfoCache.RelayBriefInfo(it.url),
@@ -114,7 +114,7 @@ private fun RelayOptions(
val isNotUsingRelay = val isNotUsingRelay =
remember(userState) { remember(userState) {
accountViewModel.account.activeRelays()?.none { it.url == relay.url } == true accountViewModel.account.connectToRelays.value.none { it.url == relay.url }
} }
if (isNotUsingRelay) { if (isNotUsingRelay) {