From e88c5f242dbb30f5fc7a9dfb581fa519d2e5ff11 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Sat, 21 Dec 2024 18:29:29 +0200 Subject: Implemented fetching existing messages when changing frequencies --- internal/client/ui/core/core.go | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 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 f986351..b1ed7e3 100644 --- a/internal/client/ui/core/core.go +++ b/internal/client/ui/core/core.go @@ -308,19 +308,22 @@ func (m *Model) updateConnected(msg tea.Msg) tea.Cmd { return nil } + var cmds []tea.Cmd var cmd tea.Cmd - switch m.focus { - case FocusNetworkList: - m.networkList, cmd = m.networkList.Update(msg) - m.frequencyList.SetNetworkIndex(m.networkList.Index()) - m.chat.SetFrequency(m.networkList.Index(), m.frequencyList.Index()) - case FocusFrequencyList: - m.frequencyList, cmd = m.frequencyList.Update(msg) - m.chat.SetFrequency(m.networkList.Index(), m.frequencyList.Index()) - case FocusChat: - m.chat, cmd = m.chat.Update(msg) - } - return cmd + + m.networkList, cmd = m.networkList.Update(msg) + cmds = append(cmds, cmd) + + m.frequencyList.SetNetworkIndex(m.networkList.Index()) + m.frequencyList, cmd = m.frequencyList.Update(msg) + cmds = append(cmds, cmd) + + cmd = m.chat.SetFrequency(m.networkList.Index(), m.frequencyList.Index()) + cmds = append(cmds, cmd) + m.chat, cmd = m.chat.Update(msg) + cmds = append(cmds, cmd) + + return tea.Batch(cmds...) } func (m *Model) updateLoadScreenContent() { -- cgit v1.3.1