From a139197371092330c1440d2646cc7602747ca974 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 14 Jul 2023 20:07:58 +0300 Subject: [PATCH] persist ppl's edit text on failure --- files/assets/js/core.js | 8 ++++++++ files/routes/posts.py | 3 +-- files/templates/post.html | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/files/assets/js/core.js b/files/assets/js/core.js index d8a02edfb..b233bea46 100644 --- a/files/assets/js/core.js +++ b/files/assets/js/core.js @@ -327,6 +327,14 @@ function sendFormXHRSwitch(form) { ) } +function sendFormXHRReload(form) { + sendFormXHR(form, + () => { + location.reload(); + } + ) +} + let sortAscending = {}; function sort_table(t) { diff --git a/files/routes/posts.py b/files/routes/posts.py index 98c5851ce..65bee6eab 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -1089,5 +1089,4 @@ def edit_post(pid, v): ) g.db.add(ma) - - return redirect(p.permalink) + return {"message": "Post edited successfully!"} diff --git a/files/templates/post.html b/files/templates/post.html index 04dc0594d..4cb19e82f 100644 --- a/files/templates/post.html +++ b/files/templates/post.html @@ -157,7 +157,7 @@ {% if v and v.can_edit(p) and not v.is_suspended %}