summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorKyren223 <Kyren223@proton.me>2025-01-06 18:29:22 +0200
committerKyren223 <Kyren223@proton.me>2025-01-06 18:29:22 +0200
commit17969fd39e99d5d2338677f6a57fcb7c96eed2d9 (patch)
tree5747a553db8b23500d57c485ba620aa4890affb7 /internal
parent63790c069fbca0c3548fdaa58148e6cefdf477d5 (diff)
Implemented deleting for networks on the client
Diffstat (limited to 'internal')
-rw-r--r--internal/client/ui/core/networklist/networklist.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/internal/client/ui/core/networklist/networklist.go b/internal/client/ui/core/networklist/networklist.go
index 3ff73f4..96b2e33 100644
--- a/internal/client/ui/core/networklist/networklist.go
+++ b/internal/client/ui/core/networklist/networklist.go
@@ -168,6 +168,27 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
Network: network.ID,
User: *state.State.UserID,
})
+
+ case "D":
+ if state.State.UserID == nil || m.index == TrustedIndex {
+ return m, nil
+ }
+
+ networks := state.State.Networks
+ network := networks[m.index]
+
+ // Remove network from the list so it's not visible
+ state.State.Networks = slices.Delete(networks, m.index, m.index+1)
+
+ // Set back to trusted bcz that's always valid
+ // Where if u were on the network u just left
+ // it'd be an issue (or if u left all networks)
+ m.index = TrustedIndex
+
+ return m, gateway.Send(&packet.DeleteNetwork{
+ Network: network.ID,
+ })
+
}
}
return m, nil