diff --git a/public/s/js/f0ckm.js b/public/s/js/f0ckm.js index 755eab7..817938b 100644 --- a/public/s/js/f0ckm.js +++ b/public/s/js/f0ckm.js @@ -8588,14 +8588,61 @@ class NotificationSystem { } 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 const grid = document.querySelector('.posts'); if (!grid) return; // Don't live-update on filtered views (tags, halls, users) - if (window.location.pathname.includes('/tag/') || - window.location.pathname.includes('/h/') || - window.location.pathname.includes('/user/')) return; + if (isFilteredView) return; // 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 diff --git a/src/inc/routes/apiv2/upload.mjs b/src/inc/routes/apiv2/upload.mjs index ab89c8e..cd61d46 100644 --- a/src/inc/routes/apiv2/upload.mjs +++ b/src/inc/routes/apiv2/upload.mjs @@ -229,8 +229,6 @@ export default router => { domain = parts.slice(-2).join('.'); } - if (domain) tags.push(domain); - // YouTube-specific tag if (/(?:youtube\.com|youtu\.be)$/i.test(domain) || /(?:youtube\.com|youtu\.be)$/i.test(host)) { tags.push('youtube');