0
1
mirror of https://github.com/radio95-rnt/RadioPlayer.git synced 2026-02-26 21:53:54 +01:00

de-select

This commit is contained in:
2025-12-27 21:54:25 +01:00
parent 82e8423178
commit 748913552e
3 changed files with 17 additions and 3 deletions

View File

@@ -137,10 +137,17 @@ class Module(ActiveModifier):
if data.get("action") == "add_to_toplay": if data.get("action") == "add_to_toplay":
songs_to_add = data.get("songs") songs_to_add = data.get("songs")
at_top = data.get("top", False)
if isinstance(songs_to_add, list): if isinstance(songs_to_add, list):
with self.file_lock: with self.file_lock:
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: with open(TOPLAY, "a") as f:
for song_path in songs_to_add: f.write(f"{song_path}\n") 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."} return {"status": "ok", "message": f"{len(songs_to_add)} songs added."}
elif data.get("action") == "get_toplay": elif data.get("action") == "get_toplay":
with self.file_lock: with self.file_lock:

View File

@@ -364,6 +364,12 @@
node.className = "item"; node.className = "item";
node.textContent = f; node.textContent = f;
node.addEventListener("click", () => { 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")); Array.from(dirsBox.children).forEach(c=>c.classList.remove("selected"));
node.classList.add("selected"); node.classList.add("selected");
selectedDir = null; selectedDir = null;

View File

@@ -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"})) await websocket.send(json.dumps({"status": "ok", "action": "skip_requested"}))
elif action == "add_to_toplay": elif action == "add_to_toplay":
songs = msg.get("songs") 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"})) if not isinstance(songs, list): await websocket.send(json.dumps({"error": "songs must be a list"}))
else: 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"})) await websocket.send(json.dumps({"status": "ok", "message": f"{len(songs)} song(s) queued"}))
result = await get_imc("activemod", {"action": "get_toplay"}) result = await get_imc("activemod", {"action": "get_toplay"})