E4: copie del fotogramma con il loro nome, eventi che non si perdono, visualizzatore che si chiude

«Copia di nuovo» di un _fotogramma lo rifaceva come _t…, e un lavoro in attesa prendeva un istante del file vecchio.
Un'analisi copriva l'evento di una copia finita; il visualizzatore restava sopra la pagina nuova e poteva mostrare un
esito superato; la scheda Esportazione perdeva il fuoco a ogni rilettura.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-01 18:57:58 +01:00
1 parent 6dcaf30db6
commit 2c0cfcccf2
17 files changed
+301 -35

No files matched your search

+1
View File
@@ -356,6 +356,7 @@ async function render() {
if (current) {
current.frame.destroy();
current = null;
document.dispatchEvent(new Event('febe:pagina')); // what lies over the page (the viewer) goes with it
}
for (const [key, link] of Object.entries(navLinks)) {
const here = route && route.nav === key;
+3 -1
View File
@@ -325,7 +325,9 @@ export default {
}, 150);
search.addEventListener('input', onSearch);
const onChange = later(reload, 600);
page.onLibrary(onChange);
page.onLibrary((change) => {
if (change.reason !== 'fermi') onChange(); // an analysis («Cerca i video fermi») changes nothing here
});
page.onLeave(() => {
onSearch.cancel();
onChange.cancel();
@@ -37,6 +37,7 @@ export async function mountExport(page) {
let runs = [];
let progress = null;
let stillJob = null;
let drawnStills = '';
let wasRunning = null;
let timer = 0;
let ticks = 0;
@@ -233,6 +234,10 @@ export async function mountExport(page) {
function drawStills() {
const job = stillJob;
stills.hidden = !job || !(job.running || job.total);
// A job that is over stays as it is drawn: read again every few seconds, its link keeps the focus of the keyboard.
const drawn = stills.hidden || job.running ? '' : JSON.stringify(job);
if (drawn && drawn === drawnStills) return;
drawnStills = drawn;
if (stills.hidden) {
stills.replaceChildren();
return;
+3 -1
View File
@@ -90,7 +90,9 @@ export default {
}
await loadSide();
if (page.signal.aborted) return;
page.onLibrary(() => loadSide());
page.onLibrary((change) => {
if (change.reason !== 'fermi') loadSide(); // an analysis («Cerca i video fermi») changes nothing here
});
const timer = setInterval(() => {
if (latest && document.visibilityState === 'visible') loadSide();
}, 60000);
@@ -115,7 +115,9 @@ export function stillVideosDialog(selection) {
draw();
try {
const job = await api('/api/still-videos/start', { method: 'POST', body: selection });
if (job.running) toast(t('esportazione.fermi.avviata', { n: plan.toAnalyse }), '', { label: t('esportazione.copia.vediAvanzamento'), href: PROGRESS_PAGE });
const follow = { label: t('esportazione.copia.vediAvanzamento'), href: PROGRESS_PAGE };
if (job.added) toast(t('esportazione.fermi.avviata', { n: job.added }), '', follow);
else if (job.running) toast(t('esportazione.fermi.giaInCoda'), '', follow); // all of them were queued already
else toast(t('esportazione.fermi.niente'));
noteJob(job);
close(job);
+23 -8
View File
@@ -37,6 +37,8 @@ export function openViewer({ tile, source, origin, onDeleted }) {
const copying = new Set();
// The videos being analysed («È un video fermo?», tappa E4): the answer may come once another file is on screen.
const analysing = new Set();
// Only the last reading of the analyses counts.
let analysesToken = 0;
let closed = false;
const where = h('span.dove');
@@ -88,8 +90,19 @@ export function openViewer({ tile, source, origin, onDeleted }) {
}
function close() {
dismiss();
if (entry && source && source.reveal) {
const key = keyAt(0);
if (key != null) source.reveal(key);
}
if (opener && document.contains(opener)) opener.focus();
}
/** Takes the viewer away, also when the page under it changes (a link of a toast, Back): nothing under it is left. */
function dismiss() {
closed = true;
document.removeEventListener('keydown', onKey, true);
document.removeEventListener('febe:pagina', dismiss);
stopWatching();
onCopiesChanged.cancel();
onAnalysed.cancel();
@@ -97,11 +110,6 @@ export function openViewer({ tile, source, origin, onDeleted }) {
if (document.fullscreenElement) document.exitFullscreen().catch(() => {});
box.remove();
document.body.style.overflow = '';
if (entry && source && source.reveal) {
const key = keyAt(0);
if (key != null) source.reveal(key);
}
if (opener && document.contains(opener)) opener.focus();
}
function setZoom(on) {
@@ -403,7 +411,10 @@ export function openViewer({ tile, source, origin, onDeleted }) {
}
analysing.delete(media.id);
if (closed) return;
if (still) setStill(media.id, still);
if (still) {
analysesToken++;
setStill(media.id, still);
}
const current = entry.media[fileIndex];
if (!current || current.id !== media.id) return;
const lostFocus = document.activeElement === document.body;
@@ -431,13 +442,15 @@ export function openViewer({ tile, source, origin, onDeleted }) {
async function readAnalyses() {
if (!entry) return;
const id = entry.id;
const mine = ++analysesToken;
let fresh;
try {
fresh = await api(`/api/entries/${id}`);
} catch {
return;
}
if (closed || !entry || entry.id !== id) return;
// Asked again since, or answered by «È un video fermo?»: an older answer must not bring back what was before.
if (closed || !entry || entry.id !== id || mine !== analysesToken) return;
const stills = (media) => JSON.stringify(media.map((m) => [m.id, m.still || null]));
if (stills(fresh.media) === stills(entry.media)) return;
for (const m of fresh.media) setStill(m.id, m.still || null);
@@ -501,10 +514,12 @@ export function openViewer({ tile, source, origin, onDeleted }) {
const onAnalysed = later(readAnalyses, 400);
const stopWatching = onLibrary((change) => {
if (change.reason === 'export') onCopiesChanged();
if (change.reason === 'fermi' && (!entry || !change.accountId || change.accountId === entry.account.id)) onAnalysed();
// An outcome belongs to the file: the same video may be here under another account than the one analysed.
if (change.reason === 'fermi' && entry && entry.media.some((m) => m.kind === 'video')) onAnalysed();
});
document.addEventListener('keydown', onKey, true);
document.addEventListener('febe:pagina', dismiss);
document.body.append(box);
closeButton.focus();
load(tile.id, 0, files && tile.cover ? tile.cover.mediaId : null);