D1, terza parte: Dashboard come pagina iniziale ovunque, miniature anche del Giro

Richiesta di Alberto (#59, parte b): la Dashboard al posto di Attività, prima voce e
pagina iniziale, compatta, con l'anteprima del browser sempre visibile e le miniature di
ciò che è arrivato. La prima parte (d6c0ef8) aveva già pagina, rotte e anteprima; qui si
chiude ciò che mancava.

- La finestra di Febe per Windows apre /dashboard?gettone=… (non più /): tolto il
  gettone l'indirizzo resta /dashboard.
- La voce Dashboard ha un'icona sua, layout-dashboard, disegnata in casa.
- Cronologia: anche le righe del Giro dei seguiti, che non hanno un account, mostrano le
  miniature di ciò che è arrivato di tutti gli account; mai gli elementi importati. Indice
  ix_entry_discovered nella migrazione 0002 (non ancora unita), così la domanda legge
  solo le righe dei minuti della ricetta anche con 200.000 elementi.
- Anteprima ingrandita: le frecce funzionano anche con il fuoco sui pulsanti del piede,
  «Apri l'account» segue l'elemento mostrato, chiudendo non si disegna più nulla.
- Al telefono il cruscotto è più basso (anteprima 196 px, miniature 40 px).
- Guida: «Attività e arresti» diventa «Dashboard e arresti», collegamenti e testi delle
  altre pagine aggiornati; differenze dai mockup in docs/schermate/differenze.md; quattro
  righe in docs/decisioni.md.
- Prove: DashboardApiTests (riga del Giro, importati esclusi, domande sbagliate),
  DesktopCompositionTests (/dashboard), GuideTests; DashboardInterfaceTests con Chromium
  (miniature, anteprima, frecce, Esc, una colonna sotto i 1000 px), solo nella CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-25 16:00:02 +01:00
1 parent 0547c747c5
commit 34fe5e9073
31 files changed
+265 -78

No files matched your search

+1 -1
View File
@@ -531,7 +531,7 @@ public sealed class EngineMonitor : IEngineMonitor
r.Detail,
r.Badge,
false,
r.NewEntries > 0 ? r.AccountId : null,
r.NewEntries > 0 ? r.AccountId : null, // none for the Giro dei seguiti: what arrived of every account
r.NewEntries > 0 ? r.StartedAt : null,
r.NewEntries)));
return views;
+2 -1
View File
@@ -139,7 +139,8 @@ public sealed record QueueItem(long TaskId, EngineTaskKind Kind, long? AccountId
/// <summary>A line of the history of the Dashboard («Appena fatto»).</summary>
/// <param name="AccountId">Account of the recipe, when it has one and saved something: with <see cref="From"/> and
/// <see cref="At"/> it tells the page which entries arrived, for their thumbnails (spec §7.9, tappa D1).</param>
/// <param name="From">When the recipe started.</param>
/// <param name="From">When the recipe started, when it saved something; with no account (the Giro dei seguiti) the
/// thumbnails are what arrived of every account in that time.</param>
/// <param name="NewEntries">Entries saved by the recipe.</param>
public sealed record RecentActionView(
DateTimeOffset At,
+4 -3
View File
@@ -67,10 +67,11 @@ public interface IEntryStore
Task<IReadOnlyList<Entry>> ListByAccountAsync(long accountId, EntryListOptions? options = null, CancellationToken ct = default);
/// <summary>
/// What a recipe saved (spec §7.9, thumbnails of the history of the Dashboard): the entries of the account discovered
/// in [from, to], newest first, at most <paramref name="limit"/>, with how many there are in all.
/// What a recipe saved (spec §7.9, thumbnails of the history of the Dashboard): the entries Febe downloaded (never
/// the imported ones) discovered in [from, to], of the account or, with null, of every account (the Giro dei
/// seguiti), newest first, at most <paramref name="limit"/>, with how many there are in all.
/// </summary>
Task<ArrivedEntries> ListDiscoveredAsync(long accountId, DateTimeOffset from, DateTimeOffset to, int limit, CancellationToken ct = default);
Task<ArrivedEntries> ListDiscoveredAsync(long? accountId, DateTimeOffset from, DateTimeOffset to, int limit, CancellationToken ct = default);
/// <summary>Entries of (account, kind) discovered in [from, to): per-account daily backfill limit.</summary>
Task<int> CountDiscoveredAsync(long accountId, EntryKind kind, DateTimeOffset from, DateTimeOffset to, CancellationToken ct = default);
@@ -1,6 +1,6 @@
-- Febe, schema version 2: «Cosa scaricare prima» (tappa D1, issue #59; spec §7.2, §4.4, §8.3).
-- Run by the migration runner inside a transaction; PRAGMA user_version is set by the runner.
-- Only columns are added: no behaviour changes for the data already stored.
-- Only columns and an index are added: no behaviour changes for the data already stored.
-- The order of «Cosa scaricare prima» of the account: the Italian names of the five kinds, comma separated
-- («storie,evidenza,post,reel,taggati»). NULL: «Come le impostazioni generali» (setting scaricamento.ordine).
@@ -9,3 +9,7 @@ ALTER TABLE account ADD COLUMN download_order TEXT;
-- A post that Febe knows to be a reel (found in the Reel tab, or marked so in the response): it counts as a reel in
-- the queue of the files. 0 for every post stored before, which Febe cannot tell apart without asking the site again.
ALTER TABLE entry ADD COLUMN is_reel INTEGER NOT NULL DEFAULT 0 CHECK (is_reel IN (0, 1));
-- What a recipe saved, for the thumbnails of the history of the Dashboard (spec §7.9): the entries discovered in the
-- few minutes of the recipe, of one account or of all (the Giro dei seguiti), read by range whatever the library's size.
CREATE INDEX ix_entry_discovered ON entry (discovered_at);
+14 -7
View File
@@ -201,15 +201,22 @@ internal sealed class EntryStore(FebeDatabase db) : IEntryStore
ct);
}
public Task<ArrivedEntries> ListDiscoveredAsync(long accountId, DateTimeOffset from, DateTimeOffset to, int limit, CancellationToken ct = default) =>
// The window of a recipe is a few minutes: the range on ix_entry_discovered (migration 0002) reads only those rows,
// whatever the size of the library or of the account.
private const string ArrivedWhere = """
discovered_at >= @f AND discovered_at <= @t AND (@a IS NULL OR account_id = @a) AND provenance = @p AND state <> 'Deleted'
""";
public Task<ArrivedEntries> ListDiscoveredAsync(long? accountId, DateTimeOffset from, DateTimeOffset to, int limit, CancellationToken ct = default) =>
db.ReadAsync(
c =>
{
var ids = new List<long>();
using (var r = c.Command("""
SELECT id FROM entry WHERE account_id = @a AND discovered_at >= @f AND discovered_at <= @t AND state <> 'Deleted'
using (var r = c.Command($"""
SELECT id FROM entry WHERE {ArrivedWhere}
ORDER BY discovered_at DESC, id DESC LIMIT @l
""").With("@a", accountId).With("@f", Sql.Time(from)).With("@t", Sql.Time(to)).With("@l", (long)Math.Clamp(limit, 1, 100)).ExecuteReader())
""").With("@a", accountId).With("@f", Sql.Time(from)).With("@t", Sql.Time(to)).With("@p", Sql.Enum(Provenance.Downloaded))
.With("@l", (long)Math.Clamp(limit, 1, 100)).ExecuteReader())
{
while (r.Read())
{
@@ -217,9 +224,9 @@ internal sealed class EntryStore(FebeDatabase db) : IEntryStore
}
}
var total = (int)c.Command("""
SELECT COUNT(*) FROM entry WHERE account_id = @a AND discovered_at >= @f AND discovered_at <= @t AND state <> 'Deleted'
""").With("@a", accountId).With("@f", Sql.Time(from)).With("@t", Sql.Time(to)).ScalarInt64();
var total = (int)c.Command($"""
SELECT COUNT(*) FROM entry WHERE {ArrivedWhere}
""").With("@a", accountId).With("@f", Sql.Time(from)).With("@t", Sql.Time(to)).With("@p", Sql.Enum(Provenance.Downloaded)).ScalarInt64();
return new ArrivedEntries(ids, total);
},
ct);
+9 -3
View File
@@ -94,7 +94,7 @@ public sealed class DesktopPlatform : IFebePlatform
};
}
/// <summary>The token of this start: the interface window opens <c>/?gettone=…</c> once. Never logged.</summary>
/// <summary>The token of this start: the interface window opens <c>/dashboard?gettone=…</c> once. Never logged.</summary>
public string AccessToken { get; } = Febe.Web.Security.AccessToken.Create();
public FebeWebOptions WebOptions { get; }
@@ -105,13 +105,19 @@ public sealed class DesktopPlatform : IFebePlatform
/// <summary>The hosting actually used (after a missing Edge fell back to the window).</summary>
public BrowserHosting? Hosting { get; private set; }
/// <summary>The address the interface window opens once: the token becomes a cookie and leaves the address.</summary>
/// <summary>
/// The address the interface window opens once: the Dashboard, Febe's start page (spec §7.9, §12, tappa D1). The
/// token becomes a cookie and leaves the address, which stays <c>/dashboard</c>.
/// </summary>
public Uri FirstAddress(Uri address)
{
ArgumentNullException.ThrowIfNull(address);
return new Uri(address, "/?" + Febe.Web.Security.AccessToken.QueryName + "=" + Uri.EscapeDataString(AccessToken));
return new Uri(address, StartPage + "?" + Febe.Web.Security.AccessToken.QueryName + "=" + Uri.EscapeDataString(AccessToken));
}
/// <summary>The page the interface window opens on.</summary>
public const string StartPage = "/dashboard";
public IReadOnlyList<ConfigurationProblem> CheckConfiguration(FebeAppOptions options, DataFolderCheck dataFolderCheck)
{
ArgumentNullException.ThrowIfNull(options);
+1 -1
View File
@@ -11,7 +11,7 @@ vero, in `tests/Febe.Tests.Windows` (`dotnet test tests/Febe.Tests.Windows`). Gu
|---|---|
| `Program.cs` | Riga di comando (`DesktopCommandLine`), cartella dei dati, istanza unica: un secondo avvio chiede al primo di mostrarsi ed esce |
| `DesktopApplication.cs` | Avvio: area di notifica, spostamento della cartella dei dati se chiesto, `FebeApp` con `DesktopPlatform`, finestra principale; «Esci», fine sessione di Windows |
| `MainWindow.cs` | La finestra con l'interfaccia (WebView2 di WPF, cartella `Dati\interfaccia`): apre `/?gettone=…` una volta, ogni altro indirizzo va al browser predefinito |
| `MainWindow.cs` | La finestra con l'interfaccia (WebView2 di WPF, cartella `Dati\interfaccia`): apre `/dashboard?gettone=…` una volta, ogni altro indirizzo va al browser predefinito |
| `Browser/WebView2Host.cs` | `IBrowserHost` di Windows: finestra «Browser di Febe», ambiente e controllo WebView2 in `Dati\browser`, CDP con `WebView2CdpSession`, fuori vista e in primo piano (S2), chi guida |
| `Browser/WebView2Browser.cs` | `IFebeBrowser` per la composizione: avvio con nuovi tentativi, ripartenza dopo un arresto del processo, «Scollega» |
| `Browser/BrowserWindow.cs` | La finestra «Browser di Febe»: pagina a misura fissa, barra con Indietro, Ricarica e indirizzo; chiudere = fuori vista |
+4 -3
View File
@@ -9,9 +9,10 @@ namespace Febe.Desktop;
/// <summary>
/// The main window (spec §12): a WebView2 showing the interface served in this process on 127.0.0.1. It opens
/// <c>/?gettone=…</c> once — the token of this start becomes an HttpOnly cookie and leaves the address — and never
/// leaves the interface: any other address opens in Alberto's default browser. Its WebView2 has a user data folder of
/// its own (<c>Dati\interfaccia</c>), separate from the browser of Instagram.
/// <c>/dashboard?gettone=…</c> once, on the start page (spec §7.9) — the token of this start becomes an HttpOnly
/// cookie and leaves the address — and never leaves the interface: any other address opens in Alberto's default
/// browser. Its WebView2 has a user data folder of its own (<c>Dati\interfaccia</c>), separate from the browser of
/// Instagram.
/// </summary>
internal sealed class MainWindow : Window
{
+11 -4
View File
@@ -47,16 +47,23 @@ public static class ActivityApi
endpoints.MapGet("/api/alerts", async (IFebeStorage storage, IClock clock, CancellationToken ct) =>
ApiHttp.Json(await AlertsAsync(storage, clock, ct).ConfigureAwait(false), FebeJsonContext.Default.AlertListDto));
// The thumbnails of a line of the history (spec §7.9): asked by the page only when the line is in view.
// The thumbnails of a line of the history (spec §7.9): asked by the page only when the line is in view. Without
// «account» (the Giro dei seguiti saves posts of many accounts), what arrived of every account in that time.
endpoints.MapGet("/api/activity/arrived", async (HttpContext context, IFebeStorage storage, IClock clock, CancellationToken ct) =>
{
var query = context.Request.Query;
if (!long.TryParse(query["account"].ToString(), NumberStyles.None, CultureInfo.InvariantCulture, out var account)
|| !TryTime(query["from"].ToString(), out var from)
var accountText = query["account"].ToString();
long? account = null;
if (accountText.Length > 0)
{
account = long.TryParse(accountText, NumberStyles.None, CultureInfo.InvariantCulture, out var id) ? id : throw new BadRequestException("Account non valido.");
}
if (!TryTime(query["from"].ToString(), out var from)
|| !TryTime(query["to"].ToString(), out var to)
|| to < from)
{
throw new BadRequestException("Indica account, inizio e fine.");
throw new BadRequestException("Indica inizio e fine.");
}
var limit = int.TryParse(query["limit"].ToString(), NumberStyles.None, CultureInfo.InvariantCulture, out var n) ? Math.Clamp(n, 1, ArrivedLimit) : ArrivedShown;
+5 -4
View File
@@ -84,7 +84,7 @@ Tutti con un ripiego registrato con `TryAdd`; la composizione registra i propri
| Veste | Opzioni | Effetto |
|---|---|---|
| Docker | `Edition = Docker`, `Access = Password`, `Password = FEBE_PASSWORD`, `AllowedHosts` = nomi con cui si raggiunge il server (anche `nome:*`), `FebeListen.Any(8480)` | Pagina `/accesso`, cookie `febe_sessione` HttpOnly SameSite=Strict, blocco dopo 5 errori per client e 20 in tutto in 15 minuti. Senza password risponde solo alla pagina dell'errore (indirizzi delle pagine, file dell'interfaccia, `GET /api/capabilities` e `/api/preferences`, `/salute`); tutto il resto, vista remota compresa, 503 |
| Windows | `Edition = Desktop`, `Access = Token`, `AccessToken = AccessToken.Create()`, `AllowedHosts = FebeWebOptions.LoopbackHosts(porta)`, `FebeListen.Loopback(0)` | La finestra apre `/?gettone=…` una volta: il gettone diventa un cookie HttpOnly Strict e sparisce dall'indirizzo. Anche l'intestazione `X-Febe-Gettone` vale |
| Windows | `Edition = Desktop`, `Access = Token`, `AccessToken = AccessToken.Create()`, `AllowedHosts = FebeWebOptions.LoopbackHosts(porta)`, `FebeListen.Loopback(0)` | La finestra apre `/dashboard?gettone=…` una volta: il gettone diventa un cookie HttpOnly Strict e sparisce dall'indirizzo. Anche l'intestazione `X-Febe-Gettone` vale |
| Prove e dimostrazione | `Access = None` | Solo su 127.0.0.1 |
Sempre attivi: nome Host in elenco (altrimenti 400), Origin uguale all'Host per ogni comando, per `/api/eventi` e
@@ -119,10 +119,11 @@ sono anche `day` (`aaaa-mm-gg`) e `clock` calcolati sul fuso di Febe.
| `GET /accesso`, `POST /api/accesso`, `POST /api/uscita` | Accesso con password |
| `GET /api/connection`, `POST /api/connection/begin` (`{ openLogin }`), `/finish`, `/cancel`, `/disconnect` | Collegamento a Instagram (`IConnectionService`, §6.4): stato `notConnected`, `connected`, `verificationRequired`, `browserUnavailable` |
| `GET /api/engine/incidents` | Incidenti degli ultimi 14 giorni (rallentamenti, verifiche, arresti), con un consiglio dopo 3 rallentamenti in 7 giorni |
| `POST /api/engine/recipes/{ricetta}/resume` | «Riattiva» una ricetta sospesa dopo tre problemi di fila (`IEngineControl.ResumeRecipeAsync`: metodo con un'implementazione predefinita che risponde «non era sospesa», così le altre implementazioni non cambiano). Attività mostra le ricette sospese da `snapshot.suspendedRecipes` |
| `GET /api/alerts` | Avvisi degli ultimi 14 giorni (§13.3, sezione «Avvisi» di Attività): righe della cronologia con i codici di `AlertCatalog.Codes`, compresi gli avvisi non arrivati |
| `POST /api/engine/recipes/{ricetta}/resume` | «Riattiva» una ricetta sospesa dopo tre problemi di fila (`IEngineControl.ResumeRecipeAsync`: metodo con un'implementazione predefinita che risponde «non era sospesa», così le altre implementazioni non cambiano). La Dashboard mostra le ricette sospese da `snapshot.suspendedRecipes` |
| `GET /api/alerts` | Avvisi degli ultimi 14 giorni (§13.3, sezione «Avvisi» della Dashboard): righe della cronologia con i codici di `AlertCatalog.Codes`, compresi gli avvisi non arrivati |
| `GET /api/engine/diagnostica` | «Esporta il rapporto di diagnostica» (issue #39, §7.9): file JSON `febe-diagnostica-aaaa-mm-gg.json` (giorno locale) in allegato, `no-store`, UTF-8 senza BOM, da `DiagnosticReport.Write` con le tracce di `IDiagnosticSource`. Nessun valore dei dati: solo conteggi, misure, orari, codici da elenchi chiusi e forme degli indirizzi. In testa `righeRovinate`, `erroriRegistratore`, `fileIlleggibili` e `sessioniSenzaFine` (`IDiagnosticSource.GatherAsync`). Risponde anche con un problema di configurazione (`ConfigurationGateMiddleware.AllowedApi`), con gli elenchi vuoti: il motore non è partito |
| `GET /api/browser/preview`, `GET /api/browser/preview/frame` | Anteprima del browser in Attività: indirizzo e immagine JPEG (`no-store`, 404 se non c'è) |
| `GET /api/browser/preview`, `GET /api/browser/preview/frame` | Anteprima del browser nella Dashboard: indirizzo e immagine JPEG (`no-store`, 404 se non c'è), al più un fotogramma nuovo al secondo |
| `GET /api/activity/arrived?account=&from=&to=&limit=` | Miniature di una riga della cronologia della Dashboard (§7.9): gli elementi scaricati da Febe (mai gli importati) scoperti fra `from` e `to`, dell'account o, senza `account`, di tutti (righe del Giro dei seguiti); tessere come la Libreria, al più `limit` (8, fino a 60), e `total` |
| `GET /api/duplicates/count`, `GET /api/duplicates?after=`, `POST /api/duplicates/{pairId}` (`{ decision, applyToAll }`) | Doppioni dopo uno scaricamento (§9.5): `keepLarger`, `keepExisting`, `keepBoth`; niente si decide da solo |
| `GET/PUT /api/settings/general`, `POST /api/settings/naming-preview`, `/pick-folder`, `/data-folder` | Cartelle (cambio della libreria solo desktop), schema dei nomi con anteprima, tema, avvio, area di notifica |
| `GET/PUT /api/settings/limits` | Profilo di prudenza, orari, sessioni, tetti, avvio graduale; le regole di §7.5 rispondono 400 con i messaggi italiani |
+9
View File
@@ -703,6 +703,15 @@ a.stato:hover{border-color:var(--bordo-forte)}
.cruscotto .anteprima{width:100%}
.storia-coda{grid-template-columns:minmax(0,1fr)}
}
@media (max-width:560px){
/* On the phone the preview stays at the top but lower, so that what is happening and the budgets fit too */
.cruscotto{padding:12px;gap:14px}
.cruscotto .anteprima .quadro{height:196px}
.miniatura,.miniature-altre{width:40px;height:40px}
.miniature{min-height:40px}
.anteprima-palco{height:min(52vh,460px)}
.anteprima-scena .btn.tondo{width:30px;height:30px}
}
.ora-pannello{display:flex;align-items:center;gap:24px;padding:18px 18px 18px 24px;min-height:142px}
.ora-testo{flex:1;min-width:0}
.ora-testo .riga{display:flex;align-items:center;gap:10px}
@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<rect x="3.5" y="3.5" width="7" height="9" rx="1.5"/>
<rect x="13.5" y="3.5" width="7" height="5" rx="1.5"/>
<rect x="13.5" y="11.5" width="7" height="9" rx="1.5"/>
<rect x="3.5" y="15.5" width="7" height="5" rx="1.5"/>
</svg>

After

Width:  |  Height:  |  Size: 397 B

+1 -1
View File
@@ -12,7 +12,7 @@ import { avatar, showError, toast, closeMenu } from './ui.js';
import { routes } from '../routes.js';
const NAV = [
{ key: 'dashboard', href: '/dashboard', icon: 'activity' },
{ key: 'dashboard', href: '/dashboard', icon: 'layout-dashboard' },
{ key: 'libreria', href: '/libreria', icon: 'layout-grid' },
{ key: 'account', href: '/account', icon: 'users' },
{ key: 'importa', href: '/importa', icon: 'folder-input' },
+26 -9
View File
@@ -374,7 +374,7 @@ function historyBox(page) {
page.onLeave(() => watcher && watcher.disconnect());
function keyOf(r) {
return `${r.accountId}|${r.from}|${r.at}`;
return `${r.accountId || ''}|${r.from}|${r.at}`;
}
async function loadThumbs(holder) {
@@ -388,8 +388,7 @@ function historyBox(page) {
const item = { loading: true, result: null, line: holder.line };
arrived.set(key, item);
try {
const query = new URLSearchParams({ account: String(holder.line.accountId), from: holder.line.from, to: holder.line.at, limit: String(THUMBS) });
item.result = await api(`/api/activity/arrived?${query}`, { signal: page.signal });
item.result = await api(`/api/activity/arrived?${arrivedQuery(holder.line, THUMBS)}`, { signal: page.signal });
} catch (error) {
if (error.name === 'AbortError') return;
item.result = { tiles: [], total: 0 };
@@ -423,7 +422,7 @@ function historyBox(page) {
}
const list = h('ul.elenco-attivita.storia-righe', items.map((r) => {
let holder = null;
if (r.accountId && r.from && r.newEntries > 0) {
if (r.from && r.newEntries > 0) {
holder = h('div.miniature', { dataset: { chiave: keyOf(r) }, 'aria-label': t('attivita.arrivate', { n: r.newEntries }), role: 'group' });
holder.line = r;
const known = arrived.get(keyOf(r));
@@ -438,13 +437,23 @@ function historyBox(page) {
}));
fill(element, h('h2', t('attivita.fatto')), h('div.pannello', list));
// Lines no longer shown are forgotten, so that a long day does not keep every answer.
const keys = new Set(items.filter((r) => r.accountId && r.from).map(keyOf));
const keys = new Set(items.filter((r) => r.from).map(keyOf));
for (const key of arrived.keys()) if (!keys.has(key)) arrived.delete(key);
}
return { element, draw };
}
/**
* The question for what a line of the history saved: the recipe's account and time; a line without an account (the
* Giro dei seguiti saves posts of many accounts) asks for what arrived of every account in that time.
*/
function arrivedQuery(line, limit) {
const query = new URLSearchParams({ from: line.from, to: line.at, limit: String(limit) });
if (line.accountId) query.set('account', String(line.accountId));
return query;
}
/** A small tile of the history: the thumbnail of §8.4 with the marks of the mosaic (video length, ring of stories). */
function thumb(tile, onOpen) {
const cover = tile.cover;
@@ -475,8 +484,7 @@ async function openPreview(page, line, firstTiles, total, startIndex) {
// More entries than the thumbnails: the arrows walk all of them (up to the server's limit).
if (total > firstTiles.length) {
try {
const query = new URLSearchParams({ account: String(line.accountId), from: line.from, to: line.at, limit: '60' });
const all = await api(`/api/activity/arrived?${query}`, { signal: page.signal });
const all = await api(`/api/activity/arrived?${arrivedQuery(line, 60)}`, { signal: page.signal });
if (all.tiles.length) tiles = all.tiles;
} catch (error) {
if (error.name === 'AbortError') return;
@@ -492,6 +500,8 @@ async function openPreview(page, line, firstTiles, total, startIndex) {
const prev = h('button.btn.nudo.tondo', { type: 'button', 'aria-label': t('vis.precedente'), onclick: () => step(-1) }, icon('chevron-left'));
const next = h('button.btn.nudo.tondo', { type: 'button', 'aria-label': t('vis.successivo'), onclick: () => step(1) }, icon('chevron-right'));
let closeDialog = null;
// «Apri l'account» follows the arrows: a line of the Giro dei seguiti holds entries of many accounts.
const accountLink = h('a.btn', { onclick: () => closeDialog() }, icon('user'), t('attivita.apriAccount'));
async function entryOf(i) {
const id = tiles[i].id;
@@ -502,6 +512,7 @@ async function openPreview(page, line, firstTiles, total, startIndex) {
async function show() {
const mine = ++token;
const tile = tiles[entryIndex];
accountLink.href = withCarried(`/account/${tile.accountId}/contenuti`);
const entry = await entryOf(entryIndex);
if (mine !== token) return;
const media = entry && entry.media.length ? entry.media[Math.min(fileIndex, entry.media.length - 1)] : null;
@@ -571,12 +582,18 @@ async function openPreview(page, line, firstTiles, total, startIndex) {
className: 'anteprima-cronologia',
build: (close) => {
closeDialog = close;
// The arrows walk the files wherever the focus is in the dialog (also on its buttons); Esc is the dialog's.
document.addEventListener('keydown', onKey);
return {
body: h('div.contenuto', { onkeydown: onKey }, h('div.anteprima-scena', prev, stage, next), caption),
onClose: () => {
token += 1; // an entry still loading draws nothing any more
document.removeEventListener('keydown', onKey);
},
body: h('div.contenuto', h('div.anteprima-scena', prev, stage, next), caption),
footer: h('footer',
position,
h('div.destra',
h('a.btn', { href: withCarried(`/account/${tiles[entryIndex].accountId}/contenuti`), onclick: () => closeDialog() }, icon('user'), t('attivita.apriAccount')),
accountLink,
h('button.btn.primo', {
type: 'button',
onclick: () => {