mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-25 22:52:12 +00:00
ui: fix channel creation with relays of disabled operator (#6841)
This commit is contained in:
@@ -222,6 +222,7 @@ struct AddChannelView: View {
|
||||
var operatorGroups: [[UserChatRelay]] = []
|
||||
var customRelays: [UserChatRelay] = []
|
||||
for op in servers {
|
||||
guard op.operator?.enabled ?? true else { continue }
|
||||
let relays = op.chatRelays.filter { $0.enabled && !$0.deleted && $0.chatRelayId != nil }
|
||||
guard !relays.isEmpty else { continue }
|
||||
if op.operator != nil {
|
||||
@@ -256,6 +257,7 @@ struct AddChannelView: View {
|
||||
private func checkHasRelays() async -> Bool {
|
||||
guard let servers = try? await getUserServers() else { return false }
|
||||
return servers.contains { op in
|
||||
(op.operator?.enabled ?? true) &&
|
||||
op.chatRelays.contains { $0.enabled && !$0.deleted && $0.chatRelayId != nil }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +180,7 @@ private suspend fun chooseRandomRelays(): List<UserChatRelay> {
|
||||
val operatorGroups = mutableListOf<List<UserChatRelay>>()
|
||||
var customRelays = mutableListOf<UserChatRelay>()
|
||||
for (op in servers) {
|
||||
if (op.operator?.enabled == false) continue
|
||||
val relays = op.chatRelays.filter { it.enabled && !it.deleted && it.chatRelayId != null }
|
||||
if (relays.isEmpty()) continue
|
||||
if (op.operator != null) {
|
||||
@@ -212,6 +213,7 @@ private suspend fun chooseRandomRelays(): List<UserChatRelay> {
|
||||
private suspend fun checkHasRelays(): Boolean {
|
||||
val servers = try { getUserServers(rh = null) } catch (_: Exception) { null } ?: return false
|
||||
return servers.any { op ->
|
||||
(op.operator?.enabled ?: true) &&
|
||||
op.chatRelays.any { it.enabled && !it.deleted && it.chatRelayId != null }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user