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); }
|
||||
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;
|
||||
if (itemId && window.NotificationSystemInstance && typeof window.NotificationSystemInstance.handleNewItem === 'function') {
|
||||
const grid = document.querySelector('.posts');
|
||||
@@ -197,8 +208,8 @@ window.escapeHtmlUpload = window.escapeHtmlUpload || ((unsafe) => {
|
||||
} else {
|
||||
// Failure: update the row to show the error, keep until user closes
|
||||
const row = _$('uut-active-list')?.querySelector(`[data-jid="${CSS.escape(jobId)}"]`);
|
||||
if (row) {
|
||||
const errMsg = notif.data?.msg || i18n().url_tracker_failed || 'Upload failed';
|
||||
if (row) {
|
||||
const stageEl = row.querySelector('.uut-stage');
|
||||
if (stageEl) {
|
||||
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'; }
|
||||
}
|
||||
_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)
|
||||
const injectNewItem = () => {
|
||||
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
|
||||
});
|
||||
// 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');
|
||||
}
|
||||
};
|
||||
|
||||
// Inject item into grid without redirecting
|
||||
const allPending = lastData?.pending && selectedFiles.every(i => i.type === 'url');
|
||||
if (!allPending) {
|
||||
injectNewItem();
|
||||
} else {
|
||||
window.location.href = '/';
|
||||
}
|
||||
} else {
|
||||
restoreBtn();
|
||||
|
||||
Reference in New Issue
Block a user