on main help sign in
chore(ui): standardize dialog identifiers
ed7ef78Ayman Bagabas
internal/ui/dialog/quit.go+3−3
@@ -7,8 +7,8 @@ import (
7 "github.com/charmbracelet/crush/internal/ui/common"
7 "github.com/charmbracelet/crush/internal/ui/common"
8)
8)
9
9
10−// QuitDialogID is the identifier for the quit dialog.
10+// QuitID is the identifier for the quit dialog.
11−const QuitDialogID = "quit"
11+const QuitID = "quit"
12
12
13// Quit represents a confirmation dialog for quitting the application.
13// Quit represents a confirmation dialog for quitting the application.
14type Quit struct {
14type Quit struct {
@@ -56,7 +56,7 @@ func NewQuit(com *common.Common) *Quit {
56
56
57// ID implements [Model].
57// ID implements [Model].
58func (*Quit) ID() string {
58func (*Quit) ID() string {
59− return QuitDialogID
59+ return QuitID
60}
60}
61
61
62// Update implements [Model].
62// Update implements [Model].
internal/ui/dialog/sessions.go+3−3
@@ -13,8 +13,8 @@ import (
13 "github.com/charmbracelet/crush/internal/ui/list"
13 "github.com/charmbracelet/crush/internal/ui/list"
14)
14)
15
15
16−// SessionDialogID is the identifier for the session selector dialog.
16+// SessionsID is the identifier for the session selector dialog.
17−const SessionDialogID = "session"
17+const SessionsID = "session"
18
18
19// Session is a session selector dialog.
19// Session is a session selector dialog.
20type Session struct {
20type Session struct {
@@ -96,7 +96,7 @@ func (s *Session) SelectedItem() list.Item {
96
96
97// ID implements Dialog.
97// ID implements Dialog.
98func (s *Session) ID() string {
98func (s *Session) ID() string {
99− return SessionDialogID
99+ return SessionsID
100}
100}
101
101
102// Update implements Dialog.
102// Update implements Dialog.
internal/ui/model/ui.go+4−4
@@ -193,7 +193,7 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
193 sessions.SetSize(min(120, m.width-8), 30)
193 sessions.SetSize(min(120, m.width-8), 30)
194 m.dialog.AddDialog(sessions)
194 m.dialog.AddDialog(sessions)
195 case dialog.SessionSelectedMsg:
195 case dialog.SessionSelectedMsg:
196− m.dialog.RemoveDialog(dialog.SessionDialogID)
196+ m.dialog.RemoveDialog(dialog.SessionsID)
197 cmds = append(cmds,
197 cmds = append(cmds,
198 m.loadSession(msg.Session.ID),
198 m.loadSession(msg.Session.ID),
199 m.loadSessionFiles(msg.Session.ID),
199 m.loadSessionFiles(msg.Session.ID),
@@ -347,7 +347,7 @@ func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) (cmds []tea.Cmd) {
347 handleQuitKeys := func(msg tea.KeyPressMsg) bool {
347 handleQuitKeys := func(msg tea.KeyPressMsg) bool {
348 switch {
348 switch {
349 case key.Matches(msg, m.keyMap.Quit):
349 case key.Matches(msg, m.keyMap.Quit):
350− if !m.dialog.ContainsDialog(dialog.QuitDialogID) {
350+ if !m.dialog.ContainsDialog(dialog.QuitID) {
351 m.dialog.AddDialog(dialog.NewQuit(m.com))
351 m.dialog.AddDialog(dialog.NewQuit(m.com))
352 return true
352 return true
353 }
353 }
@@ -370,9 +370,9 @@ func (m *UI) handleKeyPressMsg(msg tea.KeyPressMsg) (cmds []tea.Cmd) {
370 case key.Matches(msg, m.keyMap.Models):
370 case key.Matches(msg, m.keyMap.Models):
371 // TODO: Implement me
371 // TODO: Implement me
372 case key.Matches(msg, m.keyMap.Sessions):
372 case key.Matches(msg, m.keyMap.Sessions):
373− if m.dialog.ContainsDialog(dialog.SessionDialogID) {
373+ if m.dialog.ContainsDialog(dialog.SessionsID) {
374 // Bring to front
374 // Bring to front
375− m.dialog.BringToFront(dialog.SessionDialogID)
375+ m.dialog.BringToFront(dialog.SessionsID)
376 } else {
376 } else {
377 cmds = append(cmds, m.loadSessionsCmd)
377 cmds = append(cmds, m.loadSessionsCmd)
378 }
378 }