Переглянути джерело

Further refinements to the update func

arianagiroux 3 тижнів тому
батько
коміт
18298f686e
1 змінених файлів з 11 додано та 4 видалено
  1. 11 4
      tui.go

+ 11 - 4
tui.go

@@ -82,11 +82,9 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 				return m, tea.Quit
 			}
 		}
-	default:
+	case IssueCollection:
 		if msg, ok := msg.(tea.KeyMsg); ok {
 			switch msg.String() {
-			case "q":
-				return m, tea.Quit
 			case "j":
 				if collection, ok := m.widget.(IssueCollection); ok {
 					if collection.selection+1 < len(collection.Collection) {
@@ -116,12 +114,21 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 					return m, m.load
 				}
 				return m, nil
+			case "q":
+				return m, tea.Quit
+			}
+		}
+	default:
+		if msg, ok := msg.(tea.KeyMsg); ok {
+			switch msg.String() {
+			case "q":
+				return m, tea.Quit
 			}
 		}
 	}
 
 	switch msg := msg.(type) {
-	case tea.KeyMsg:
+	case tea.KeyMsg: // keymsg capture that is always present
 		switch msg.String() {
 		case "ctrl+c":
 			return m, tea.Quit