From cf3a5d8c979b114fceef43b35541b941bcbd62a1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 17 Apr 2023 15:00:14 +0300 Subject: Private posts --- src/main/assets/scripts.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/main/assets') diff --git a/src/main/assets/scripts.js b/src/main/assets/scripts.js index 20d32fd9..6c5e987b 100644 --- a/src/main/assets/scripts.js +++ b/src/main/assets/scripts.js @@ -478,12 +478,18 @@ function subscribeMessage(e, mid) { function setPrivacy(e, mid) { fetch('/api/messages/set_privacy?mid=' + mid + '&hash=' + document.getElementById('body').getAttribute('data-hash'), { - credentials: 'same-origin' + credentials: 'same-origin', + method: 'POST' }) .then(handleErrors) - .then(function() { - e.closest('article').append(resultMessage('OK!')); - }); + .then(function(response) { + if (response.ok) { + window.location.reload(); + } else { + alert('Something went wrong :('); + } + }) + .catch(console.err); return false; } @@ -702,10 +708,9 @@ ready(() => { Array.from(document.querySelectorAll('.l .a-privacy')).forEach(function(e) { e.addEventListener('click', function(e) { - const article = /** @type {HTMLElement} */((e.target).closest('article')); setPrivacy( e.target, - article.getAttribute('data-mid')); + document.getElementById('content').getAttribute('data-mid')); e.preventDefault(); }); }); -- cgit v1.2.3