D1, correzioni della revisione: conteggi della Libreria più rapidi, frecce che seguono le tessere, Dashboard nei testi

- /api/library/days in «Tutte le foto» faceva due volte il passaggio su tutta la tabella media
  a ogni aggiornamento del mosaico: il totale dei file è ora la somma dei giorni
  (CountLibraryFilesAsync tolto).
- I totali e i conteggi per giorno di «Foto» e «Video» su tutta la libreria non pagano più un
  EXISTS per post (1,3-1,6 s): elenco degli elementi con file di quel tipo su un indice di
  copertura, 86-141 ms su 200.000 elementi; nuove misure con limite 600 ms in LibraryScaleTests.
- La quota di chi aspetta non è un minimo per tipo: corretti commento e decisioni, prova con un
  arretrato più vecchio di un altro tipo.
- Visualizzatore in «Tutte le foto»: le frecce saltano i file che non sono tessere (foto sotto
  «Video» e simili) e l'intestazione non dà il numero di un altro file; la voce già scelta
  dell'interruttore non ridisegna il mosaico. Prova d'interfaccia nuova (solo CI).
- «Ricetta sospesa» dice di riattivarla dalla Dashboard, non da Attività; commenti aggiornati.
- Nomi accessibili distinti nella scheda account, variabile in inglese in download-order.js,
  icona activity tolta perché nessuna pagina la usa.
- Schermate 06, 11 e 14 rifatte con /dashboard e nuova 01-libreria-tutte-le-foto, confrontate
  con i mockup in docs/schermate/differenze.md (con quattro difetti visivi ancora da sistemare).
- LEGGIMI del web (mode, cursore, files, moduli riusabili) e guida della Libreria (la scelta del
  mosaico resta nel browser, a differenza del tema).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-25 17:27:33 +01:00
1 parent 30e159cbd4
commit 58ff4e48b3
44 files changed
+261 -118

No files matched your search

+2 -2
View File
@@ -94,7 +94,7 @@ public static class AlertEventCodes
/// </summary>
public static class AlertCatalog
{
/// <summary>Codes shown in the «Avvisi» list of Attività: the alerts and the failed deliveries.</summary>
/// <summary>Codes shown in the «Avvisi» list of the Dashboard: the alerts and the failed deliveries.</summary>
public static IReadOnlyList<string> Codes { get; } =
[
EngineEventCodes.ChallengeStop,
@@ -193,7 +193,7 @@ public static class AlertCatalog
/// <summary>
/// The engine's sentence without its first words when they repeat the title: «Instagram ha chiesto di rallentare
/// (segnale http-429). Ho chiuso…» becomes «Ho chiuso…» (the signal stays in the stops of Attività).
/// (segnale http-429). Ho chiuso…» becomes «Ho chiuso…» (the signal stays in the stops of the Dashboard).
/// </summary>
private static string WithoutTitle(string message, string title)
{
+1 -1
View File
@@ -43,7 +43,7 @@ public sealed record AlertServiceOptions
/// stops and resumes, backfills completed, unknown formats, suspended recipes) and checks the free space of the
/// library and the Data folder; each alert goes to the channels switched on in Impostazioni ▸ Notifiche (Windows
/// notification on the desktop, Telegram when token and chat are set). The red strip of the interface is not its
/// job: the engine snapshot always shows a stop, and every alert is a line of the «Avvisi» list in Attività.
/// job: the engine snapshot always shows a stop, and every alert is a line of the «Avvisi» list of the Dashboard.
/// <list type="bullet">
/// <item>Same kind and key within <see cref="AlertCatalog.MinimumInterval"/>: not sent again (the times are kept in the
/// settings, so a restart does not send it again either).</item>
@@ -75,11 +75,12 @@ public sealed record DownloadOptions
public int BatchSize { get; init; } = 200;
/// <summary>
/// «Cosa scaricare prima» never starves the later kinds (spec §6.5, §7.2): one file in this many is the one that has
/// waited longest, whatever its kind; the others follow the order. Every file in the queue becomes the longest
/// waiting sooner or later (new files are always younger), so every kind gets at least this share of the downloads
/// while it has files waiting, even when the daily data budget ends each day before the queue does. 0 or 1: the
/// order alone.
/// «Cosa scaricare prima» never makes a file wait for ever (spec §6.5, §7.2): one file in this many is the one that
/// has waited longest, whatever its kind; the others follow the order. Every file in the queue becomes the longest
/// waiting sooner or later (new files are always younger), so every file is downloaded in the end, even when the
/// daily data budget ends each day before the queue does. It is not a share per kind: the place goes to the oldest
/// file of the whole queue, so a kind found after an older backlog of another kind waits until that backlog is done
/// (taggati found after thousands of older posts come after them). 0 or 1: the order alone.
/// </summary>
public int LongestWaitingShare { get; init; } = 8;
@@ -437,7 +437,7 @@ public sealed partial class RecipeRunner
run.Finished = true;
if (walk.IsGrid)
{
// «Storico completato» in Attività, and the new state of the account, are the engine's: one line per
// «Storico completato» in the Dashboard, and the new state of the account, are the engine's: one line per
// history, with its numbers (SessionComposer, from RecipeOutcome.BackfillFinished).
await Env.Storage.Accounts.SetBackfillAsync(account.Id, null, Env.Clock.Now, run.Ct).ConfigureAwait(false);
await settings.SetAsync(walk.MarkKey(account.Id), null, run.Ct).ConfigureAwait(false);
+1 -1
View File
@@ -66,7 +66,7 @@ public sealed class EngineHost : IAsyncDisposable
public EngineServices Services => _s;
/// <summary>What the interface shows of the engine (Attività, sidebar, account settings panel).</summary>
/// <summary>What the interface shows of the engine (Dashboard, sidebar, account settings panel).</summary>
public IEngineMonitor Monitor { get; }
/// <summary>Recipes suspended after repeated unrecognized formats, with when.</summary>
+2 -2
View File
@@ -1227,7 +1227,7 @@ internal sealed class SessionComposer
/// <summary>
/// The history of the account is complete: «Aggiornato» (or «In pausa» with «Tieni aggiornato» off) and the one
/// «storico completato» line of Attività, which is also the alert (spec §13.3). The recipes write no line of their
/// «storico completato» line of the Dashboard, which is also the alert (spec §13.3). The recipes write no line of their
/// own for it. Called once per history: after it the account is no longer «Storico in corso». Returns the account
/// as it is now.
/// </summary>
@@ -1292,7 +1292,7 @@ internal sealed class SessionComposer
await _s.Events.WriteAsync(
EventSeverity.Error,
EngineEventCodes.RecipeSuspended,
$"«{ItalianText.Capitalize(RecipeName(kind))}» è sospeso dopo {ItalianText.Number(threshold)} problemi di fila: Instagram potrebbe essere cambiato. Serve un campione nuovo con la modalità sonda; poi si riattiva da Attività.",
$"«{ItalianText.Capitalize(RecipeName(kind))}» è sospeso dopo {ItalianText.Number(threshold)} problemi di fila: Instagram potrebbe essere cambiato. Serve un campione nuovo con la modalità sonda; poi si riattiva dalla Dashboard («Riattiva»).",
account?.Id,
ct: ct).ConfigureAwait(false);
}
+1 -1
View File
@@ -17,7 +17,7 @@ public interface ITaskStore
/// <summary>Pending tasks due at <paramref name="now"/>: highest priority first, then earliest due, then oldest.</summary>
Task<IReadOnlyList<EngineTask>> PeekDueAsync(DateTimeOffset now, int limit, CancellationToken ct = default);
/// <summary>Pending tasks by due time (the queue shown in Attività, «verso le»).</summary>
/// <summary>Pending tasks by due time (the queue shown in the Dashboard, «verso le»).</summary>
Task<IReadOnlyList<EngineTask>> ListPendingAsync(int limit, CancellationToken ct = default);
/// <summary>Pending → Running, atomically. False if the task was not pending any more.</summary>
+3 -7
View File
@@ -81,15 +81,11 @@ public interface IEntryStore
Task<LibraryTotals> GetLibraryTotalsAsync(LibraryFilter filter, CancellationToken ct = default);
/// <summary>
/// Files of the entries of the filter that are in the library (downloaded or imported): the tiles of
/// «Tutte le foto». With «Foto» and «Video» only the files of that kind.
/// </summary>
Task<int> CountLibraryFilesAsync(LibraryFilter filter, CancellationToken ct = default);
/// <summary>
/// Entries (or, with <see cref="MosaicMode.Files"/>, files) per local calendar day in Alberto's zone, newest day
/// first. A day without files is left out in that mode.
/// first. A day without files is left out in that mode. In that mode the files are those in the library
/// (downloaded or imported), the tiles of «Tutte le foto», with «Foto» and «Video» only the files of that kind; their
/// total is the sum of the days (one pass over the files, not a second count).
/// </summary>
Task<IReadOnlyList<DayCount>> CountLibraryByDayAsync(LibraryFilter filter, TimeZoneInfo zone, MosaicMode mode = MosaicMode.Grouped, CancellationToken ct = default);
+19 -33
View File
@@ -323,7 +323,7 @@ internal sealed class EntryStore(FebeDatabase db) : IEntryStore
c =>
{
var command = c.Command(string.Empty);
var where = BuildWhere(c, command, filter);
var where = BuildWhere(c, command, filter, aggregate: true);
command.CommandText = $"SELECT COUNT(*), COUNT(DISTINCT e.account_id) FROM entry e WHERE {where}";
using var r = command.ExecuteReader();
r.Read();
@@ -332,34 +332,6 @@ internal sealed class EntryStore(FebeDatabase db) : IEntryStore
ct);
}
public Task<int> CountLibraryFilesAsync(LibraryFilter filter, CancellationToken ct = default)
{
ArgumentNullException.ThrowIfNull(filter);
return db.ReadAsync(
c =>
{
var command = c.Command(string.Empty);
var where = BuildWhere(c, command, EntriesOfFiles(filter));
var counts = FileCounts(c, filter);
if (counts is null)
{
command.CommandText = $"SELECT COALESCE(SUM({FilesOfEntry(filter)}), 0) FROM entry e WHERE {where}";
return (int)command.ScalarInt64();
}
command.CommandText = $"SELECT e.id FROM entry e WHERE {where}";
var total = 0;
using var r = command.ExecuteReader();
while (r.Read())
{
total += counts.GetValueOrDefault(r.GetInt64(0));
}
return total;
},
ct);
}
public Task<IReadOnlyList<DayCount>> CountLibraryByDayAsync(LibraryFilter filter, TimeZoneInfo zone, MosaicMode mode = MosaicMode.Grouped, CancellationToken ct = default)
{
ArgumentNullException.ThrowIfNull(filter);
@@ -371,7 +343,7 @@ internal sealed class EntryStore(FebeDatabase db) : IEntryStore
// in SQL, no sort, and the day bounds are computed once per day rather than once per entry.
var command = c.Command(string.Empty);
var files = mode == MosaicMode.Files;
var where = BuildWhere(c, command, files ? EntriesOfFiles(filter) : filter);
var where = BuildWhere(c, command, files ? EntriesOfFiles(filter) : filter, aggregate: true);
var counts = files ? FileCounts(c, filter) : null;
var perEntry = files && counts is null;
command.CommandText = !files
@@ -758,8 +730,22 @@ internal sealed class EntryStore(FebeDatabase db) : IEntryStore
}
/// <summary>The WHERE clause of a library filter on <c>entry e</c>; parameters are added to <paramref name="command"/>.</summary>
internal static string BuildWhere(SqliteConnection c, SqliteCommand command, LibraryFilter filter)
/// <param name="aggregate">
/// The clause is for a count over every entry of the filter (totals, day counts) rather than for a window. «Foto» and
/// «Video» then test the key of each post, on a covering index, against one list of the entries that have such
/// files, read once from ix_media_entry_files (under two tenths of a second over 200,000 entries), instead of an
/// EXISTS per post (over a second: each post needs its table row). A window keeps the EXISTS: it stops after a few
/// hundred posts in index order.
/// With a filter on accounts the posts are few and the EXISTS is the cheaper of the two.
/// </param>
internal static string BuildWhere(SqliteConnection c, SqliteCommand command, LibraryFilter filter, bool aggregate = false)
{
var byList = aggregate && filter.AccountIds is not { Count: > 0 };
// The unary + on kind and key keeps SQLite on a covering index of entry (kind, state and account in the index):
// looking up each entry of the list by key would read its table row, 0.85 s for «Foto» over 200,000 entries.
string FilesOfKind(string kind) => byList
? $"+e.kind = 'Post' AND +e.id IN (SELECT mk.entry_id FROM media mk WHERE mk.kind = '{kind}')"
: $"e.kind = 'Post' AND EXISTS (SELECT 1 FROM media mk WHERE mk.entry_id = e.id AND mk.kind = '{kind}')";
var parts = new List<string>();
var states = filter.States is { Count: > 0 } s ? s : EntryStateRules.Visible;
// The unary + keeps SQLite from using the state and kind indexes for these broad terms: the keyset scan of the
@@ -772,8 +758,8 @@ internal sealed class EntryStore(FebeDatabase db) : IEntryStore
// Like «Tutto», a broad term: on the kind index every post would need its table row for the state (most of
// the library); the publication index already holds kind and state.
LibraryKindFilter.Posts => "+e.kind = 'Post'",
LibraryKindFilter.Photos => "e.kind = 'Post' AND EXISTS (SELECT 1 FROM media mk WHERE mk.entry_id = e.id AND mk.kind = 'Photo')",
LibraryKindFilter.Videos => "e.kind = 'Post' AND EXISTS (SELECT 1 FROM media mk WHERE mk.entry_id = e.id AND mk.kind = 'Video')",
LibraryKindFilter.Photos => FilesOfKind("Photo"),
LibraryKindFilter.Videos => FilesOfKind("Video"),
LibraryKindFilter.Stories => "e.kind = 'Story'",
LibraryKindFilter.Highlights => "(e.kind = 'Highlight' OR EXISTS (SELECT 1 FROM highlight_entry he WHERE he.entry_id = e.id))",
LibraryKindFilter.Tagged => "e.kind = 'Tagged'",
+1 -1
View File
@@ -15,7 +15,7 @@ using Microsoft.AspNetCore.Routing;
namespace Febe.Web.Api;
/// <summary>
/// What the Attività page needs beside the engine snapshot (spec §7.6, §7.9, mockups 06 and 11): the history of the
/// What the Dashboard (before: Attività) needs beside the engine snapshot (spec §7.6, §7.9, mockups 06 and 11): the history of the
/// stops, the still frame of the browser, the probable duplicates waiting for Alberto, the diagnostic report.
/// </summary>
public static class ActivityApi
+1 -1
View File
@@ -285,7 +285,7 @@ public sealed record ProfileSearchHitDto(string InstagramId, string Username, st
/// <param name="State">"connected", "notConnected", "verification", "disconnected".</param>
public sealed record ConnectionDto(string State, string? Username, string? DisplayName, string? Avatar);
/// <summary>The engine for the sidebar, the stop strip and the Attività page.</summary>
/// <summary>The engine for the sidebar, the stop strip and the Dashboard.</summary>
public sealed record EngineDto(long Now, EngineSnapshot Snapshot, ConnectionDto Connection, bool CanResume);
public sealed record ResumeDto(bool Resumed, string Message);
+2 -1
View File
@@ -33,8 +33,9 @@ public static class LibraryApi
var filter = ApiMapping.Filter(context.Request.Query, zone);
var mode = ApiMapping.Mode(context.Request.Query["mode"]);
var totals = await storage.Entries.GetLibraryTotalsAsync(filter, ct).ConfigureAwait(false);
int? files = mode == MosaicMode.Files ? await storage.Entries.CountLibraryFilesAsync(filter, ct).ConfigureAwait(false) : null;
var days = await storage.Entries.CountLibraryByDayAsync(filter, zone, mode, ct).ConfigureAwait(false);
// The files of «Tutte le foto» are the sum of their days: one pass over the media table per request.
int? files = mode == MosaicMode.Files ? days.Sum(d => d.Count) : null;
var list = days.Select(d =>
{
var end = LocalCalendar.StartOfDay(d.Day.AddDays(1), zone);
+2 -2
View File
@@ -1,6 +1,6 @@
namespace Febe.Web.Api;
// JSON shapes of the second part of the interface (Attività, Impostazioni, Importa, Collegamento, Browser, doppioni).
// JSON shapes of the second part of the interface (Dashboard, Impostazioni, Importa, Collegamento, Browser, doppioni).
// Same conventions as Dtos.cs: English camelCase names, Italian texts, times as Unix milliseconds or LocalTimeDto.
// ---------------------------------------------------------------- connection (PROTOCOLLO.md)
@@ -64,7 +64,7 @@ public sealed record IncidentDto(
public sealed record IncidentListDto(IReadOnlyList<IncidentDto> Items, int ThrottlesLastWeek, string? Advice);
/// <summary>
/// A line of the «Avvisi» list of Attività (spec §13.3): an alert or a failed delivery. <see cref="Kind"/>:
/// A line of the «Avvisi» list of the Dashboard (spec §13.3): an alert or a failed delivery. <see cref="Kind"/>:
/// verification, disconnection, throttleStop, throttleEnd, backfillDone, unknownFormat, recipeSuspended, diskLow,
/// deliveryFailed. <see cref="Level"/>: error, warning, success, info.
/// </summary>
+1 -1
View File
@@ -497,7 +497,7 @@ public static class DemoSeeder
withNews == 0 ? "Giro dei profili che segui: nessuna novità" : $"Giro dei profili che segui: {withNews} contenuti nuovi", null));
}
// The alerts of the last days (Attività, «Avvisi»): the throttle of three days ago (as DemoIncidentHistory) and
// The alerts of the last days (Dashboard, «Avvisi»): the throttle of three days ago (as DemoIncidentHistory) and
// its end, and the backfills completed in the last two weeks.
var throttle = LocalCalendar.StartOfDay(today.AddDays(-3), zone) + TimeSpan.FromHours(18.4);
var throttleEnd = throttle + TimeSpan.FromHours(1);
+2 -2
View File
@@ -1,13 +1,13 @@
namespace Febe.Web.Engine;
/// <summary>A still frame of Febe's browser for the Attività page (mockup 06: one frame every few seconds, not a video).</summary>
/// <summary>A still frame of Febe's browser for the Dashboard (mockup 06: one frame every few seconds, not a video).</summary>
/// <param name="Jpeg">The frame, JPEG encoded.</param>
/// <param name="Url">Address of the page, without query string.</param>
/// <param name="At">When the frame was taken.</param>
public sealed record BrowserFrame(byte[] Jpeg, string? Url, DateTimeOffset At);
/// <summary>
/// The latest frame of Febe's browser, for the preview of the Attività page. Implemented by the composition over the
/// The latest frame of Febe's browser, for the preview of the Dashboard. Implemented by the composition over the
/// browser host (Docker: the screencast of the remote view; Windows: the WebView2). Taking frames is never an action
/// toward the site: it reads what the browser already shows.
/// </summary>
+1 -1
View File
@@ -3,7 +3,7 @@ using Febe.Core.Collection.Diagnostics;
namespace Febe.Web.Engine;
/// <summary>
/// The traces of the diagnostic report (issue #39) for «Esporta il rapporto di diagnostica» in Attività: the finished
/// The traces of the diagnostic report (issue #39) for «Esporta il rapporto di diagnostica» in the Dashboard: the finished
/// ones of the last two weeks and the ones in progress, oldest first. They hold no data value
/// (<see cref="SessionTrace"/>).
/// </summary>
+1 -1
View File
@@ -100,7 +100,7 @@ public sealed class OfflineEngine(IClock clock) : IEngineMonitor, IEngineControl
/// <summary>Pieces for building snapshots outside <see cref="EngineMonitor"/> (offline engine, demo).</summary>
public static class SnapshotParts
{
/// <summary>The four main budgets in the order of the Attività page.</summary>
/// <summary>The four main budgets in the order of the Dashboard.</summary>
public static readonly ActionKind[] Main = [ActionKind.ProfileOpen, ActionKind.StoryView, ActionKind.BackfillPage, ActionKind.DataDownload];
/// <summary>Every category in the order of the table of spec §7.5.</summary>
+1 -1
View File
@@ -3,7 +3,7 @@ using Febe.Core.Storage;
namespace Febe.Web.Engine;
/// <summary>The stops of the last days for the Attività page (spec §7.6: «nella cronologia della pagina Attività»).</summary>
/// <summary>The stops of the last days for the Dashboard (spec §7.6 still says «nella cronologia della pagina Attività», the page before it).</summary>
public interface IIncidentHistory
{
/// <summary>Incidents that started in [from, to), newest first.</summary>
+8 -3
View File
@@ -107,8 +107,8 @@ sono anche `day` (`aaaa-mm-gg`) e `clock` calcolati sul fuso di Febe.
| `GET /api/engine`, `POST /api/engine/pause`, `/resume` | Istantanea del motore, collegamento, `canResume` |
| `POST /api/browser/show`, `/api/browser/used` | «Apri il browser» (desktop), uso del browser |
| `GET /api/eventi` | SSE: `motore` (istantanea, al massimo ogni 300 ms, comunque ogni 60 s), `libreria` (al massimo ogni 1,5 s), commento ogni 25 s |
| `GET /api/library/days` | Totali e giorni con conteggio e cursore (per la finestra del mosaico) |
| `GET /api/library?cursor=&direction=older\|newer&limit=` | Una finestra di tessere, con `older`/`newer` per continuare; filtri `kind`, `accounts`, `from`, `to`, `provenance`, `q` |
| `GET /api/library/days?mode=grouped\|files` | Totali (sempre elementi: `entries`, `accounts`) e giorni con conteggio e cursore (per la finestra del mosaico); con `mode=files` («Tutte le foto») i giorni contano i file presenti in libreria e `files` è la loro somma (altrimenti `null`). Un altro valore di `mode` dà 400. Stessi filtri di `/api/library` |
| `GET /api/library?cursor=&direction=older\|newer&limit=&mode=grouped\|files` | Una finestra di tessere, con `older`/`newer` per continuare; filtri `kind`, `accounts`, `from`, `to`, `provenance`, `q`. Con `mode=files` una tessera per file (con la sua posizione e `files`, i file dell'elemento) e il cursore è `ms.elemento.posizione` (raggruppato `ms.elemento`); un cursore malformato o `mode` sconosciuto danno 400 |
| `GET /api/library/tiles?ids=` | Tessere per chiave |
| `GET /api/thumbnails/{chiave}`, `GET /api/media/{id}/file[?download=1]` | Miniature (immutabili) e file (con range) |
| `GET /api/entries/{id}`, `POST /api/entries/delete`, `/export`, `/{id}/open-on-instagram`, `POST /api/media/show-in-folder` | Visualizzatore, eliminazione (`remember` o `allowReturn`), CSV (`{ ids }` per la selezione, `{ query }` per il filtro della pagina: «Esporta l'elenco» nella riga degli strumenti) |
@@ -210,7 +210,12 @@ Moduli ES, nessuna dipendenza, nessuna build. Durante lo sviluppo si servono da
Pezzi riusabili delle pagine: `pages/mosaic.js` (`Mosaic`: righe giustificate o griglia 9:16, finestre per giorno,
virtualizzazione, selezione, nuovi elementi in cima senza spostare la vista), `pages/viewer.js` (`openViewer`),
`pages/accounts.js` (`checkNow`, `removeAccount`, `accountMenu`, `stateLine`), `pages/library.js` (`confirmDelete`).
`pages/accounts.js` (`checkNow`, `removeAccount`, `accountMenu`, `stateLine`), `pages/library.js` (`confirmDelete`,
`selectionBar`: la barra della selezione, che con «Tutte le foto» dice file ed elementi), `pages/mosaic.js` anche
`storedMode` e `modeSwitch` («Raggruppa i post» / «Tutte le foto», ricordato per pagina nella memoria locale del
browser), `pages/download-order.js` (`orderEditor`: l'elenco da trascinare di «Cosa scaricare prima», con Su/Giù e i
tipi spenti attenuati, usato da Limiti e comportamento e dalla scheda account; `kindName`, `orderOrDefault`,
`DEFAULT_ORDER`).
### Testi, stile, accessibilità
-3
View File
@@ -1,3 +0,0 @@
<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">
<polyline points="3 12 7 12 9.5 6 14 18 16.5 12 21 12"/>
</svg>

Before

Width:  |  Height:  |  Size: 228 B

+1 -1
View File
@@ -1,5 +1,5 @@
// The engine and the library as seen by the pages: one event stream (/api/eventi) for the whole interface.
// «motore» carries the snapshot (sidebar, stop strip, Attività); «libreria» says the library changed.
// «motore» carries the snapshot (sidebar, stop strip, Dashboard); «libreria» says the library changed.
import { api, eventsUrl } from './api.js';
import { caps } from './context.js';
+2 -1
View File
@@ -384,7 +384,8 @@ function settingsTab(page, detail) {
label: t('impAccount.ordineScelta'),
});
const orderChoice = segmented({
label: t('impAccount.ordineScelta'),
// The list is «Ordine dei tipi per questo account»; the two-way choice has the name of the section.
label: t('impAccount.ordine'),
value: Array.isArray(form.downloadOrder) && form.downloadOrder.length ? 'own' : 'general',
options: [{ value: 'general', label: t('impAccount.ordineGenerale') }, { value: 'own', label: t('impAccount.ordineSuo') }],
onchange: (v) => {
@@ -53,13 +53,13 @@ export function orderEditor({ read, write, changed, off = () => false, label })
const order = read();
fill(list, order.map((kind, i) => {
const name = kindName(kind);
const spento = off(kind);
const row = h(spento ? 'li.riga-ordine.spenta' : 'li.riga-ordine', { draggable: 'true', dataset: { tipo: kind } },
const switchedOff = off(kind);
const row = h(switchedOff ? 'li.riga-ordine.spenta' : 'li.riga-ordine', { draggable: 'true', dataset: { tipo: kind } },
h('span.maniglia', { title: t('impostazioni.limiti.ordineManiglia'), 'aria-hidden': 'true' }, icon('grip-vertical', 's')),
h('span.posizione.dati', String(i + 1)),
h('b', name),
spento ? h('span.muto.piccolo', t('impostazioni.limiti.ordineSpento')) : null,
kind === 'storie' && i > 0 && !spento ? h('span.muto.piccolo', icon('clock', 'xs'), ' ', t('impostazioni.limiti.ordineStorie')) : null,
switchedOff ? h('span.muto.piccolo', t('impostazioni.limiti.ordineSpento')) : null,
kind === 'storie' && i > 0 && !switchedOff ? h('span.muto.piccolo', icon('clock', 'xs'), ' ', t('impostazioni.limiti.ordineStorie')) : null,
h('div.destra',
h('button.btn.piccolo.nudo', {
type: 'button', disabled: i === 0, dataset: { verso: 'su' }, 'aria-label': t('impostazioni.limiti.ordineSuDi', { tipo: name }), onclick: () => move(i, i - 1, 'su'),
+13 -4
View File
@@ -13,24 +13,33 @@ import { t, dayName, duration, capitalize } from '../core/text.js';
import { avatar, segmented } from '../core/ui.js';
/**
* «Raggruppa i post» or «Tutte le foto» of a page ('libreria', or 'account' for every account), remembered in this
* browser like the theme (spec §4.6). Storage that is missing, blocked or holds anything else means grouped.
* «Raggruppa i post» or «Tutte le foto» of a page ('libreria', or 'account' for every account), kept only in the
* local storage of this browser (spec §4.6): unlike the theme, Febe does not save it, so another browser starts
* grouped. Storage that is missing, blocked or holds anything else means grouped.
*/
export function storedMode(page) {
return local.get(`mosaico.${page}`, 'grouped') === 'files' ? 'files' : 'grouped';
}
/** The two-voice switch of the tools row; onchange(mode) after the choice is remembered. compact: icons only sooner. */
/**
* The two-voice switch of the tools row; onchange(mode) after the choice is remembered, and only when the mode
* changes: the voice already chosen does nothing (the mosaic, its place and the selection stay). compact: icons only
* sooner.
*/
export function modeSwitch(page, onchange, { compact = false } = {}) {
const labels = { grouped: t('libreria.modi.grouped'), files: t('libreria.modi.files') };
// The mode shown, kept here: without browser storage storedMode() always says grouped.
let current = storedMode(page);
const group = segmented({
label: t('libreria.modi.etichetta'),
value: storedMode(page),
value: current,
options: [
{ value: 'grouped', icon: 'layers', label: h('span.voce', labels.grouped) },
{ value: 'files', icon: 'layout-grid', label: h('span.voce', labels.files) },
],
onchange: (value) => {
if (value === current) return;
current = value;
local.set(`mosaico.${page}`, value);
onchange(value);
},
+13 -2
View File
@@ -112,6 +112,11 @@ export function openViewer({ tile, source, origin, onDeleted }) {
const at = mediaId == null ? -1 : entry.media.findIndex((m) => m.id === mediaId);
if (at >= 0) fileIndex = at;
else fileIndex = index < 0 ? entry.media.length - 1 : Math.min(index, entry.media.length - 1);
if (files && at < 0) {
// Entered from an edge without a file named: the first (or last) file that is a tile.
const tiles = entry.media.map((m, i) => (source.has(m.id) ? i : -1)).filter((i) => i >= 0);
if (tiles.length) fileIndex = index < 0 ? tiles[tiles.length - 1] : tiles[0];
}
draw();
} catch (error) {
showError(error);
@@ -120,7 +125,10 @@ export function openViewer({ tile, source, origin, onDeleted }) {
async function step(delta) {
if (!entry) return;
const target = fileIndex + delta;
let target = fileIndex + delta;
// With «Tutte le foto» the arrows follow the tiles: the files the mosaic does not show (the photos of a post under
// «Video», the videos under «Foto», a file not in the library) are passed over, as the mosaic passes over them.
if (files) while (target >= 0 && target < entry.media.length && !source.has(entry.media[target].id)) target += delta;
if (target >= 0 && target < entry.media.length) {
fileIndex = target;
drawFile();
@@ -149,7 +157,10 @@ export function openViewer({ tile, source, origin, onDeleted }) {
}
function drawWhere() {
const key = source && source.position ? keyAt(0) : null;
// With «Tutte le foto» the place is that of the file on screen; a file that is not a tile (chosen in the series
// strip) has none, and the header says only where the viewer was opened.
const current = files && entry.media[fileIndex];
const key = !source || !source.position ? null : !files ? keyAt(0) : current && source.has(current.id) ? current.id : null;
if (key != null) {
const p = source.position(key);
where.textContent = p.index ? t(files ? 'vis.doveFile' : 'vis.dove', { origine: origin, n: number(p.index), totale: number(p.total) }) : origin;