Fix: minor bugfix

This commit is contained in:
2025-10-16 10:00:42 +08:00
parent 8fb294cd5d
commit 85078ca36a

View File

@@ -3,6 +3,7 @@ package stages
import ( import (
"fmt" "fmt"
"net" "net"
"sort"
"strings" "strings"
"time" "time"
@@ -117,6 +118,9 @@ type clientScanMsg time.Time
func (m *LobbyModel) clientScan() tea.Cmd { func (m *LobbyModel) clientScan() tea.Cmd {
return tea.Tick(REFRESH_TIME, func(t time.Time) tea.Msg { return tea.Tick(REFRESH_TIME, func(t time.Time) tea.Msg {
m.endpoints, m.err = utils.Ping(viper.GetStringSlice("udp-endpoints")) m.endpoints, m.err = utils.Ping(viper.GetStringSlice("udp-endpoints"))
sort.Slice(m.endpoints, func(i, j int) bool {
return m.endpoints[i] < m.endpoints[j]
})
return clientScanMsg(t) return clientScanMsg(t)
}) })
} }
@@ -199,6 +203,7 @@ func (m *LobbyModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "N", "n": case "N", "n":
m.op = lobbyOperationServerWaiting m.op = lobbyOperationServerWaiting
cmds = append(cmds, m.serverSendReply(false)) cmds = append(cmds, m.serverSendReply(false))
cmds = append(cmds, m.serverListen())
} }
case serverSendReplyMsg: case serverSendReplyMsg:
if m.err == nil { if m.err == nil {
@@ -225,6 +230,7 @@ func (m *LobbyModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, tea.Quit return m, tea.Quit
} else { } else {
m.op = lobbyOperationServerWaiting m.op = lobbyOperationServerWaiting
cmds = append(cmds, m.serverListen())
} }
} }
case lobbyOperationClientScannning: case lobbyOperationClientScannning: