#597 fixed multi-page context update when removing burst entries in viewer
This commit is contained in:
parent
88b1041286
commit
9df2ea5d02
3 changed files with 32 additions and 7 deletions
|
@ -8,6 +8,10 @@ All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
- Collection: support for Sony predictive capture as burst
|
- Collection: support for Sony predictive capture as burst
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Viewer: multi-page context update when removing burst entries
|
||||||
|
|
||||||
## <a id="v1.8.5"></a>[v1.8.5] - 2023-04-18
|
## <a id="v1.8.5"></a>[v1.8.5] - 2023-04-18
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -697,7 +697,20 @@ class _EntryViewerStackState extends State<EntryViewerStack> with EntryViewContr
|
||||||
|
|
||||||
if (hasCollection) {
|
if (hasCollection) {
|
||||||
final collectionEntries = collection!.sortedEntries;
|
final collectionEntries = collection!.sortedEntries;
|
||||||
removedEntries.forEach(collectionEntries.remove);
|
removedEntries.forEach((removedEntry) {
|
||||||
|
// remove from collection
|
||||||
|
if (collectionEntries.remove(removedEntry)) return;
|
||||||
|
|
||||||
|
// remove from burst
|
||||||
|
final mainEntry = collectionEntries.firstWhereOrNull((entry) => entry.burstEntries?.contains(removedEntry) == true);
|
||||||
|
if (mainEntry != null) {
|
||||||
|
final multiPageController = context.read<MultiPageConductor>().getController(mainEntry);
|
||||||
|
if (multiPageController != null) {
|
||||||
|
mainEntry.burstEntries!.remove(removedEntry);
|
||||||
|
multiPageController.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
if (collectionEntries.isNotEmpty) {
|
if (collectionEntries.isNotEmpty) {
|
||||||
_onCollectionChanged();
|
_onCollectionChanged();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:aves/model/entry/entry.dart';
|
import 'package:aves/model/entry/entry.dart';
|
||||||
import 'package:aves/model/entry/extensions/multipage.dart';
|
import 'package:aves/model/entry/extensions/multipage.dart';
|
||||||
|
@ -23,13 +24,20 @@ class MultiPageController {
|
||||||
set page(int? page) => pageNotifier.value = page;
|
set page(int? page) => pageNotifier.value = page;
|
||||||
|
|
||||||
MultiPageController(this.entry) {
|
MultiPageController(this.entry) {
|
||||||
entry.getMultiPageInfo().then((value) {
|
reset();
|
||||||
if (value == null || _disposed) return;
|
}
|
||||||
pageNotifier.value = value.defaultPage?.index ?? 0;
|
|
||||||
_info = value;
|
void reset() => entry.getMultiPageInfo().then((info) {
|
||||||
|
if (info == null || _disposed) return;
|
||||||
|
final currentPage = pageNotifier.value;
|
||||||
|
if (currentPage == null) {
|
||||||
|
pageNotifier.value = info.defaultPage?.index ?? 0;
|
||||||
|
} else {
|
||||||
|
pageNotifier.value = min(currentPage, info.pageCount - 1);
|
||||||
|
}
|
||||||
|
_info = info;
|
||||||
_infoStreamController.add(_info);
|
_infoStreamController.add(_info);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
|
|
Loading…
Reference in a new issue