fix(ui): filepicker: remove redundant Init method and Action type

Ayman Bagabas created

Change summary

internal/ui/dialog/filepicker.go | 9 ++-------
internal/ui/model/ui.go          | 7 +++----
2 files changed, 5 insertions(+), 11 deletions(-)

Detailed changes

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

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