From 748913552ef303fdffb87ff2a8c58c9ac4468848 Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Sat, 27 Dec 2025 21:54:25 +0100 Subject: [PATCH] de-select --- modules/active_modifier.py | 11 +++++++++-- modules/web.html | 6 ++++++ modules/web.py | 3 ++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/active_modifier.py b/modules/active_modifier.py index 5130e3e..07c6446 100644 --- a/modules/active_modifier.py +++ b/modules/active_modifier.py @@ -137,10 +137,17 @@ class Module(ActiveModifier): if data.get("action") == "add_to_toplay": songs_to_add = data.get("songs") + at_top = data.get("top", False) if isinstance(songs_to_add, list): with self.file_lock: - with open(TOPLAY, "a") as f: - for song_path in songs_to_add: f.write(f"{song_path}\n") + if at_top: + with open(TOPLAY, "r") as f: data = f.read() + with open(TOPLAY, "w") as f: + for song_path in songs_to_add: f.write(f"\n{song_path}\n") + f.write(data) + else: + with open(TOPLAY, "a") as f: + for song_path in songs_to_add: f.write(f"\n{song_path}\n") return {"status": "ok", "message": f"{len(songs_to_add)} songs added."} elif data.get("action") == "get_toplay": with self.file_lock: diff --git a/modules/web.html b/modules/web.html index 0cc99f1..14c14b5 100644 --- a/modules/web.html +++ b/modules/web.html @@ -364,6 +364,12 @@ node.className = "item"; node.textContent = f; node.addEventListener("click", () => { + if(node.classList.contains("selected")) { + node.classList.remove("selected"); + selectedDir = null; + selectedSubFile = null; + return; + } Array.from(dirsBox.children).forEach(c=>c.classList.remove("selected")); node.classList.add("selected"); selectedDir = null; diff --git a/modules/web.py b/modules/web.py index a4dba8e..7bc1aa8 100644 --- a/modules/web.py +++ b/modules/web.py @@ -45,9 +45,10 @@ async def ws_handler(websocket: ServerConnection, shared_data: dict, imc_q: mult await websocket.send(json.dumps({"status": "ok", "action": "skip_requested"})) elif action == "add_to_toplay": songs = msg.get("songs") + at_top = msg.get("top", False) if not isinstance(songs, list): await websocket.send(json.dumps({"error": "songs must be a list"})) else: - imc_q.put({"name": "activemod", "data": {"action": "add_to_toplay", "songs": songs}}) + imc_q.put({"name": "activemod", "data": {"action": "add_to_toplay", "songs": songs, "at_top": at_top}}) await websocket.send(json.dumps({"status": "ok", "message": f"{len(songs)} song(s) queued"})) result = await get_imc("activemod", {"action": "get_toplay"})