diff --git a/app.go b/app.go
index dcae8dc..d6ae393 100644
--- a/app.go
+++ b/app.go
@@ -40,7 +40,7 @@ func (a *App) startup(ctx context.Context) {
if err != nil {
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
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()
return dir, nil
}
+
+// trying to make a function
+func (a *App) GetLibraryDir() (string, error) {
+ return a.config.Library.DirectoryPath, nil
+}
diff --git a/frontend/index.html b/frontend/index.html
index 528eeb9..c4bfe31 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -7,6 +7,9 @@
yellowjacket
+
diff --git a/frontend/src/main.js b/frontend/src/main.js
index fa7720d..eb1eba2 100644
--- a/frontend/src/main.js
+++ b/frontend/src/main.js
@@ -1,19 +1,30 @@
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");
-window.dirPicker = function () {
+GetLibraryDir().
+ then((result) => {
+ if (result.length === 0) { return; }
+ window.updateLibraryDirLabel(result);
+ }).catch((err) => { console.error(err) })
+
+window.dirPicker = function() {
var dir;
try {
DirectoryPicker()
- .then((result) => {libraryDirectoryLabel.innerText = result;})
- .catch((err) => {
- console.log("There is an error with directory picker")
- console.error(err);});
+ .then((result) => { window.updateLibraryDirLabel(result); })
+ .catch((err) => {
+ console.log("There is an error with directory picker")
+ console.error(err);
+ });
}
catch (err) {
console.error(err);
}
}
+
+window.updateLibraryDirLabel = function(value) {
+ libraryDirectoryLabel.innerText = value;
+}
diff --git a/frontend/wailsjs/go/main/App.d.ts b/frontend/wailsjs/go/main/App.d.ts
index 265d33e..d1b1475 100755
--- a/frontend/wailsjs/go/main/App.d.ts
+++ b/frontend/wailsjs/go/main/App.d.ts
@@ -2,3 +2,5 @@
// This file is automatically generated. DO NOT EDIT
export function DirectoryPicker():Promise;
+
+export function GetLibraryDir():Promise;
diff --git a/frontend/wailsjs/go/main/App.js b/frontend/wailsjs/go/main/App.js
index 36071ac..fd828ba 100755
--- a/frontend/wailsjs/go/main/App.js
+++ b/frontend/wailsjs/go/main/App.js
@@ -5,3 +5,7 @@
export function DirectoryPicker() {
return window['go']['main']['App']['DirectoryPicker']();
}
+
+export function GetLibraryDir() {
+ return window['go']['main']['App']['GetLibraryDir']();
+}