aboutsummaryrefslogtreecommitdiff
path: root/src/main/assets
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-04-17 15:00:14 +0300
committerGravatar Vitaly Takmazov2023-04-17 15:00:14 +0300
commitcf3a5d8c979b114fceef43b35541b941bcbd62a1 (patch)
tree9a639a3b3ad35b94ebf13cad5889e9fa4974b820 /src/main/assets
parent36bbb8317990022453b6127d90b11ffd5122d596 (diff)
Private posts
Diffstat (limited to 'src/main/assets')
-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();
});
});