gfsd
This commit is contained in:
+51
-16
@@ -2670,6 +2670,7 @@ window.initUploadForm = (selector) => {
|
||||
|
||||
let successCount = 0;
|
||||
let lastData = null;
|
||||
const uploadedResults = [];
|
||||
|
||||
for (let i = 0; i < selectedFiles.length; i++) {
|
||||
const item = selectedFiles[i];
|
||||
@@ -2765,6 +2766,7 @@ window.initUploadForm = (selector) => {
|
||||
if (res.success) {
|
||||
successCount++;
|
||||
lastData = res;
|
||||
uploadedResults.push(res);
|
||||
if (res.pending) {
|
||||
// Background URL download — show tracker widget entry
|
||||
if (window.urlUploadTracker) {
|
||||
@@ -2830,30 +2832,63 @@ window.initUploadForm = (selector) => {
|
||||
|
||||
if (successCount > 0) {
|
||||
if (dragModal) dragModal.classList.remove('show');
|
||||
const dropModal = document.getElementById('upload-drag-modal');
|
||||
if (dropModal) dropModal.classList.remove('show');
|
||||
form._f0ckUploader.reset();
|
||||
if (isShitpost) {
|
||||
if (lastData?.manual_approval && typeof window.flashMessage === 'function') {
|
||||
window.flashMessage(window.f0ckI18n?.upload_pending_approval_patient || 'Upload awaits approval', 3000, 'warning');
|
||||
}
|
||||
} else {
|
||||
if (lastData?.manual_approval) {
|
||||
if (typeof window.flashMessage === 'function') {
|
||||
window.flashMessage(window.f0ckI18n?.upload_pending_approval_patient || 'Upload awaits approval', 3000, 'warning');
|
||||
}
|
||||
} else if (!dragModal && statusDiv) {
|
||||
statusDiv.innerHTML = '✓ ' + (lastData?.msg || 'Upload successful');
|
||||
statusDiv.className = 'upload-status success';
|
||||
}
|
||||
}
|
||||
|
||||
// URL background uploads do not redirect; standard file uploads redirect back to main page ('/')
|
||||
const isBgUrlUpload = lastData?.pending && selectedFiles.every(i => i.type === 'url');
|
||||
if (isBgUrlUpload) {
|
||||
if (typeof window.flashMessage === 'function') {
|
||||
window.flashMessage((window.f0ckI18n && window.f0ckI18n.url_upload_started) || 'Background upload started', 3000, 'info');
|
||||
}
|
||||
} else {
|
||||
window.location.href = '/';
|
||||
if (lastData?.manual_approval) {
|
||||
if (typeof window.flashMessage === 'function') {
|
||||
window.flashMessage(window.f0ckI18n?.upload_pending_approval_patient || 'Upload awaits approval', 3000, 'warning');
|
||||
}
|
||||
} else {
|
||||
const successMsg = successCount > 1
|
||||
? `${successCount} items uploaded successfully!`
|
||||
: (lastData?.msg || 'Upload successful');
|
||||
if (typeof window.flashMessage === 'function') {
|
||||
window.flashMessage(successMsg, 3000, 'success');
|
||||
} else if (!dragModal && statusDiv) {
|
||||
statusDiv.innerHTML = '✓ ' + successMsg;
|
||||
statusDiv.className = 'upload-status success';
|
||||
}
|
||||
}
|
||||
|
||||
// Seamless live injection without hard reload
|
||||
if (window.location.pathname === '/upload') {
|
||||
if (typeof window.loadPageAjax === 'function') {
|
||||
window.loadPageAjax('/', true, { bypassCache: true });
|
||||
} else {
|
||||
window.location.href = '/';
|
||||
}
|
||||
} else {
|
||||
// Prepend items to live grid seamlessly
|
||||
if (window.NotificationSystemInstance && typeof window.NotificationSystemInstance.handleNewItem === 'function') {
|
||||
for (const up of uploadedResults) {
|
||||
if (!up.manual_approval && !up.pending && up.itemid) {
|
||||
window.NotificationSystemInstance.handleNewItem({
|
||||
id: up.itemid,
|
||||
dest: up.dest,
|
||||
mime: up.mime,
|
||||
username: up.username || window.f0ckSession?.user || '',
|
||||
display_name: up.display_name || window.f0ckSession?.display_name || null,
|
||||
tag_id: up.tag_id ?? 0,
|
||||
is_oc: !!up.is_oc,
|
||||
slug: up.slug,
|
||||
visibility: up.visibility || 0
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// Refresh grid & pagination seamlessly in background without reload
|
||||
if (typeof window.loadPageAjax === 'function') {
|
||||
window.loadPageAjax(window.location.pathname + window.location.search, true, { bypassCache: true, skipPush: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
restoreBtn();
|
||||
|
||||
Reference in New Issue
Block a user