[mob] Support for showing recent first in discover
This commit is contained in:
@@ -7,7 +7,7 @@ class Prompt {
|
||||
final double minSize;
|
||||
final String title;
|
||||
final bool showVideo;
|
||||
final bool bestFirst;
|
||||
final bool recentFirst;
|
||||
|
||||
// fromJson
|
||||
Prompt.fromJson(Map<String, dynamic> json)
|
||||
@@ -17,6 +17,6 @@ class Prompt {
|
||||
minSize = json['minSize'] ?? json['minimumSize'] ?? 0.0,
|
||||
position = json['position'] ?? 0,
|
||||
title = json['title'],
|
||||
bestFirst = json['bestFirst'] ?? false,
|
||||
recentFirst = json['recentFirst'] ?? false,
|
||||
showVideo = json['showVideo'] ?? true;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ class MagicCache {
|
||||
extension MagicCacheServiceExtension on MagicCache {
|
||||
Future<GenericSearchResult?> toGenericSearchResult(
|
||||
List<EnteFile> enteFilesInMagicCache,
|
||||
bool showRecentFirst,
|
||||
) async {
|
||||
if (enteFilesInMagicCache.isEmpty) {
|
||||
return null;
|
||||
@@ -66,6 +67,7 @@ extension MagicCacheServiceExtension on MagicCache {
|
||||
MagicResultScreen(
|
||||
enteFilesInMagicCache,
|
||||
name: title,
|
||||
enableGrouping: showRecentFirst,
|
||||
heroTag: GenericSearchResult(
|
||||
ResultType.magic,
|
||||
title,
|
||||
@@ -244,6 +246,7 @@ class MagicCacheService {
|
||||
for (MagicCache magicCache in magicCaches) {
|
||||
final genericSearchResult = await magicCache.toGenericSearchResult(
|
||||
magicIdToFiles[magicCache.title]!,
|
||||
(promptMap[magicCache.title]?.recentFirst ?? false),
|
||||
);
|
||||
if (genericSearchResult != null) {
|
||||
genericSearchResults.add(genericSearchResult);
|
||||
|
||||
@@ -20,6 +20,7 @@ class MagicResultScreen extends StatefulWidget {
|
||||
final List<EnteFile> files;
|
||||
final String name;
|
||||
final String heroTag;
|
||||
final bool enableGrouping;
|
||||
|
||||
static const GalleryType appBarType = GalleryType.magic;
|
||||
static const GalleryType overlayType = GalleryType.magic;
|
||||
@@ -27,6 +28,7 @@ class MagicResultScreen extends StatefulWidget {
|
||||
const MagicResultScreen(
|
||||
this.files, {
|
||||
required this.name,
|
||||
this.enableGrouping = false,
|
||||
this.heroTag = "",
|
||||
super.key,
|
||||
});
|
||||
@@ -46,6 +48,7 @@ class _MagicResultScreenState extends State<MagicResultScreen> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
files = widget.files;
|
||||
_enableGrouping = widget.enableGrouping;
|
||||
_filesUpdatedEvent =
|
||||
Bus.instance.on<LocalPhotosUpdatedEvent>().listen((event) {
|
||||
if (event.type == EventType.deletedFromDevice ||
|
||||
|
||||
Reference in New Issue
Block a user