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 (
"fmt"
"net"
"sort"
"strings"
"time"
@@ -117,6 +118,9 @@ type clientScanMsg time.Time
func (m *LobbyModel) clientScan() tea.Cmd {
return tea.Tick(REFRESH_TIME, func(t time.Time) tea.Msg {
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)
})
}
@@ -199,6 +203,7 @@ func (m *LobbyModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "N", "n":
m.op = lobbyOperationServerWaiting
cmds = append(cmds, m.serverSendReply(false))
cmds = append(cmds, m.serverListen())
}
case serverSendReplyMsg:
if m.err == nil {
@@ -225,6 +230,7 @@ func (m *LobbyModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, tea.Quit
} else {
m.op = lobbyOperationServerWaiting
cmds = append(cmds, m.serverListen())
}
}
case lobbyOperationClientScannning: