Draft: big refactor

This commit is contained in:
2025-09-16 16:03:27 +08:00
parent f527230f1e
commit c4f2b0af25
42 changed files with 684 additions and 215 deletions

View File

@@ -14,7 +14,7 @@ import (
)
var (
lobbyChoices = []string{"No-op", "Logout"}
lobbyChoices = []string{"No-op", "Create Room", "Logout"}
)
type Lobby struct {
@@ -25,18 +25,18 @@ type Lobby struct {
updateCh chan struct{}
users []models.UserStatus
rooms []models.Room
rooms []types.Room
}
func NewLobby(base *Base) *Lobby {
m := Lobby{
m := &Lobby{
Base: base,
choice: "",
cursor: 0,
updateCh: make(chan struct{}, 1),
}
return &m
return m
}
func updateLobbyInfo(m *Lobby) error {
@@ -58,7 +58,8 @@ func updateLobbyInfo(m *Lobby) error {
}
m.users = users
var rooms []models.Room
var rooms []types.Room
// TODO: scan rooms
_, err = m.Base.client.R().
SetResult(&rooms).
ForceContentType("application/json").
@@ -147,6 +148,9 @@ func (m *Lobby) Next(queue *[]*tea.Program) error {
case "No-op":
*queue = append(*queue,
tea.NewProgram(NewLobby(m.Base)))
case "Create Room":
*queue = append(*queue,
tea.NewProgram(NewRoomWaiting(m.Base)))
case "Logout":
*queue = append(*queue,
tea.NewProgram(NewLogout(m.Base)))