refactor(ui/chat): migrate to command-based api for (*attachmentsPicker).close

This commit is contained in:
ayn2op 2026-03-22 16:00:42 -04:00
parent b2f079b700
commit 3397a4426d
2 changed files with 4 additions and 10 deletions

View file

@ -45,9 +45,9 @@ func (ap *attachmentsPicker) SetItems(items []attachmentItem) {
ap.Model.SetItems(pickerItems)
}
func (ap *attachmentsPicker) close() {
func (ap *attachmentsPicker) close() tview.Command {
ap.chatView.RemoveLayer(attachmentsPickerLayerName)
ap.chatView.app.SetFocus(ap.chatView.messagesList)
return tview.SetFocus(ap.chatView.messagesList)
}
func (ap *attachmentsPicker) HandleEvent(event tview.Event) tview.Command {
@ -61,11 +61,9 @@ func (ap *attachmentsPicker) HandleEvent(event tview.Event) tview.Command {
return nil
}
ap.items[index].open()
ap.close()
return nil
return ap.close()
case *picker.CancelEvent:
ap.close()
return nil
return ap.close()
}
return ap.Model.HandleEvent(event)

View file

@ -30,10 +30,6 @@ func (m *Model) activeKeyMap() help.KeyMap {
return m.channelsPicker
}
if m.app == nil {
return nil
}
switch m.app.Focused() {
case m.guildsTree:
return m.guildsTree