mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-07-04 15:21:43 +00:00
ui: enable relay management (#7094)
This commit is contained in:
@@ -24,26 +24,24 @@ struct ChannelRelaysView: View {
|
||||
var body: some View {
|
||||
List {
|
||||
relaysList()
|
||||
// TODO [relays] re-enable when relay management ships
|
||||
// if groupInfo.isOwner {
|
||||
// Section {
|
||||
// Button {
|
||||
// showAddRelay = true
|
||||
// } label: {
|
||||
// Label("Add relay", systemImage: "plus")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if groupInfo.isOwner {
|
||||
Section {
|
||||
Button {
|
||||
showAddRelay = true
|
||||
} label: {
|
||||
Label("Add relay", systemImage: "plus")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: $showAddRelay) {
|
||||
// Backend gate (APIAddGroupRelays) rejects any chatRelayId already in group_relays
|
||||
// regardless of relayStatus, so all current rows must be excluded from the add list.
|
||||
let existingRelayIds = Set(groupRelays.compactMap { $0.userChatRelay.chatRelayId })
|
||||
AddGroupRelayView(groupInfo: groupInfo, existingRelayIds: existingRelayIds) {
|
||||
Task { await chatModel.loadGroupMembers(groupInfo) }
|
||||
}
|
||||
}
|
||||
// TODO [relays] re-enable when relay management ships
|
||||
// .sheet(isPresented: $showAddRelay) {
|
||||
// // Backend gate (APIAddGroupRelays) rejects any chatRelayId already in group_relays
|
||||
// // regardless of relayStatus, so all current rows must be excluded from the add list.
|
||||
// let existingRelayIds = Set(groupRelays.compactMap { $0.userChatRelay.chatRelayId })
|
||||
// AddGroupRelayView(groupInfo: groupInfo, existingRelayIds: existingRelayIds) {
|
||||
// Task { await chatModel.loadGroupMembers(groupInfo) }
|
||||
// }
|
||||
// }
|
||||
.onAppear {
|
||||
Task {
|
||||
await chatModel.loadGroupMembers(groupInfo)
|
||||
@@ -82,20 +80,18 @@ struct ChannelRelaysView: View {
|
||||
: subscriberRelayStatusText(member.wrapped)
|
||||
relayMemberRow(member.wrapped, statusText: statusText)
|
||||
}
|
||||
// TODO [relays] re-enable when relay management ships
|
||||
// if groupInfo.isOwner && member.wrapped.canBeRemoved(groupInfo: groupInfo) {
|
||||
// link.swipeActions(edge: .trailing) {
|
||||
// Button {
|
||||
// showRemoveMemberAlert(groupInfo, member.wrapped)
|
||||
// } label: {
|
||||
// Label("Remove relay", systemImage: "trash")
|
||||
// }
|
||||
// .tint(.red)
|
||||
// }
|
||||
// } else {
|
||||
// link
|
||||
// }
|
||||
link
|
||||
if groupInfo.isOwner && member.wrapped.canBeRemoved(groupInfo: groupInfo) {
|
||||
link.swipeActions(edge: .trailing) {
|
||||
Button {
|
||||
showRemoveMemberAlert(groupInfo, member.wrapped)
|
||||
} label: {
|
||||
Label("Remove relay", systemImage: "trash")
|
||||
}
|
||||
.tint(.red)
|
||||
}
|
||||
} else {
|
||||
link
|
||||
}
|
||||
}
|
||||
} footer: {
|
||||
Text("Chat relays forward messages to channel subscribers.")
|
||||
|
||||
@@ -633,8 +633,7 @@ struct GroupMemberInfoView: View {
|
||||
blockForAllButton(mem)
|
||||
}
|
||||
}
|
||||
// TODO [relays] re-enable when relay management ships
|
||||
if canRemove && mem.memberRole != .relay {
|
||||
if canRemove {
|
||||
if mem.memberStatus != .memRemoved && (mem.memberStatus != .memLeft || mem.memberRole == .relay) {
|
||||
removeMemberButton(mem)
|
||||
} else if mem.memberRole != .relay {
|
||||
|
||||
-6
@@ -87,8 +87,6 @@ private fun ChannelRelaysLayout(
|
||||
minHeight = 54.dp,
|
||||
padding = PaddingValues(horizontal = DEFAULT_PADDING)
|
||||
) {
|
||||
// TODO [relays] re-enable when relay management ships
|
||||
/*
|
||||
if (groupInfo.isOwner && member.canBeRemoved(groupInfo)) {
|
||||
DefaultDropdownMenu(showMenu) {
|
||||
ItemAction(generalGetString(MR.strings.button_remove_relay), painterResource(MR.images.ic_delete), color = MaterialTheme.colors.error, onClick = {
|
||||
@@ -97,7 +95,6 @@ private fun ChannelRelaysLayout(
|
||||
})
|
||||
}
|
||||
}
|
||||
*/
|
||||
val statusText = if (groupInfo.isOwner) {
|
||||
ownerRelayStatusText(member, groupRelays)
|
||||
} else {
|
||||
@@ -109,8 +106,6 @@ private fun ChannelRelaysLayout(
|
||||
}
|
||||
SectionTextFooter(generalGetString(MR.strings.chat_relays_forward_messages))
|
||||
}
|
||||
// TODO [relays] re-enable when relay management ships
|
||||
/*
|
||||
if (groupInfo.isOwner) {
|
||||
SectionView {
|
||||
SectionItemView(click = {
|
||||
@@ -139,7 +134,6 @@ private fun ChannelRelaysLayout(
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
SectionBottomSpacer()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -421,8 +421,7 @@ fun GroupMemberInfoLayout(
|
||||
@Composable
|
||||
fun ModeratorDestructiveSection() {
|
||||
val canBlockForAll = member.canBlockForAll(groupInfo)
|
||||
// TODO [relays] re-enable when relay management ships
|
||||
val canRemove = member.canBeRemoved(groupInfo) && member.memberRole != GroupMemberRole.Relay
|
||||
val canRemove = member.canBeRemoved(groupInfo)
|
||||
if (canBlockForAll || canRemove) {
|
||||
SectionDividerSpaced()
|
||||
SectionView {
|
||||
|
||||
Reference in New Issue
Block a user