fixed collection entries when filters include/exclude faved/unfaved entry

This commit is contained in:
Thibault Deckers 2021-06-07 14:47:42 +09:00
parent 56c2070bfa
commit b332739eac

View file

@ -2,7 +2,9 @@ import 'dart:async';
import 'dart:collection'; import 'dart:collection';
import 'package:aves/model/entry.dart'; import 'package:aves/model/entry.dart';
import 'package:aves/model/favourites.dart';
import 'package:aves/model/filters/album.dart'; import 'package:aves/model/filters/album.dart';
import 'package:aves/model/filters/favourite.dart';
import 'package:aves/model/filters/filters.dart'; import 'package:aves/model/filters/filters.dart';
import 'package:aves/model/filters/location.dart'; import 'package:aves/model/filters/location.dart';
import 'package:aves/model/settings/settings.dart'; import 'package:aves/model/settings/settings.dart';
@ -52,6 +54,7 @@ class CollectionLens with ChangeNotifier, CollectionActivityMixin {
_refresh(); _refresh();
} }
})); }));
favourites.addListener(onFavouritesChanged);
} }
_refresh(); _refresh();
} }
@ -61,6 +64,7 @@ class CollectionLens with ChangeNotifier, CollectionActivityMixin {
_subscriptions _subscriptions
..forEach((sub) => sub.cancel()) ..forEach((sub) => sub.cancel())
..clear(); ..clear();
favourites.removeListener(onFavouritesChanged);
super.dispose(); super.dispose();
} }
@ -183,6 +187,12 @@ class CollectionLens with ChangeNotifier, CollectionActivityMixin {
_applyGroup(); _applyGroup();
} }
void onFavouritesChanged() {
if (filters.any((filter) => filter is FavouriteFilter)) {
_refresh();
}
}
void onEntryAdded(Set<AvesEntry>? entries) { void onEntryAdded(Set<AvesEntry>? entries) {
_refresh(); _refresh();
} }