aboutsummaryrefslogtreecommitdiffstats
path: root/desktop
diff options
context:
space:
mode:
Diffstat (limited to 'desktop')
-rw-r--r--desktop/modules/sonix/SonixFolders.qml9
1 files changed, 7 insertions, 2 deletions
diff --git a/desktop/modules/sonix/SonixFolders.qml b/desktop/modules/sonix/SonixFolders.qml
index ad7ae88..b00f4c3 100644
--- a/desktop/modules/sonix/SonixFolders.qml
+++ b/desktop/modules/sonix/SonixFolders.qml
@@ -33,9 +33,11 @@ Column {
function report(ok, d, err) { fo.error = ok ? "" : err; }
function go(p) {
+ fo.notice = "";
Sonix.get("/api/browse?" + S.query({ path: p }), (ok, d, err) => {
fo.report(ok, d, err);
if (!ok) return;
+ if (typeof d !== "object" || d === null) { fo.error = String(d).trim() || "unexpected answer"; return; }
fo.root = d.root;
fo.path = d.path;
fo.entries = d.entries || [];
@@ -48,11 +50,13 @@ Column {
function filesIn(folder, cb) {
Sonix.get("/api/browse?" + S.query({ path: folder }), (ok, d, err) => {
if (!ok) { fo.report(ok, d, err); return; }
+ if (typeof d !== "object" || d === null) { fo.error = String(d).trim() || "unexpected answer"; return; }
cb((d.entries || []).filter(e => !e.dir).map(e => e.path));
});
}
function playFolder(folder) {
+ fo.notice = "";
fo.filesIn(folder, files => {
if (files.length === 0) { fo.error = "no tracks directly in this folder"; return; }
Sonix.command({ do: "play_path", path: files[0], list: "folder", value: folder }, null, fo.report);
@@ -62,6 +66,7 @@ Column {
function addTo(name) {
const a = fo.adding;
if (!a || name === "") return;
+ newName.value = "";
const send = paths => {
if (paths.length === 0) { fo.error = "no tracks directly in this folder"; return; }
Sonix.command({ do: "playlist_add", value: name }, paths.join("\n"), (ok, d, err) => {
@@ -102,7 +107,7 @@ Column {
Button {
text: "Up"
- icon: ""
+ icon: "\uf062"
enabled: fo.path !== fo.root
onClicked: fo.go(S.parentOf(fo.path, fo.root))
}
@@ -164,7 +169,7 @@ Column {
glyph: fo.glyph(0xF040A) // md-play
onClicked: modelData.dir
? fo.playFolder(modelData.path)
- : Sonix.command({ do: "play_path", path: modelData.path, list: "folder", value: fo.path }, null, fo.report)
+ : (fo.notice = "", Sonix.command({ do: "play_path", path: modelData.path, list: "folder", value: fo.path }, null, fo.report))
}
TransportButton {
glyph: fo.glyph(0xF0415) // md-plus