make ws api simpler

This commit is contained in:
2026-04-15 21:17:50 +02:00
parent 096a2e51e3
commit f31a85a62c
2 changed files with 2 additions and 7 deletions
-4
View File
@@ -284,10 +284,6 @@
const d = msg.data || {};
if(d.track) applyProgressState(d.track);
if(d.dirs) updateDirs(d.dirs);
if(d.rds) {
const rt = (d.rds?.rt) ?? "";
document.getElementById("rds-text").textContent = rt ?? "";
}
} else if (msg.event === "rds") {
const rt = (msg.data?.rt) ?? "";
document.getElementById("rds-text").textContent = rt ?? "";
+2 -3
View File
@@ -16,13 +16,12 @@ async def ws_handler(websocket: ServerConnection, shared_data: dict, imc_q: mult
try:
initial = {
"track": json.loads(shared_data.get("track", "{}")),
"progress": json.loads(shared_data.get("progress", "{}")),
"dirs": {"files": [i.name for i in list(MAIN_PATH_DIR.iterdir()) if i.is_file()], "dirs": [i.name for i in list(MAIN_PATH_DIR.iterdir()) if i.is_dir()], "base": str(MAIN_PATH_DIR)},
"rds": json.loads(shared_data.get("rds", "{}"))
}
except Exception: initial = {"track": {}, "progress": {}, "dirs": {}, "rds": {}}
except Exception: initial = {"track": {}, "dirs": {}}
await websocket.send(json.dumps({"event": "state", "data": initial}))
await websocket.send(json.dumps({"event": "playlist", "data": json.loads(shared_data.get("playlist", "[]"))}))
await websocket.send(json.dumps({"event": "rds", "data": json.loads(shared_data.get("rds", "{}"))}))
async for raw in websocket:
try: msg: dict = json.loads(raw)