summaryrefslogtreecommitdiff
path: root/internal/client/ui/core/chat/chat.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/client/ui/core/chat/chat.go')
-rw-r--r--internal/client/ui/core/chat/chat.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/internal/client/ui/core/chat/chat.go b/internal/client/ui/core/chat/chat.go
index c94db31..11cb751 100644
--- a/internal/client/ui/core/chat/chat.go
+++ b/internal/client/ui/core/chat/chat.go
@@ -255,8 +255,10 @@ func (m *Model) SetFrequency(networkIndex, frequencyIndex int) tea.Cmd {
}
func (m *Model) ResetBeforeSwitch() {
- if m.frequencyIndex != -1 && m.networkIndex != -1 {
- network := state.State.Networks[m.networkIndex]
+ networks := state.State.Networks
+ networkInBounds := 0 <= m.networkIndex && m.networkIndex < len(networks)
+ if m.frequencyIndex != -1 && networkInBounds {
+ network := networks[m.networkIndex]
frequencyId := network.Frequencies[m.frequencyIndex].ID
log.Println("Saving", frequencyId)
state.State.FrequencyState[frequencyId] = state.Frequency{