From b6f0fe758303e1446f45d6367075b99ec77d8af3 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 29 Apr 2025 09:52:30 +0000 Subject: refactor with permissions --- view/js/main.js | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index b54879e40..c927e8521 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1266,40 +1266,51 @@ function justifyPhotosAjax(id) { $('#' + id).justifiedGallery('norewind').on('jg.complete', function(e){ justifiedGalleryActive = false; }); } -function request(id, mid, verb) { +function request(id, mid, verb, parent) { + + const loading = document.getElementById('like-rotator-' + id); + loading.style.display = 'block'; if (verb === 'comment') { - fetch('/request?verb=' + verb + '&mid=' + mid) + + document.querySelectorAll('.thread-wrapper.item-highlight').forEach(el => { + el.classList.remove('item-highlight'); + }); + + document.getElementById('thread-wrapper-' + id).classList.add('item-highlight'); + + fetch('/request?verb=' + verb + '&mid=' + mid + '&parent=' + parent + '&module=' + module) .then(response => response.json()) .then(obj => { injectWithAnimation('sub-thread-wrapper-' + id, obj.html); updateRelativeTime('.autotime'); + loading.style.display = 'none'; }) .catch(error => { console.error('Error fetching data:', error); }); } else { - const modal = new bootstrap.Modal('#reactions'); - modal.show(); - - const modal_content = document.getElementById('reactions_body'); - modal_content.innerHTML = 'Loading...'; - - const modal_title = document.getElementById('reactions_title'); - modal_title.innerHTML = verb; - - const modal_action = document.getElementById('reactions_action'); - modal_action.innerHTML = ''; - - fetch('/request?verb=' + verb + '&mid=' + mid) + fetch('/request?verb=' + verb + '&mid=' + mid + '&parent=' + parent) .then(response => response.json()) .then(obj => { + const modal = new bootstrap.Modal('#reactions'); + const modal_content = document.getElementById('reactions_body'); + const modal_title = document.getElementById('reactions_title'); + const modal_action = document.getElementById('reactions_action'); + modal_action.style.display = 'none'; + modal_title.innerHTML = verb; modal_content.innerHTML = ''; - modal_action.innerHTML = '' + obj.action_label + ''; + if (obj.action) { + modal_action.innerHTML = '' + obj.action_label + ''; + modal_action.style.display = 'block'; + } obj.result.forEach(e => { modal_content.innerHTML += ' ' + e.name + ''; }); + + modal.show(); + loading.style.display = 'none'; }) .catch(error => { console.error('Error fetching data:', error); @@ -1328,7 +1339,8 @@ function injectWithAnimation(container, html) { ], { duration: 300, delay: i * 50, - fill: 'both' + fill: 'both', + easing: 'ease-out' }); }); } -- cgit v1.2.3