Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob] Keep json sorting for discover

Neeraj Guptafff633aebe74
diff --git a/mobile/lib/models/search/search_types.dart b/mobile/lib/models/search/search_types.dart
index e0f9c5a1d8..0674a28aac 100644
--- a/mobile/lib/models/search/search_types.dart
+++ b/mobile/lib/models/search/search_types.dart
@@ -117,7 +117,7 @@ extension SectionTypeExtensions on SectionType {
}
}
- bool get sortByName => this != SectionType.face;
+ bool get sortByName => this != SectionType.face && this != SectionType.magic;
bool get isEmptyCTAVisible {
switch (this) {
diff --git a/mobile/lib/services/magic_cache_service.dart b/mobile/lib/services/magic_cache_service.dart
index 276a04dbf7..3f7254d453 100644
--- a/mobile/lib/services/magic_cache_service.dart
+++ b/mobile/lib/services/magic_cache_service.dart
@@ -51,35 +51,33 @@ class MagicCache {
}
}
-extension MagicCacheServiceExtension on MagicCache {
- Future<GenericSearchResult?> toGenericSearchResult(
- List<EnteFile> enteFilesInMagicCache,
- bool showRecentFirst,
- ) async {
- if (enteFilesInMagicCache.isEmpty) {
- return null;
- }
- return GenericSearchResult(
- ResultType.magic,
- title,
- enteFilesInMagicCache,
- onResultTap: (ctx) {
- routeToPage(
- ctx,
- MagicResultScreen(
- enteFilesInMagicCache,
- name: title,
- enableGrouping: showRecentFirst,
- heroTag: GenericSearchResult(
- ResultType.magic,
- title,
- enteFilesInMagicCache,
- ).heroTag(),
- ),
- );
- },
- );
+GenericSearchResult? toGenericSearchResult(
+ Prompt prompt,
+ List<EnteFile> enteFilesInMagicCache,
+) {
+ if (enteFilesInMagicCache.isEmpty) {
+ return null;
}
+ return GenericSearchResult(
+ ResultType.magic,
+ prompt.title,
+ enteFilesInMagicCache,
+ onResultTap: (ctx) {
+ routeToPage(
+ ctx,
+ MagicResultScreen(
+ enteFilesInMagicCache,
+ name: prompt.title,
+ enableGrouping: prompt.recentFirst,
+ heroTag: GenericSearchResult(
+ ResultType.magic,
+ prompt.title,
+ enteFilesInMagicCache,
+ ).heroTag(),
+ ),
+ );
+ },
+ );
}
class MagicCacheService {
@@ -264,10 +262,10 @@ class MagicCacheService {
}
}
}
- for (MagicCache magicCache in magicCaches) {
- final genericSearchResult = await magicCache.toGenericSearchResult(
- magicIdToFiles[magicCache.title]!,
- (promptMap[magicCache.title]?.recentFirst ?? false),
+ for (final p in prompts) {
+ final genericSearchResult = toGenericSearchResult(
+ p,
+ magicIdToFiles[p.title] ?? [],
);
if (genericSearchResult != null) {
genericSearchResults.add(genericSearchResult);