power un dat
This commit is contained in:
@@ -2673,9 +2673,8 @@ 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 &&
|
||||||
@@ -2690,14 +2689,23 @@ window.initUploadForm = (selector) => {
|
|||||||
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