From 08203a791d81694bc79b53d46c44d05e112d42b0 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 10 Apr 2022 02:11:06 +0200 Subject: [PATCH] fsd --- files/assets/js/submit.js | 12 ++++++++---- files/routes/posts.py | 4 ++-- files/templates/submit.html | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/files/assets/js/submit.js b/files/assets/js/submit.js index de7e5efaa..f2aa6ab24 100644 --- a/files/assets/js/submit.js +++ b/files/assets/js/submit.js @@ -113,10 +113,14 @@ function checkRepost(t) { form.append("url", url); xhr.onload=function(){ - const permalink = xhr.response - console.log(permalink) - if (permalink) { - system.innerHTML = `This is a repost of ${permalink}`; + try {data = JSON.parse(xhr.response)} + catch(e) {console.log(e)} + + if (data && data["permalink"]) { + const permalink = data["permalink"] + if (permalink) { + system.innerHTML = `This is a repost of ${permalink}`; + } } } xhr.send(form) diff --git a/files/routes/posts.py b/files/routes/posts.py index b72d319a4..82ca9d5f6 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -854,8 +854,8 @@ def api_is_repost(): Submission.deleted_utc == 0, Submission.is_banned == False ).first() - if repost: return repost.permalink - else: return '' + if repost: return {'permalink': repost.permalink} + else: return {'permalink': ''} @app.post("/submit") @app.post("/h//submit") diff --git a/files/templates/submit.html b/files/templates/submit.html index fec53ebbd..0c53d1c96 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -268,7 +268,7 @@ - + {% include "emoji_modal.html" %} {% include "gif_modal.html" %}