diff --git a/files/assets/js/pinpost.js b/files/assets/js/pinpost.js index b99f450ae..32c36ab6d 100644 --- a/files/assets/js/pinpost.js +++ b/files/assets/js/pinpost.js @@ -5,16 +5,19 @@ function pinPost(t, id) { { }, (xhr) => { - if(xhr.status == 200) { - t.innerHTML = t.innerHTML.replace(t.textContent, 'Pin permanently') + if (xhr.status >= 200 && xhr.status < 300) { + response = JSON.parse(xhr.response); + length = response["length"]; + if (length == "permanently") { + t.innerHTML = t.innerHTML.replace(t.textContent, 'Pin for 1 hour'); + t.classList.add('d-none'); + } else { + t.innerHTML = t.innerHTML.replace(t.textContent, 'Pin permanently'); + } + t.nextElementSibling.classList.remove('d-none'); + t.disabled = false; + t.classList.remove("disabled"); } - else if(xhr.status == 201) { - t.innerHTML = t.innerHTML.replace(t.textContent, 'Pin for 1 hour') - t.classList.add('d-none') - } - t.nextElementSibling.classList.remove('d-none') - t.disabled = false; - t.classList.remove("disabled"); } ); setTimeout(() => { diff --git a/files/helpers/const.py b/files/helpers/const.py index e8600701c..6664be6ce 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -152,6 +152,7 @@ AGENDAPOSTER_MSG_HTML = """