From 4235b4a4d555882ce86628a88dd4e4eeee2c9097 Mon Sep 17 00:00:00 2001 From: Caleb Allen Date: Tue, 17 Mar 2026 21:03:17 -0400 Subject: [PATCH] feat(17-01): add WriteTrackTagsByPath and ImageFilePicker backend methods - WriteTrackTagsByPath resolves filePath to trackID via GetAudioFileByPath - ImageFilePicker opens native file dialog filtered to JPEG/PNG - Added Wails TypeScript bindings for both new methods --- backend/frontendutil/frontendutil.go | 23 +++++++++++++++++++ backend/tagwriter/pipeline.go | 14 +++++++++++ .../wailsjs/go/frontendutil/FrontendUtil.d.ts | 2 ++ .../wailsjs/go/frontendutil/FrontendUtil.js | 4 ++++ frontend/wailsjs/go/tagwriter/TagWriter.d.ts | 10 ++++++++ frontend/wailsjs/go/tagwriter/TagWriter.js | 15 ++++++++++++ 6 files changed, 68 insertions(+) create mode 100755 frontend/wailsjs/go/tagwriter/TagWriter.d.ts create mode 100755 frontend/wailsjs/go/tagwriter/TagWriter.js diff --git a/backend/frontendutil/frontendutil.go b/backend/frontendutil/frontendutil.go index ada82a7..c53fee2 100644 --- a/backend/frontendutil/frontendutil.go +++ b/backend/frontendutil/frontendutil.go @@ -67,3 +67,26 @@ func (fe *FrontendUtil) PlaylistFilePicker() ( return files, nil } + +// ImageFilePicker opens a file selection dialog filtered to image +// files (JPEG, PNG). Returns the selected file path, or empty +// string if the user cancelled. +func (fe *FrontendUtil) ImageFilePicker() (string, error) { + file, err := runtime.OpenFileDialog( + fe.ctx, + runtime.OpenDialogOptions{ + Title: "Select Cover Art", + Filters: []runtime.FileFilter{ + { + DisplayName: "Image Files (*.jpg, *.jpeg, *.png)", + Pattern: "*.jpg;*.jpeg;*.png", + }, + }, + }, + ) + if err != nil { + return "", fmt.Errorf("could not open file dialog: %w", err) + } + + return file, nil +} diff --git a/backend/tagwriter/pipeline.go b/backend/tagwriter/pipeline.go index 855d19e..75128f0 100644 --- a/backend/tagwriter/pipeline.go +++ b/backend/tagwriter/pipeline.go @@ -172,3 +172,17 @@ func (tw *TagWriter) WriteTrackTags(trackID int64, changes TagChanges) error { return nil } + +// WriteTrackTagsByPath resolves a file path to its audio_file.id and +// delegates to WriteTrackTags. This is the frontend-facing entry +// point since the frontend identifies tracks by FilePath. +func (tw *TagWriter) WriteTrackTagsByPath(filePath string, changes TagChanges) error { + ctx := context.Background() + + audioFile, err := tw.db.Queries.GetAudioFileByPath(ctx, filePath) + if err != nil { + return fmt.Errorf("resolve track by path %q: %w", filePath, err) + } + + return tw.WriteTrackTags(audioFile.ID, changes) +} diff --git a/frontend/wailsjs/go/frontendutil/FrontendUtil.d.ts b/frontend/wailsjs/go/frontendutil/FrontendUtil.d.ts index f579f7a..9f23326 100755 --- a/frontend/wailsjs/go/frontendutil/FrontendUtil.d.ts +++ b/frontend/wailsjs/go/frontendutil/FrontendUtil.d.ts @@ -4,6 +4,8 @@ import {context} from '../models'; export function DirectoryPicker():Promise; +export function ImageFilePicker():Promise; + export function PlaylistFilePicker():Promise>; export function SetContext(arg1:context.Context):Promise; diff --git a/frontend/wailsjs/go/frontendutil/FrontendUtil.js b/frontend/wailsjs/go/frontendutil/FrontendUtil.js index 858ac2c..2d51b3f 100755 --- a/frontend/wailsjs/go/frontendutil/FrontendUtil.js +++ b/frontend/wailsjs/go/frontendutil/FrontendUtil.js @@ -6,6 +6,10 @@ export function DirectoryPicker() { return window['go']['frontendutil']['FrontendUtil']['DirectoryPicker'](); } +export function ImageFilePicker() { + return window['go']['frontendutil']['FrontendUtil']['ImageFilePicker'](); +} + export function PlaylistFilePicker() { return window['go']['frontendutil']['FrontendUtil']['PlaylistFilePicker'](); } diff --git a/frontend/wailsjs/go/tagwriter/TagWriter.d.ts b/frontend/wailsjs/go/tagwriter/TagWriter.d.ts new file mode 100755 index 0000000..dc57e7b --- /dev/null +++ b/frontend/wailsjs/go/tagwriter/TagWriter.d.ts @@ -0,0 +1,10 @@ +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT +import {context} from '../models'; +import {tagwriter} from '../models'; + +export function SetContext(arg1:context.Context):Promise; + +export function WriteTrackTags(arg1:number,arg2:tagwriter.TagChanges):Promise; + +export function WriteTrackTagsByPath(arg1:string,arg2:tagwriter.TagChanges):Promise; diff --git a/frontend/wailsjs/go/tagwriter/TagWriter.js b/frontend/wailsjs/go/tagwriter/TagWriter.js new file mode 100755 index 0000000..b29810f --- /dev/null +++ b/frontend/wailsjs/go/tagwriter/TagWriter.js @@ -0,0 +1,15 @@ +// @ts-check +// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL +// This file is automatically generated. DO NOT EDIT + +export function SetContext(arg1) { + return window['go']['tagwriter']['TagWriter']['SetContext'](arg1); +} + +export function WriteTrackTags(arg1, arg2) { + return window['go']['tagwriter']['TagWriter']['WriteTrackTags'](arg1, arg2); +} + +export function WriteTrackTagsByPath(arg1, arg2) { + return window['go']['tagwriter']['TagWriter']['WriteTrackTagsByPath'](arg1, arg2); +}