aboutsummaryrefslogtreecommitdiff
path: root/src/main/assets/scripts.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/assets/scripts.js')
-rw-r--r--src/main/assets/scripts.js17
1 files changed, 11 insertions, 6 deletions
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();
});
});