sync with regular mpd

This commit is contained in:
Ondrej Zara 2020-03-13 10:36:13 +01:00
parent 33361a4552
commit 0b9a1ad7af
6 changed files with 26 additions and 27 deletions

View file

@ -1,3 +1,2 @@
cyp-library {
cyp-song .subtitle { display: none; }
}

View file

@ -13,5 +13,7 @@ cyp-song {
.subtitle { .ellipsis; }
}
cyp-queue & .track { display: none; }
}

File diff suppressed because one or more lines are too long

View file

@ -19,7 +19,7 @@ function createEnqueueCommand(node) {
`sort ${SORT}`
].join(" ");
} else {
throw new Exception(`Cannot create enqueue command for "${node.nodeName}"`);
throw new Error(`Cannot create enqueue command for "${node.nodeName}"`);
}
}

View file

@ -5,38 +5,36 @@ import Item from "../item.js";
export default class Song extends Item {
constructor(data) {
super();
this.data = data;
this.dataset.songId = data["Id"];
this.data = data; // FIXME verejne?
this.dataset.songId = data["Id"]; // FIXME toto maji jen ve fronte
}
connectedCallback() {
let block = html.node("div", {className:"multiline"}, "", this);
const data = this.data;
let lines = formatSongInfo(this.data);
block.appendChild(this._buildTitle(lines.shift()));
const block = html.node("div", {className:"multiline"}, "", this);
lines.length && html.node("span", {className:"subtitle"}, lines.shift(), block);
const title = this._buildTitle(data);
block.appendChild(title);
if (data["Track"]) {
const track = html.node("span", {className:"track"}, data["Track"].padStart(2, "0"));
title.insertBefore(html.text(" "), title.firstChild);
title.insertBefore(track, title.firstChild);
}
if (data["Title"]) {
const subtitle = format.subtitle(data);
html.node("span", {className:"subtitle"}, subtitle, block);
}
}
_buildTitle(data) {
return super._buildTitle(data["Title"] || fileName(data));
}
}
customElements.define("cyp-song", Song);
// FIXME vyfaktorovat nekam do haje
function formatSongInfo(data) {
let lines = [];
if (data["Title"]) {
lines.push(data["Title"]);
lines.push(format.subtitle(data));
} else {
lines.push(fileName(data));
lines.push("\u00A0");
}
return lines;
}
// FIXME vyfaktorovat nekam do haje
function fileName(data) {
return data["file"].split("/").pop();

View file

@ -95,9 +95,9 @@ export async function listPath(path) {
return parser.pathContents(lines);
}
export async function listTags(tag, filter = null) {
export async function listTags(tag, filter = {}) {
let tokens = ["list", tag];
if (filter) {
if (Object.keys(filter).length) {
tokens.push(serializeFilter(filter));
let fakeGroup = Object.keys(filter)[0]; // FIXME hack for MPD < 0.21.6