From d9b5b95f549882fafef64239a0850b4c68777b4e Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Wed, 15 Jul 2026 18:27:45 +0200 Subject: [PATCH] uga buga kaka --- public/s/js/upload.js | 18 ++++++++++++++++++ src/upload_handler.mjs | 9 ++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/public/s/js/upload.js b/public/s/js/upload.js index 64d105d..2d5f14b 100644 --- a/public/s/js/upload.js +++ b/public/s/js/upload.js @@ -2673,6 +2673,24 @@ window.initUploadForm = (selector) => { } } + // Immediately inject the new item into the main grid using the HTTP response data. + // This eliminates the SSE race condition where the async new_item event could + // arrive during or after page navigation and be silently lost. + if (lastData && !lastData.manual_approval && !lastData.pending && + lastData.itemid && lastData.dest && lastData.mime && + window.NotificationSystemInstance && + typeof window.NotificationSystemInstance.handleNewItem === 'function') { + window.NotificationSystemInstance.handleNewItem({ + id: lastData.itemid, + dest: lastData.dest, + mime: lastData.mime, + username: lastData.username || window.f0ckSession?.user || '', + display_name: lastData.display_name || window.f0ckSession?.display_name || null, + tag_id: lastData.tag_id ?? 0, + is_oc: !!lastData.is_oc + }); + } + // Skip redirect if every item was a background URL job const allPending = lastData?.pending && selectedFiles.every(i => i.type === 'url'); if (!allPending) { diff --git a/src/upload_handler.mjs b/src/upload_handler.mjs index f73aeb4..3f3b385 100644 --- a/src/upload_handler.mjs +++ b/src/upload_handler.mjs @@ -775,7 +775,14 @@ export const handleUpload = async (req, res, self) => { manual_approval: manualApproval, redirect: !manualApproval ? `/${itemid}` : null, url: !manualApproval ? `${cfg.main.url.full}/${itemid}` : `${cfg.main.url.full}/`, - file_url: !manualApproval ? `${cfg.main.url.full}${imagesPath}/${filename}` : null + file_url: !manualApproval ? `${cfg.main.url.full}${imagesPath}/${filename}` : null, + // Fields for immediate client-side grid injection (avoids SSE race condition) + dest: filename, + mime: actualMime, + tag_id: effectiveRating ? (effectiveRating === 'sfw' ? 1 : (effectiveRating === 'nsfw' ? 2 : (cfg.nsfl_tag_id || 3))) : 0, + is_oc: !!is_oc, + display_name: req.session.display_name || null, + username: req.session.user }); } catch (err) {