on main help sign in
fix(ui): filepicker: remove redundant Init method and Action type
commitcb8ddcb99c013dabc7de902e5b8ae74ba16e0abc authorAyman Bagabas <ayman.bagabas@gmail.com> dateFri 16 Jan 2026, 14:38 (9 months ago) parentbe46953
2 files changed+5−11
internal/ui/dialog/filepicker.go+2−7 internal/ui/model/ui.go+3−4
internal/ui/dialog/filepicker.go+2−7
@@ -49,7 +49,7 @@ type FilePicker struct {
4949var _ Dialog = (*FilePicker)(nil)
5050
5151// NewFilePicker creates a new [FilePicker] dialog.
52−func NewFilePicker(com *common.Common) (*FilePicker, Action) {
52+func NewFilePicker(com *common.Common) (*FilePicker, tea.Cmd) {
5353 f := new(FilePicker)
5454 f.com = com
5555
@@ -98,7 +98,7 @@ func NewFilePicker(com *common.Common) (*FilePicker, Action) {
9898
9999 f.fp = fp
100100
101− return f, ActionCmd{f.fp.Init()}
101+ return f, f.fp.Init()
102102}
103103
104104// SetImageCapabilities sets the image capabilities for the [FilePicker].
@@ -156,11 +156,6 @@ func (f *FilePicker) ID() string {
156156 return FilePickerID
157157}
158158
159−// Init implements the [Dialog] interface.
160−func (f *FilePicker) Init() tea.Cmd {
161− return f.fp.Init()
162−}
163−
164159// HandleMsg updates the [FilePicker] dialog based on the given message.
165160func (f *FilePicker) HandleMsg(msg tea.Msg) Action {
166161 var cmds []tea.Cmd
internal/ui/model/ui.go+3−4
@@ -2345,13 +2345,12 @@ func (m *UI) openFilesDialog() tea.Cmd {
23452345 return nil
23462346 }
23472347
2348− filePicker, action := dialog.NewFilePicker(m.com)
2348+ filePicker, cmd := dialog.NewFilePicker(m.com)
23492349 filePicker.SetImageCapabilities(&m.imgCaps)
23502350 m.dialog.OpenDialog(filePicker)
23512351
2352− switch action := action.(type) {
2353− case dialog.ActionCmd:
2354− return action.Cmd
2352+ if cmd != nil {
2353+ return cmd
23552354 }
23562355
23572356 return nil