From 56c2070bfa16198379430c0dfa66ebec167dce89 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Mon, 7 Jun 2021 14:40:03 +0900 Subject: [PATCH] fixed collection entries when filters include/exclude renamed entry --- lib/model/source/collection_source.dart | 3 ++- lib/widgets/collection/grid/thumbnail.dart | 1 + lib/widgets/viewer/entry_viewer_stack.dart | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/model/source/collection_source.dart b/lib/model/source/collection_source.dart index 32d1e3bd9..c4702d5cb 100644 --- a/lib/model/source/collection_source.dart +++ b/lib/model/source/collection_source.dart @@ -153,6 +153,7 @@ abstract class CollectionSource with SourceBase, AlbumMixin, LocationMixin, TagM await _moveEntry(entry, newFields); entry.metadataChangeNotifier.notifyListeners(); + eventBus.fire(EntryMovedEvent({entry})); return true; } @@ -312,7 +313,7 @@ class EntryRemovedEvent { } class EntryMovedEvent { - final Iterable entries; + final Set entries; const EntryMovedEvent(this.entries); } diff --git a/lib/widgets/collection/grid/thumbnail.dart b/lib/widgets/collection/grid/thumbnail.dart index 4692fea0d..5329f8cc3 100644 --- a/lib/widgets/collection/grid/thumbnail.dart +++ b/lib/widgets/collection/grid/thumbnail.dart @@ -76,6 +76,7 @@ class InteractiveThumbnail extends StatelessWidget { id: collection.id, listenToSource: false, ); + assert(viewerCollection.entryCount == collection.entryCount); return EntryViewerPage( collection: viewerCollection, initialEntry: entry, diff --git a/lib/widgets/viewer/entry_viewer_stack.dart b/lib/widgets/viewer/entry_viewer_stack.dart index f9e75a0d1..e7d2948ff 100644 --- a/lib/widgets/viewer/entry_viewer_stack.dart +++ b/lib/widgets/viewer/entry_viewer_stack.dart @@ -78,11 +78,12 @@ class _EntryViewerStackState extends State with SingleTickerPr @override void initState() { super.initState(); - final entry = widget.initialEntry; + // make sure initial entry is actually among the filtered collection entries + final entry = entries.contains(widget.initialEntry) ? widget.initialEntry : entries.firstOrNull; // opening hero, with viewer as target _heroInfoNotifier.value = HeroInfo(collection?.id, entry); _entryNotifier.value = entry; - _currentHorizontalPage = max(0, entries.indexOf(entry)); + _currentHorizontalPage = max(0, entry != null ? entries.indexOf(entry) : -1); _currentVerticalPage = ValueNotifier(imagePage); _horizontalPager = PageController(initialPage: _currentHorizontalPage); _verticalPager = PageController(initialPage: _currentVerticalPage.value)..addListener(_onVerticalPageControllerChange);