previews and make sure blurry thumb gets always generated when rating is changed later on
This commit is contained in:
@@ -7177,12 +7177,30 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
activeThumb = null;
|
activeThumb = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
window.clearHoverPreview = clearPreview;
|
||||||
|
|
||||||
// Use mouseover/mouseout bubbling on document for dynamic elements
|
// Use mouseover/mouseout bubbling on document for dynamic elements
|
||||||
const startPreview = (thumb, delay = 150) => {
|
const startPreview = (thumb, delay = 150) => {
|
||||||
// Clear any existing preview
|
// Clear any existing preview
|
||||||
clearPreview();
|
clearPreview();
|
||||||
|
|
||||||
|
// If this thumbnail is currently set to be blurred and is not revealed yet, do not preview it!
|
||||||
|
const mode = thumb.getAttribute('data-mode');
|
||||||
|
const blurNsfw = localStorage.getItem('blurNsfw') === 'true';
|
||||||
|
const blurNsfl = localStorage.getItem('blurNsfl') === 'true';
|
||||||
|
const blurSfw = localStorage.getItem('blurSfw') === 'true';
|
||||||
|
const blurUntagged = localStorage.getItem('blurUntagged') === 'true';
|
||||||
|
|
||||||
|
let shouldBlurThis = false;
|
||||||
|
if (mode === 'nsfw') shouldBlurThis = blurNsfw;
|
||||||
|
else if (mode === 'nsfl') shouldBlurThis = blurNsfl;
|
||||||
|
else if (mode === 'sfw') shouldBlurThis = blurSfw;
|
||||||
|
else if (mode === 'null' || !mode) shouldBlurThis = blurUntagged;
|
||||||
|
|
||||||
|
if (shouldBlurThis && !thumb.classList.contains('revealed')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
activeThumb = thumb;
|
activeThumb = thumb;
|
||||||
activeThumb.classList.add('touch-active'); // Visual feedback (box-shadow)
|
activeThumb.classList.add('touch-active'); // Visual feedback (box-shadow)
|
||||||
|
|
||||||
@@ -7222,6 +7240,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
hoverTimeout = setTimeout(run, delay);
|
hoverTimeout = setTimeout(run, delay);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
window.startHoverPreview = startPreview;
|
||||||
|
|
||||||
document.addEventListener('mouseover', (e) => {
|
document.addEventListener('mouseover', (e) => {
|
||||||
const thumb = e.target.closest('.thumb');
|
const thumb = e.target.closest('.thumb');
|
||||||
@@ -8775,6 +8794,11 @@ if (navigator.vibrate) {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const thumb = hideBtn.closest('a.thumb');
|
const thumb = hideBtn.closest('a.thumb');
|
||||||
if (thumb) {
|
if (thumb) {
|
||||||
|
// Stop any active hover video preview immediately
|
||||||
|
if (typeof window.clearHoverPreview === 'function') {
|
||||||
|
window.clearHoverPreview();
|
||||||
|
}
|
||||||
|
|
||||||
thumb.classList.remove('revealed');
|
thumb.classList.remove('revealed');
|
||||||
hideBtn.remove();
|
hideBtn.remove();
|
||||||
|
|
||||||
@@ -8822,6 +8846,11 @@ if (navigator.vibrate) {
|
|||||||
btn.title = 'Hide thumbnail again';
|
btn.title = 'Hide thumbnail again';
|
||||||
p.appendChild(btn);
|
p.appendChild(btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Automatically start the hover video preview immediately on reveal since mouse is already over the item
|
||||||
|
if (typeof window.startHoverPreview === 'function') {
|
||||||
|
window.startHoverPreview(thumb, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|||||||
@@ -115,6 +115,16 @@ export default router => {
|
|||||||
await db`INSERT INTO tags_assign ${db({ tag_id: nextTagId, item_id: postid, user_id: +req.session.id })}`;
|
await db`INSERT INTO tags_assign ${db({ tag_id: nextTagId, item_id: postid, user_id: +req.session.id })}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Automatically generate blurred thumbnail if cycling TO NSFW or NSFL
|
||||||
|
if (nextTagId === 2 || nextTagId === nsflId) {
|
||||||
|
const blurPath = path.join(cfg.paths.t, `${postid}_blur.webp`);
|
||||||
|
try {
|
||||||
|
await fs.promises.access(blurPath);
|
||||||
|
} catch {
|
||||||
|
await queue.genBlurredThumbnail(postid, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const labels = { 1: { label: 'SFW', cls: 'sfw' }, 2: { label: 'NSFW', cls: 'nsfw' }, [nsflId]: { label: 'NSFL', cls: 'nsfl' } };
|
const labels = { 1: { label: 'SFW', cls: 'sfw' }, 2: { label: 'NSFW', cls: 'nsfw' }, [nsflId]: { label: 'NSFL', cls: 'nsfl' } };
|
||||||
const { label, cls } = labels[nextTagId];
|
const { label, cls } = labels[nextTagId];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user