power un dat
This commit is contained in:
@@ -2673,31 +2673,39 @@ window.initUploadForm = (selector) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Immediately inject the new item into the main grid using the HTTP response data.
|
// Helper: inject the new item into the grid (deduplication is handled inside handleNewItem)
|
||||||
// This eliminates the SSE race condition where the async new_item event could
|
const injectNewItem = () => {
|
||||||
// arrive during or after page navigation and be silently lost.
|
if (lastData && !lastData.manual_approval && !lastData.pending &&
|
||||||
if (lastData && !lastData.manual_approval && !lastData.pending &&
|
lastData.itemid && lastData.dest && lastData.mime &&
|
||||||
lastData.itemid && lastData.dest && lastData.mime &&
|
window.NotificationSystemInstance &&
|
||||||
window.NotificationSystemInstance &&
|
typeof window.NotificationSystemInstance.handleNewItem === 'function') {
|
||||||
typeof window.NotificationSystemInstance.handleNewItem === 'function') {
|
window.NotificationSystemInstance.handleNewItem({
|
||||||
window.NotificationSystemInstance.handleNewItem({
|
id: lastData.itemid,
|
||||||
id: lastData.itemid,
|
dest: lastData.dest,
|
||||||
dest: lastData.dest,
|
mime: lastData.mime,
|
||||||
mime: lastData.mime,
|
username: lastData.username || window.f0ckSession?.user || '',
|
||||||
username: lastData.username || window.f0ckSession?.user || '',
|
display_name: lastData.display_name || window.f0ckSession?.display_name || null,
|
||||||
display_name: lastData.display_name || window.f0ckSession?.display_name || null,
|
tag_id: lastData.tag_id ?? 0,
|
||||||
tag_id: lastData.tag_id ?? 0,
|
is_oc: !!lastData.is_oc
|
||||||
is_oc: !!lastData.is_oc
|
});
|
||||||
});
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Skip redirect if every item was a background URL job
|
// Skip redirect if every item was a background URL job
|
||||||
const allPending = lastData?.pending && selectedFiles.every(i => i.type === 'url');
|
const allPending = lastData?.pending && selectedFiles.every(i => i.type === 'url');
|
||||||
if (!allPending) {
|
if (!allPending) {
|
||||||
setTimeout(() => {
|
// Inject now if the grid is already in the DOM (upload modal open on main page)
|
||||||
if (typeof window.loadPageAjax === 'function') window.loadPageAjax('/');
|
injectNewItem();
|
||||||
else window.location.href = '/';
|
// Navigate to main page, then inject again after the grid has loaded.
|
||||||
}, dragModal ? 0 : 1000);
|
// Awaiting loadPageAjax ensures the .posts grid DOM is present before the
|
||||||
|
// handleNewItem call — this covers the item-page drag-and-upload scenario
|
||||||
|
// where no grid exists until after navigation completes.
|
||||||
|
if (typeof window.loadPageAjax === 'function') {
|
||||||
|
await window.loadPageAjax('/');
|
||||||
|
injectNewItem();
|
||||||
|
} else {
|
||||||
|
window.location.href = '/';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
restoreBtn();
|
restoreBtn();
|
||||||
|
|||||||
Reference in New Issue
Block a user