master #15
@@ -8588,14 +8588,61 @@ class NotificationSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleNewItem(data) {
|
handleNewItem(data) {
|
||||||
|
// Invalidate client-side caches so next/prev navigation knows about the new item
|
||||||
|
if (typeof itemCacheMap !== 'undefined') itemCacheMap.clear();
|
||||||
|
if (typeof gridCacheMap !== 'undefined') gridCacheMap.clear();
|
||||||
|
|
||||||
|
const isFilteredView = window.location.pathname.includes('/tag/') ||
|
||||||
|
window.location.pathname.includes('/h/') ||
|
||||||
|
window.location.pathname.includes('/user/');
|
||||||
|
|
||||||
|
// UPDATE ITEM VIEW NAVIGATION DYNAMICALLY
|
||||||
|
const prevBtn = document.getElementById('prev');
|
||||||
|
const nextBtn = document.getElementById('next');
|
||||||
|
const isItemView = !!prevBtn || !!nextBtn;
|
||||||
|
|
||||||
|
// #prev points to newer items (pagination.next). If it's disabled, we are at the newest item.
|
||||||
|
if (isItemView && !isFilteredView && prevBtn && (prevBtn.getAttribute('href') === '#' || prevBtn.getAttribute('href') === '')) {
|
||||||
|
let filtered = false;
|
||||||
|
if (typeof window.activeMode !== 'undefined' && window.activeMode !== 3) {
|
||||||
|
const nsflId = window.f0ckSession?.nsfl_tag_id || 3;
|
||||||
|
if (window.activeMode === 0 && data.tag_id !== 1) filtered = true;
|
||||||
|
else if (window.activeMode === 1 && data.tag_id !== 2) filtered = true;
|
||||||
|
else if (window.activeMode === 4 && data.tag_id != nsflId) filtered = true;
|
||||||
|
else if (window.activeMode === 2) filtered = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!filtered) {
|
||||||
|
let nextUrl = `/${data.id}`;
|
||||||
|
const path = window.location.pathname;
|
||||||
|
const contextMatch = path.match(/^(.*\/)\d+\/?$/);
|
||||||
|
if (contextMatch && contextMatch[1] !== '/') {
|
||||||
|
nextUrl = `${contextMatch[1]}${data.id}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update main #prev arrow
|
||||||
|
prevBtn.setAttribute('href', nextUrl);
|
||||||
|
prevBtn.style.color = ''; // Remove #ccc
|
||||||
|
|
||||||
|
// Update .nav-prev text links and icons
|
||||||
|
document.querySelectorAll('.nav-prev').forEach(btn => {
|
||||||
|
btn.setAttribute('href', nextUrl);
|
||||||
|
btn.style.visibility = 'visible';
|
||||||
|
});
|
||||||
|
|
||||||
|
if (typeof prefetchNextPrevItems === 'function') {
|
||||||
|
if (typeof requestIdleCallback === 'function') requestIdleCallback(() => prefetchNextPrevItems());
|
||||||
|
else setTimeout(prefetchNextPrevItems, 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Only prepend to the grid on the main/index page
|
// Only prepend to the grid on the main/index page
|
||||||
const grid = document.querySelector('.posts');
|
const grid = document.querySelector('.posts');
|
||||||
if (!grid) return;
|
if (!grid) return;
|
||||||
|
|
||||||
// Don't live-update on filtered views (tags, halls, users)
|
// Don't live-update on filtered views (tags, halls, users)
|
||||||
if (window.location.pathname.includes('/tag/') ||
|
if (isFilteredView) return;
|
||||||
window.location.pathname.includes('/h/') ||
|
|
||||||
window.location.pathname.includes('/user/')) return;
|
|
||||||
|
|
||||||
// Respect mode filter — but if this is the current user's own upload,
|
// Respect mode filter — but if this is the current user's own upload,
|
||||||
// show a blurred "ghost" thumbnail so they know it was uploaded successfully
|
// show a blurred "ghost" thumbnail so they know it was uploaded successfully
|
||||||
|
|||||||
@@ -229,8 +229,6 @@ export default router => {
|
|||||||
domain = parts.slice(-2).join('.');
|
domain = parts.slice(-2).join('.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (domain) tags.push(domain);
|
|
||||||
|
|
||||||
// YouTube-specific tag
|
// YouTube-specific tag
|
||||||
if (/(?:youtube\.com|youtu\.be)$/i.test(domain) || /(?:youtube\.com|youtu\.be)$/i.test(host)) {
|
if (/(?:youtube\.com|youtu\.be)$/i.test(domain) || /(?:youtube\.com|youtu\.be)$/i.test(host)) {
|
||||||
tags.push('youtube');
|
tags.push('youtube');
|
||||||
|
|||||||
Reference in New Issue
Block a user