diff --git a/public/js/journal.js b/public/js/journal.js index 9986935..e875b07 100644 --- a/public/js/journal.js +++ b/public/js/journal.js @@ -2435,7 +2435,7 @@ async function saveEnhance() { let engineLabel = 'клиент'; if (enhanceAiResultPath && isDefaultEnhanceParams()) { const ctrl = new AbortController(); - const timer = setTimeout(() => ctrl.abort(), 15000); + const timer = setTimeout(() => ctrl.abort(), 45000); try { await applyAiResult(ctrl.signal); } finally { @@ -2446,7 +2446,7 @@ async function saveEnhance() { } else if (enhanceEngine !== 'client' && !enhanceAiResultPath) { try { const ctrl = new AbortController(); - const timer = setTimeout(() => ctrl.abort(), 8000); + const timer = setTimeout(() => ctrl.abort(), 45000); const res = await fetch(`${API}/api/entries/${entryId}/photo/enhance`, { method: 'PUT', headers: hdrJson(), @@ -2475,7 +2475,7 @@ async function saveEnhance() { const fd = new FormData(); fd.append('photo', blob, 'enhanced.jpg'); const ctrl = new AbortController(); - const timer = setTimeout(() => ctrl.abort(), 30000); + const timer = setTimeout(() => ctrl.abort(), Math.min(300000, Math.max(90000, blob.size * 40))); let res; try { res = await fetch(`${API}/api/entries/${entryId}/photo/enhance`, { method: 'PUT', headers: hdr(), body: fd, signal: ctrl.signal }); @@ -2492,7 +2492,11 @@ async function saveEnhance() { try { await refreshEntryCard(entryId); } catch (e) { console.error('refreshEntryCard failed:', e); } } catch (e) { console.error('saveEnhance failed:', e); - alert(e && e.message ? e.message : String(e)); + if (e && e.name === 'AbortError') { + alert('Сохранение прервано: сервер не ответил вовремя. Подождите немного и повторите — если ответ всё же дошёл до сервера, фото могло уже сохраниться, проверьте карточку.'); + } else { + alert(e && e.message ? e.message : String(e)); + } } finally { enhanceSaving = false; if (btn && document.contains(btn)) {