on main help sign in
chore: prevent multiple dialogs from opening
a282449Kujtim Hoxha
internal/tui/tui.go+4−4
@@ -315,7 +315,6 @@ func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
315 // dialogs
315 // dialogs
316 case key.Matches(msg, a.keyMap.Quit):
316 case key.Matches(msg, a.keyMap.Quit):
317 if a.dialog.ActiveDialogID() == quit.QuitDialogID {
317 if a.dialog.ActiveDialogID() == quit.QuitDialogID {
318− // if the quit dialog is already open, close the app
319 return tea.Quit
318 return tea.Quit
320 }
319 }
321 return util.CmdHandler(dialogs.OpenDialogMsg{
320 return util.CmdHandler(dialogs.OpenDialogMsg{
@@ -324,20 +323,21 @@ func (a *appModel) handleKeyPressMsg(msg tea.KeyPressMsg) tea.Cmd {
324
323
325 case key.Matches(msg, a.keyMap.Commands):
324 case key.Matches(msg, a.keyMap.Commands):
326 if a.dialog.ActiveDialogID() == commands.CommandsDialogID {
325 if a.dialog.ActiveDialogID() == commands.CommandsDialogID {
327− // If the commands dialog is already open, close it
328 return util.CmdHandler(dialogs.CloseDialogMsg{})
326 return util.CmdHandler(dialogs.CloseDialogMsg{})
329 }
327 }
330 if a.dialog.HasDialogs() {
328 if a.dialog.HasDialogs() {
331− return nil // Don't open commands dialog if another dialog is active
329+ return nil
332 }
330 }
333 return util.CmdHandler(dialogs.OpenDialogMsg{
331 return util.CmdHandler(dialogs.OpenDialogMsg{
334 Model: commands.NewCommandDialog(a.selectedSessionID),
332 Model: commands.NewCommandDialog(a.selectedSessionID),
335 })
333 })
336 case key.Matches(msg, a.keyMap.Sessions):
334 case key.Matches(msg, a.keyMap.Sessions):
337 if a.dialog.ActiveDialogID() == sessions.SessionsDialogID {
335 if a.dialog.ActiveDialogID() == sessions.SessionsDialogID {
338− // If the sessions dialog is already open, close it
339 return util.CmdHandler(dialogs.CloseDialogMsg{})
336 return util.CmdHandler(dialogs.CloseDialogMsg{})
340 }
337 }
338+ if a.dialog.HasDialogs() && a.dialog.ActiveDialogID() != commands.CommandsDialogID {
339+ return nil
340+ }
341 var cmds []tea.Cmd
341 var cmds []tea.Cmd
342 if a.dialog.ActiveDialogID() == commands.CommandsDialogID {
342 if a.dialog.ActiveDialogID() == commands.CommandsDialogID {
343 // If the commands dialog is open, close it first
343 // If the commands dialog is open, close it first