From 0b96e4da31ec20788aab4f07c1db20ae5eca670e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C5=BD=C3=A1ra?= Date: Sat, 9 May 2020 10:55:41 +0200 Subject: [PATCH] mixer idling --- app/cyp.js | 23 ++++------------------- app/js/elements/player.js | 9 +++------ app/js/mpd-mock.js | 4 ---- app/js/mpd.js | 8 +------- package.json | 2 +- 5 files changed, 9 insertions(+), 37 deletions(-) diff --git a/app/cyp.js b/app/cyp.js index 3c6b1d2..8fa3b2d 100644 --- a/app/cyp.js +++ b/app/cyp.js @@ -283,7 +283,7 @@ async function idle() { if (current) { return; } canTerminateIdle = true; - let lines = await command("idle stored_playlist playlist player options"); + let lines = await command("idle stored_playlist playlist player options mixer"); canTerminateIdle = false; let changed = linesToStruct(lines).changed || []; changed = [].concat(changed); @@ -305,12 +305,6 @@ async function command(cmd) { }); } -async function commandAndStatus(...args) { - args.push("status"); - let lines = await command(args); - return linesToStruct(lines); -} - async function status() { let lines = await command("status"); return linesToStruct(lines); @@ -425,7 +419,6 @@ async function init(a) { var mpd = /*#__PURE__*/Object.freeze({ __proto__: null, command: command, - commandAndStatus: commandAndStatus, status: status, currentSong: currentSong, listQueue: listQueue, @@ -453,10 +446,6 @@ function status$1() { } } -function commandAndStatus$1() { - return status$1(); -} - function currentSong$1() { return { duration: 70, @@ -525,7 +514,6 @@ var mpdMock = /*#__PURE__*/Object.freeze({ __proto__: null, command: command$1, status: status$1, - commandAndStatus: commandAndStatus$1, currentSong: currentSong$1, listQueue: listQueue$1, listPlaylists: listPlaylists$1, @@ -979,7 +967,8 @@ class Player extends Component { case "idle-change": let hasOptions = e.detail.includes("options"); let hasPlayer = e.detail.includes("player"); - (hasOptions || hasPlayer) && this._updateStatus(); + let hasMixer = e.detail.includes("mixer"); + (hasOptions || hasPlayer || hasMixer) && this._updateStatus(); hasPlayer && this._updateCurrent(); break; } @@ -1114,11 +1103,7 @@ class Player extends Component { }); DOM.volume.addEventListener("input", e => this._app.mpd.command(`setvol ${e.target.valueAsNumber}`)); - DOM.mute.addEventListener("click", async _ => { - let data = await this._app.mpd.commandAndStatus(`setvol ${this._toggleVolume}`); - this._updateFlags(data); - this._updateVolume(data); - }); + DOM.mute.addEventListener("click", _ => this._app.mpd.command(`setvol ${this._toggleVolume}`)); } _dispatchSongChange(detail) { diff --git a/app/js/elements/player.js b/app/js/elements/player.js index 81285f0..f40b555 100644 --- a/app/js/elements/player.js +++ b/app/js/elements/player.js @@ -31,7 +31,8 @@ class Player extends Component { case "idle-change": let hasOptions = e.detail.includes("options"); let hasPlayer = e.detail.includes("player"); - (hasOptions || hasPlayer) && this._updateStatus(); + let hasMixer = e.detail.includes("mixer"); + (hasOptions || hasPlayer || hasMixer) && this._updateStatus(); hasPlayer && this._updateCurrent(); break; } @@ -166,11 +167,7 @@ class Player extends Component { }); DOM.volume.addEventListener("input", e => this._app.mpd.command(`setvol ${e.target.valueAsNumber}`)); - DOM.mute.addEventListener("click", async _ => { - let data = await this._app.mpd.commandAndStatus(`setvol ${this._toggleVolume}`); - this._updateFlags(data); - this._updateVolume(data); - }); + DOM.mute.addEventListener("click", _ => this._app.mpd.command(`setvol ${this._toggleVolume}`)); } _dispatchSongChange(detail) { diff --git a/app/js/mpd-mock.js b/app/js/mpd-mock.js index 6ffa97d..074bca0 100644 --- a/app/js/mpd-mock.js +++ b/app/js/mpd-mock.js @@ -11,10 +11,6 @@ export function status() { } } -export function commandAndStatus() { - return status(); -} - export function currentSong() { return { duration: 70, diff --git a/app/js/mpd.js b/app/js/mpd.js index 719f1b2..11a831f 100644 --- a/app/js/mpd.js +++ b/app/js/mpd.js @@ -46,7 +46,7 @@ async function idle() { if (current) { return; } canTerminateIdle = true; - let lines = await command("idle stored_playlist playlist player options"); + let lines = await command("idle stored_playlist playlist player options mixer"); canTerminateIdle = false; let changed = parser.linesToStruct(lines).changed || []; changed = [].concat(changed); @@ -68,12 +68,6 @@ export async function command(cmd) { }); } -export async function commandAndStatus(...args) { - args.push("status"); - let lines = await command(args); - return parser.linesToStruct(lines); -} - export async function status() { let lines = await command("status"); return parser.linesToStruct(lines); diff --git a/package.json b/package.json index ad48e35..f34b783 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "dependencies": { "custom-range": "^1.1.0", "node-static": "^0.7.11", - "ws2mpd": "^2.2.0" + "ws2mpd": "^2.2.1" }, "devDependencies": { "less": "^3.9.0",