From 0bf5515629f1cfe1557dba4f8d588ac64b77d408 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Wed, 5 Feb 2025 19:41:34 +0200 Subject: When a user sends a message "signal" and the receiving user doesn't have the signal already open, it will be added as the first signal --- internal/client/ui/core/core.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'internal/client/ui/core/core.go') diff --git a/internal/client/ui/core/core.go b/internal/client/ui/core/core.go index b87600d..60225d8 100644 --- a/internal/client/ui/core/core.go +++ b/internal/client/ui/core/core.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "math" + "slices" "time" "github.com/atotto/clipboard" @@ -191,8 +192,6 @@ func (m *Model) updateNotConnected(msg tea.Msg) tea.Cmd { m.connected = true m.timeout = initialTimeout - requestUserData := gateway.Send(&packet.GetUserData{}) - var setName tea.Cmd if m.name != "" { setName = gateway.Send(&packet.SetUserData{ @@ -206,7 +205,7 @@ func (m *Model) updateNotConnected(msg tea.Msg) tea.Cmd { m.name = "" } - return tea.Batch(m.timer.Stop(), requestUserData, setName) + return tea.Batch(m.timer.Stop(), setName) case gateway.ConnectionFailed: log.Println("failed to connect:", msg) @@ -323,7 +322,14 @@ func (m *Model) updateConnected(msg tea.Msg) tea.Cmd { state.UpdateTrusteds(msg) case *packet.NotificationsInfo: - state.UpdateNotifications(msg) + signals := state.UpdateNotifications(msg) + if m.networkList.Index() == networklist.SignalsIndex { + m.chat.SetReceiver(-1) + state.Data.Signals = slices.Insert(state.Data.Signals, 0, signals...) + return m.chat.SetReceiver(m.signalList.Index()) + } else { + state.Data.Signals = slices.Insert(state.Data.Signals, 0, signals...) + } case ui.BanReasonPopupMsg: popup := banreason.New(msg.User, msg.Network) -- cgit v1.3.1