saving and displaying the configured library dir

This commit is contained in:
2025-03-22 17:00:21 -05:00
parent e3f47c602f
commit eba3187f39
5 changed files with 32 additions and 7 deletions
+6 -1
View File
@@ -40,7 +40,7 @@ func (a *App) startup(ctx context.Context) {
if err != nil { if err != nil {
panic(fmt.Errorf("could not initialize library: %w", err)) panic(fmt.Errorf("could not initialize library: %w", err))
} }
// config might have been updated, so lets propogate that to the app // config might have been updated, so lets propagate that to the app
a.config.Library = musicLib.Conf a.config.Library = musicLib.Conf
runtime.LogInfo(a.ctx, fmt.Sprintf("using library %s", logging.PrettyJSON(musicLib))) runtime.LogInfo(a.ctx, fmt.Sprintf("using library %s", logging.PrettyJSON(musicLib)))
@@ -66,3 +66,8 @@ func (a *App) DirectoryPicker() (string, error) {
a.config.WriteConfig() a.config.WriteConfig()
return dir, nil return dir, nil
} }
// trying to make a function
func (a *App) GetLibraryDir() (string, error) {
return a.config.Library.DirectoryPath, nil
}
+3
View File
@@ -7,6 +7,9 @@
<title>yellowjacket</title> <title>yellowjacket</title>
</head> </head>
<script src="./src/main.js" type="module"></script> <script src="./src/main.js" type="module"></script>
<script>
import {GetLibraryDir} from './wailsjs/go/main/App';
</script>
<body> <body>
<header class="container"> <header class="container">
+17 -6
View File
@@ -1,19 +1,30 @@
import './pico.css'; import './pico.css';
import { DirectoryPicker } from '../wailsjs/go/main/App'; import { DirectoryPicker, GetLibraryDir } from '../wailsjs/go/main/App';
let libraryDirectoryLabel = document.getElementById("library-directory-label"); let libraryDirectoryLabel = document.getElementById("library-directory-label");
window.dirPicker = function () { GetLibraryDir().
then((result) => {
if (result.length === 0) { return; }
window.updateLibraryDirLabel(result);
}).catch((err) => { console.error(err) })
window.dirPicker = function() {
var dir; var dir;
try { try {
DirectoryPicker() DirectoryPicker()
.then((result) => {libraryDirectoryLabel.innerText = result;}) .then((result) => { window.updateLibraryDirLabel(result); })
.catch((err) => { .catch((err) => {
console.log("There is an error with directory picker") console.log("There is an error with directory picker")
console.error(err);}); console.error(err);
});
} }
catch (err) { catch (err) {
console.error(err); console.error(err);
} }
} }
window.updateLibraryDirLabel = function(value) {
libraryDirectoryLabel.innerText = value;
}
+2
View File
@@ -2,3 +2,5 @@
// This file is automatically generated. DO NOT EDIT // This file is automatically generated. DO NOT EDIT
export function DirectoryPicker():Promise<string>; export function DirectoryPicker():Promise<string>;
export function GetLibraryDir():Promise<string>;
+4
View File
@@ -5,3 +5,7 @@
export function DirectoryPicker() { export function DirectoryPicker() {
return window['go']['main']['App']['DirectoryPicker'](); return window['go']['main']['App']['DirectoryPicker']();
} }
export function GetLibraryDir() {
return window['go']['main']['App']['GetLibraryDir']();
}