From fdad92047bdf5a8abd74d3d8528c84c2c389cfd4 Mon Sep 17 00:00:00 2001 From: = <=> Date: Wed, 4 Feb 2026 22:23:41 -0500 Subject: [PATCH] Refresh fix. --- modules/web_app.py | 8 ++++++++ templates/project.html | 42 +++++++++++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/modules/web_app.py b/modules/web_app.py index a3107db..2e91bfe 100644 --- a/modules/web_app.py +++ b/modules/web_app.py @@ -615,6 +615,14 @@ def refine_bible_route(id): return {"status": "queued", "task_id": task.id} +@app.route('/project//is_refining') +@login_required +def check_refinement_status(id): + proj = db.session.get(Project, id) or Project.query.get_or_404(id) + if proj.user_id != current_user.id: return "Unauthorized", 403 + is_refining = os.path.exists(os.path.join(proj.folder_path, ".refining")) + return {"is_refining": is_refining} + @app.route('/project//refine_bible/confirm', methods=['POST']) @login_required def confirm_bible_refinement(id): diff --git a/templates/project.html b/templates/project.html index 0088fce..e082d43 100644 --- a/templates/project.html +++ b/templates/project.html @@ -605,6 +605,21 @@ fetchLog(); {% endif %} + function showRefiningModal() { + if (!document.getElementById('refineProgressModal')) { + const modalHtml = ` + `; + document.body.insertAdjacentHTML('beforeend', modalHtml); + } + const modal = new bootstrap.Modal(document.getElementById('refineProgressModal')); + modal.show(); + } + function submitRefineModal(event) { event.preventDefault(); const form = event.target; @@ -628,23 +643,14 @@ const inputModal = bootstrap.Modal.getInstance(inputModalEl); inputModal.hide(); - const modalHtml = ` - `; - document.body.insertAdjacentHTML('beforeend', modalHtml); - const progressModal = new bootstrap.Modal(document.getElementById('refineProgressModal')); - progressModal.show(); + showRefiningModal(); const pollInterval = setInterval(() => { fetch(`/task_status/${data.task_id}`).then(r => r.json()).then(status => { if (status.status === 'completed') { clearInterval(pollInterval); if (status.success) { - window.location.reload(); + window.location.href = "/project/{{ project.id }}/bible_comparison"; } else { alert("Refinement failed. Please check the logs."); window.location.reload(); @@ -660,5 +666,19 @@ btn.innerHTML = originalText; }); } + + {% if is_refining %} + document.addEventListener('DOMContentLoaded', function() { + showRefiningModal(); + const pollInterval = setInterval(() => { + fetch("/project/{{ project.id }}/is_refining").then(r => r.json()).then(data => { + if (!data.is_refining) { + clearInterval(pollInterval); + window.location.href = "/project/{{ project.id }}/bible_comparison"; + } + }); + }, 2000); + }); + {% endif %} {% endblock %} \ No newline at end of file