diff --git a/app.py b/app.py index 3a90208..2d2b809 100644 --- a/app.py +++ b/app.py @@ -1733,10 +1733,13 @@ async def api_pull_model(request: Request): def api_clear_history(): with state_lock: st = load_state() - st["history"] = [] - save_state(st) - logger.info("Cleared the job history") - return {"ok": True} + count = len(st["history"]) + if count: + st["history"] = [] + save_state(st) + if count: + logger.info("Cleared %d jobs from the list", count) + return {"ok": True, "cleared": count} @app.get("/api/trending") diff --git a/static/index.html b/static/index.html index 9849828..149211b 100644 --- a/static/index.html +++ b/static/index.html @@ -290,8 +290,11 @@ try{document.execCommand("copy");$("#copy-msg").textContent="Copied"}catch(err){ ta.remove()} setTimeout(()=>{$("#copy-msg").textContent=""},3000)}; $("#clear-jobs").onclick=async()=>{ -if(!confirm("Clear the job list? Videos on disk and on YouTube are not touched."))return; -try{await api("/api/history/clear",{method:"POST"});refresh()}catch(e){alert(e.message)}}; +const b=$("#clear-jobs"); +if(b.disabled)return; +b.disabled=true; +try{await api("/api/history/clear",{method:"POST"});await refresh()}catch(e){alert(e.message)} +b.disabled=false}; $("#preview").onclick=async()=>{ $("#preview-msg").textContent="Loading..."; try{