From cb8ddcb99c013dabc7de902e5b8ae74ba16e0abc Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Fri, 16 Jan 2026 14:38:23 -0500 Subject: [PATCH] fix(ui): filepicker: remove redundant Init method and Action type --- internal/ui/dialog/filepicker.go | 9 ++------- internal/ui/model/ui.go | 7 +++---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/internal/ui/dialog/filepicker.go b/internal/ui/dialog/filepicker.go index a099cd2ff9fe6f707ac1e18c8470dba55794889c..b7e7e49735d41136c4c9b9d54b8d8c4fa36a90ae 100644 --- a/internal/ui/dialog/filepicker.go +++ b/internal/ui/dialog/filepicker.go @@ -49,7 +49,7 @@ type FilePicker struct { var _ Dialog = (*FilePicker)(nil) // NewFilePicker creates a new [FilePicker] dialog. -func NewFilePicker(com *common.Common) (*FilePicker, Action) { +func NewFilePicker(com *common.Common) (*FilePicker, tea.Cmd) { f := new(FilePicker) f.com = com @@ -98,7 +98,7 @@ func NewFilePicker(com *common.Common) (*FilePicker, Action) { f.fp = fp - return f, ActionCmd{f.fp.Init()} + return f, f.fp.Init() } // SetImageCapabilities sets the image capabilities for the [FilePicker]. @@ -156,11 +156,6 @@ func (f *FilePicker) ID() string { return FilePickerID } -// Init implements the [Dialog] interface. -func (f *FilePicker) Init() tea.Cmd { - return f.fp.Init() -} - // HandleMsg updates the [FilePicker] dialog based on the given message. func (f *FilePicker) HandleMsg(msg tea.Msg) Action { var cmds []tea.Cmd diff --git a/internal/ui/model/ui.go b/internal/ui/model/ui.go index f40a25204ce167029ee09dc1dbd0fcf012c2a94e..98f0cf7feb875597c04edd5518630736e3756ff2 100644 --- a/internal/ui/model/ui.go +++ b/internal/ui/model/ui.go @@ -2345,13 +2345,12 @@ func (m *UI) openFilesDialog() tea.Cmd { return nil } - filePicker, action := dialog.NewFilePicker(m.com) + filePicker, cmd := dialog.NewFilePicker(m.com) filePicker.SetImageCapabilities(&m.imgCaps) m.dialog.OpenDialog(filePicker) - switch action := action.(type) { - case dialog.ActionCmd: - return action.Cmd + if cmd != nil { + return cmd } return nil