perf(inventory): lazy list, photo thumbnails, indexes, debounced reload

Scale the local inventory to 10k+ varieties:
- Render the list with ListView.builder over a flattened header/item model
  instead of building every tile upfront.
- Store a small regenerable JPEG thumbnail per photo (schema v14) and use it
  for the 48px list avatar; full bytes stay for offer image hosting. Existing
  photos are backfilled lazily at startup. Thumbnail is local-only (excluded
  from CRDT sync and backups by the JSON codec).
- Add indexes on varieties(is_deleted,is_draft), attachments(parent_type,
  parent_id,kind), lots(variety_id) via @TableIndex.
- Debounce watchInventoryView (~250ms) so a burst of table writes triggers one
  reload, not seven.
- cacheWidth/cacheHeight on the list avatar decode.
- Scale test raised 3k -> 10k; migration test v13 -> v14.
This commit is contained in:
vjrj 2026-07-20 17:48:37 +02:00
parent 2884ddd3c7
commit 3de01bd948
12 changed files with 5114 additions and 34 deletions

View file

@ -28,6 +28,7 @@ import '../services/file_service.dart';
import '../services/inbox_service.dart';
import '../services/locale_store.dart';
import '../services/notification_service.dart';
import '../services/offer_thumbnail.dart';
import '../services/ocr/label_text_extractor.dart';
import '../services/ocr/ocr_language.dart';
import '../services/ocr/tesseract_label_extractor.dart';
@ -152,7 +153,11 @@ Future<void> configureDependencies() async {
database,
idGen: IdGen(),
nodeId: nodeId,
thumbnailBuilder: inventoryThumbnailBytes,
);
// Backfill list thumbnails for photos that predate the thumbnail column (or
// arrived via a restored backup). Fire-and-forget so startup isn't blocked.
unawaited(varietyRepository.backfillThumbnails());
const fileService = FilePickerFileService();