fix(library): land a reading's rows as they are read, and keep the copy the reader reads offline
- scan: rows go down on a clock as well as on a full batch. The reader's folder of 26 RAWs is under one batch of 50, so nothing of it reached the screen until the reading was over — a wall that stood empty for the whole scan and then filled in one go. Frames now reach the screen every 400ms while the roll is still being read, so the count climbs and the first tiles are drawn as the frames land. - tiles: a HEIC or a RAW has its tile written the first time it is drawn, so every later visit reads the tile back instead of the file. - resume: a reading a reload cut off is offered by the next visit with a chip instead of being run behind the reader's back. - offline listing: the desk's listing is kept whole in IndexedDB under `recipescam-offline`/`reads`, past the 200 000 characters localStorage held, so an offline visit opens on the listing it kept instead of on nothing. - offline writes: a vote or a view cast with no server is held and goes out when one answers again, with a bar that says how many are waiting. - sw: the shell precaches its own bundle, stylesheet and icon, read out of the document — a worker that precached only the document answered an offline launch with a page whose JavaScript the machine did not have. - checks in docker/frontend/scripts: tree-scan-check (counts while reading, resume after a reload, tiles of a long roll), offline-read-check, offline-queue-check.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useI18n } from '../i18n/I18nProvider';
|
||||
import { heldCount, isReachable, subscribe } from '../pwa/offline';
|
||||
|
||||
// The server cannot be reached. A bar, not a dialog: nothing is being asked of
|
||||
// the visitor, and the answer — the saved copy of what the screen was holding —
|
||||
// is already on the screen. It goes away by itself the moment a call answers.
|
||||
//
|
||||
// It also stays up while writes are still held: the server being back is not the
|
||||
// same thing as the server having them, and a queue that drained quietly would
|
||||
// leave the visitor wondering whether the last change landed. See `hold`/`flush`
|
||||
// in pwa/offline.ts.
|
||||
export function OfflineBar() {
|
||||
const { t } = useI18n();
|
||||
const [gone, setGone] = useState(() => !isReachable());
|
||||
const [held, setHeld] = useState(heldCount);
|
||||
|
||||
useEffect(
|
||||
() =>
|
||||
subscribe(() => {
|
||||
setGone(!isReachable());
|
||||
setHeld(heldCount());
|
||||
}),
|
||||
[]
|
||||
);
|
||||
|
||||
if (!gone && held === 0) return null;
|
||||
const lines = [gone ? t('offline.notice') : '', held > 0 ? t('offline.pending', { n: held }) : ''];
|
||||
return (
|
||||
<div className="offline-bar" role="status" data-key="offline-bar">
|
||||
{lines.filter(Boolean).join(' ')}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user