aboutsummaryrefslogtreecommitdiff
path: root/src/main/assets
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2024-04-26 18:33:58 +0300
committerGravatar Vitaly Takmazov2024-04-26 18:33:58 +0300
commite00dc41afada45c9cc0cab882d5e67f8d0c980f2 (patch)
treedaf9e4f9de024f51dc3a581f38bf1d34986ce74f /src/main/assets
parent57fae6b2d4e2f94e49a3b809a47ef4abc2a1ef80 (diff)
"Mark read" buttonmark_read
Diffstat (limited to 'src/main/assets')
-rw-r--r--src/main/assets/scripts.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main/assets/scripts.js b/src/main/assets/scripts.js
index 3c83bba4..50406f1c 100644
--- a/src/main/assets/scripts.js
+++ b/src/main/assets/scripts.js
@@ -533,6 +533,20 @@ function fetchUserUri(dataUri) {
})
}
+function markRead() {
+ return new Promise((resolve) => {
+ fetch('/api/messages/mark_read', {
+ method: 'POST'
+ }).then(handleErrors)
+ .then(() => {
+ resolve(true)
+ })
+ .catch(() => {
+ resolve(false)
+ })
+ })
+}
+
const registerServiceWorker = () => {
const publicKey = 'BPU0LniKKR0QiaUvILPd9AystmSOU8rWDZobxKm7IJN5HYxOSQdktRdc74TZvyRS9_kyUz7LDN6gUAmAVOmObAU'
navigator.serviceWorker.register('/sw.js', { scope: '/' })
@@ -825,4 +839,14 @@ ready(() => {
})
notificationsCheckPermissions(button)
}
+ const markReadButton = document.getElementById('messages_mark_read')
+ if (markReadButton) {
+ markReadButton.addEventListener('click', () => {
+ if (markRead()) {
+ window.location.reload()
+ } else {
+ alert('Something went wrong :(')
+ }
+ })
+ }
})