(msg tea.KeyMsg)
| 236 | } |
| 237 | |
| 238 | func (a App) handleKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) { |
| 239 | key := msg.String() |
| 240 | |
| 241 | if a.viewMode == ViewModeInitAuth { |
| 242 | return a.handleInitAuthKey(key) |
| 243 | } |
| 244 | |
| 245 | // F3: refresh metadata from any view |
| 246 | if key == "f3" { |
| 247 | if a.authState != AuthStateLoading { |
| 248 | a.authState = AuthStateLoading |
| 249 | a.loadingFrame = 0 |
| 250 | a.metadataRefreshMsg = "Refreshing metadata..." |
| 251 | a.refreshMsgFrames = 60 |
| 252 | return a, downloadMetadataCmd(a.client) |
| 253 | } |
| 254 | return a, nil |
| 255 | } |
| 256 | |
| 257 | switch a.viewMode { |
| 258 | case ViewModePricing: |
| 259 | event := a.pricingView.HandleKey(key) |
| 260 | return a.handlePricingEvent(event) |
| 261 | case ViewModeHistory: |
| 262 | event, idx := a.historyView.HandleKey(key) |
| 263 | return a.handleHistoryEvent(event, idx) |
| 264 | case ViewModeSettings: |
| 265 | event := a.settingsView.HandleKey(key) |
| 266 | return a.handleSettingsEvent(event) |
| 267 | } |
| 268 | return a, nil |
| 269 | } |
| 270 | |
| 271 | func (a App) handleInitAuthKey(key string) (tea.Model, tea.Cmd) { |
| 272 | switch a.authState { |
no test coverage detected