gfd
This commit is contained in:
@@ -169,6 +169,17 @@ window.escapeHtmlUpload = window.escapeHtmlUpload || ((unsafe) => {
|
|||||||
if (row) { row.classList.add('uut-job--fading'); setTimeout(() => row.remove(), 300); }
|
if (row) { row.classList.add('uut-job--fading'); setTimeout(() => row.remove(), 300); }
|
||||||
setTimeout(() => { _active.delete(jobId); _sync(); }, 350);
|
setTimeout(() => { _active.delete(jobId); _sync(); }, 350);
|
||||||
|
|
||||||
|
// Toast flash notification
|
||||||
|
if (typeof window.flashMessage === 'function') {
|
||||||
|
const msg = (window.f0ckI18n && window.f0ckI18n.notif_upload_success) || 'Your background upload is finished!';
|
||||||
|
window.flashMessage(msg, 3500, 'success');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh notification bell count and items
|
||||||
|
if (window.NotificationSystemInstance && typeof window.NotificationSystemInstance.pollDebounced === 'function') {
|
||||||
|
window.NotificationSystemInstance.pollDebounced();
|
||||||
|
}
|
||||||
|
|
||||||
const itemId = notif.item_id;
|
const itemId = notif.item_id;
|
||||||
if (itemId && window.NotificationSystemInstance && typeof window.NotificationSystemInstance.handleNewItem === 'function') {
|
if (itemId && window.NotificationSystemInstance && typeof window.NotificationSystemInstance.handleNewItem === 'function') {
|
||||||
const grid = document.querySelector('.posts');
|
const grid = document.querySelector('.posts');
|
||||||
@@ -197,8 +208,8 @@ window.escapeHtmlUpload = window.escapeHtmlUpload || ((unsafe) => {
|
|||||||
} else {
|
} else {
|
||||||
// Failure: update the row to show the error, keep until user closes
|
// Failure: update the row to show the error, keep until user closes
|
||||||
const row = _$('uut-active-list')?.querySelector(`[data-jid="${CSS.escape(jobId)}"]`);
|
const row = _$('uut-active-list')?.querySelector(`[data-jid="${CSS.escape(jobId)}"]`);
|
||||||
|
const errMsg = notif.data?.msg || i18n().url_tracker_failed || 'Upload failed';
|
||||||
if (row) {
|
if (row) {
|
||||||
const errMsg = notif.data?.msg || i18n().url_tracker_failed || 'Upload failed';
|
|
||||||
const stageEl = row.querySelector('.uut-stage');
|
const stageEl = row.querySelector('.uut-stage');
|
||||||
if (stageEl) {
|
if (stageEl) {
|
||||||
if (notif.item_id) {
|
if (notif.item_id) {
|
||||||
@@ -214,6 +225,13 @@ window.escapeHtmlUpload = window.escapeHtmlUpload || ((unsafe) => {
|
|||||||
if (barFill) { barFill.style.width = '100%'; barFill.style.background = '#ff5050'; barFill.style.backgroundImage = 'none'; barFill.style.animation = 'none'; }
|
if (barFill) { barFill.style.width = '100%'; barFill.style.background = '#ff5050'; barFill.style.backgroundImage = 'none'; barFill.style.animation = 'none'; }
|
||||||
}
|
}
|
||||||
_sync(); // update badge (count stays 0 for resolved jobs)
|
_sync(); // update badge (count stays 0 for resolved jobs)
|
||||||
|
|
||||||
|
if (typeof window.flashMessage === 'function') {
|
||||||
|
window.flashMessage('✕ ' + errMsg, 4500, 'error');
|
||||||
|
}
|
||||||
|
if (window.NotificationSystemInstance && typeof window.NotificationSystemInstance.pollDebounced === 'function') {
|
||||||
|
window.NotificationSystemInstance.pollDebounced();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2828,28 +2846,14 @@ window.initUploadForm = (selector) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper: inject the new item into the grid (deduplication is handled inside handleNewItem)
|
// URL background uploads do not redirect; standard file uploads redirect back to main page ('/')
|
||||||
const injectNewItem = () => {
|
const isBgUrlUpload = lastData?.pending && selectedFiles.every(i => i.type === 'url');
|
||||||
if (lastData && !lastData.manual_approval && !lastData.pending &&
|
if (isBgUrlUpload) {
|
||||||
lastData.itemid && lastData.dest && lastData.mime &&
|
if (typeof window.flashMessage === 'function') {
|
||||||
window.NotificationSystemInstance &&
|
window.flashMessage((window.f0ckI18n && window.f0ckI18n.url_upload_started) || 'Background upload started', 3000, 'info');
|
||||||
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
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
} else {
|
||||||
|
window.location.href = '/';
|
||||||
// Inject item into grid without redirecting
|
|
||||||
const allPending = lastData?.pending && selectedFiles.every(i => i.type === 'url');
|
|
||||||
if (!allPending) {
|
|
||||||
injectNewItem();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
restoreBtn();
|
restoreBtn();
|
||||||
|
|||||||
Reference in New Issue
Block a user