Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] SectionType.content -> SectionType.magic

ashilknfabd6351d9a3
diff --git a/mobile/lib/models/search/search_types.dart b/mobile/lib/models/search/search_types.dart
index 30b8a0bb0b..e6dab467e1 100644
--- a/mobile/lib/models/search/search_types.dart
+++ b/mobile/lib/models/search/search_types.dart
@@ -41,8 +41,7 @@ enum ResultType {
enum SectionType {
face,
location,
- // Grouping based on ML or manual tagging
- content,
+ magic,
// includes year, month , day, event ResultType
moment,
album,
@@ -58,8 +57,8 @@ extension SectionTypeExtensions on SectionType {
switch (this) {
case SectionType.face:
return S.of(context).people;
- case SectionType.content:
- return S.of(context).contents;
+ case SectionType.magic:
+ return "Magic";
case SectionType.moment:
return S.of(context).moments;
case SectionType.location:
@@ -79,8 +78,8 @@ extension SectionTypeExtensions on SectionType {
switch (this) {
case SectionType.face:
return S.of(context).searchFaceEmptySection;
- case SectionType.content:
- return "Contents";
+ case SectionType.magic:
+ return "Magic";
case SectionType.moment:
return S.of(context).searchDatesEmptySection;
case SectionType.location:
@@ -102,7 +101,7 @@ extension SectionTypeExtensions on SectionType {
switch (this) {
case SectionType.face:
return false;
- case SectionType.content:
+ case SectionType.magic:
return false;
case SectionType.moment:
return false;
@@ -125,7 +124,7 @@ extension SectionTypeExtensions on SectionType {
switch (this) {
case SectionType.face:
return false;
- case SectionType.content:
+ case SectionType.magic:
return false;
case SectionType.moment:
return false;
@@ -147,9 +146,9 @@ extension SectionTypeExtensions on SectionType {
case SectionType.face:
// todo: later
return "Setup";
- case SectionType.content:
+ case SectionType.magic:
// todo: later
- return "Add tags";
+ return "temp";
case SectionType.moment:
return S.of(context).addNew;
case SectionType.location:
@@ -169,7 +168,7 @@ extension SectionTypeExtensions on SectionType {
switch (this) {
case SectionType.face:
return Icons.adaptive.arrow_forward_outlined;
- case SectionType.content:
+ case SectionType.magic:
return null;
case SectionType.moment:
return null;
@@ -250,7 +249,7 @@ extension SectionTypeExtensions on SectionType {
switch (this) {
case SectionType.face:
return SearchService.instance.getAllFace(limit);
- case SectionType.content:
+ case SectionType.magic:
return SearchService.instance.getMagicSectionResutls();
case SectionType.moment:
@@ -293,7 +292,7 @@ extension SectionTypeExtensions on SectionType {
switch (this) {
case SectionType.location:
return [Bus.instance.on<LocationTagUpdatedEvent>()];
- case SectionType.content:
+ case SectionType.magic:
return [Bus.instance.on<MLFrameworkInitializationUpdateEvent>()];
default:
return [];
diff --git a/mobile/lib/ui/viewer/search/result/no_result_widget.dart b/mobile/lib/ui/viewer/search/result/no_result_widget.dart
index 48ba811df5..dc64a8e322 100644
--- a/mobile/lib/ui/viewer/search/result/no_result_widget.dart
+++ b/mobile/lib/ui/viewer/search/result/no_result_widget.dart
@@ -21,7 +21,7 @@ class _NoResultWidgetState extends State<NoResultWidget> {
super.initState();
searchTypes = SectionType.values.toList(growable: true);
// remove face and content sectionType
- searchTypes.remove(SectionType.content);
+ searchTypes.remove(SectionType.magic);
}
@override
diff --git a/mobile/lib/ui/viewer/search_tab/magic_section.dart b/mobile/lib/ui/viewer/search_tab/magic_section.dart
index 14b3772276..200f2b988d 100644
--- a/mobile/lib/ui/viewer/search_tab/magic_section.dart
+++ b/mobile/lib/ui/viewer/search_tab/magic_section.dart
@@ -42,7 +42,7 @@ class _MagicSectionState extends State<MagicSection> {
//this widget but the event with InitializationState.initialized would have
//already been fired in the above case.
if (_magicSearchResults.isEmpty) {
- SectionType.content
+ SectionType.magic
.getData(
context,
limit: kSearchSectionLimit,
@@ -56,14 +56,14 @@ class _MagicSectionState extends State<MagicSection> {
});
}
- final streamsToListenTo = SectionType.content.sectionUpdateEvents();
+ final streamsToListenTo = SectionType.magic.sectionUpdateEvents();
for (Stream<Event> stream in streamsToListenTo) {
streamSubscriptions.add(
stream.listen((event) async {
final mlFrameWorkEvent =
event as MLFrameworkInitializationUpdateEvent;
if (mlFrameWorkEvent.state == InitializationState.initialized) {
- _magicSearchResults = (await SectionType.content.getData(
+ _magicSearchResults = (await SectionType.magic.getData(
context,
limit: kSearchSectionLimit,
)) as List<GenericSearchResult>;
@@ -82,12 +82,14 @@ class _MagicSectionState extends State<MagicSection> {
super.dispose();
}
- // @override
- // void didUpdateWidget(covariant MagicSection oldWidget) {
- // super.didUpdateWidget(oldWidget);
- // //widget.magicSearch is empty when doing a hot reload
- // _magicSearchResults = widget.magicSearchResults;
- // }
+ @override
+ void didUpdateWidget(covariant MagicSection oldWidget) {
+ super.didUpdateWidget(oldWidget);
+ //widget.magicSearch is empty when doing a hot reload
+ if (widget.magicSearchResults.isNotEmpty) {
+ _magicSearchResults = widget.magicSearchResults;
+ }
+ }
@override
Widget build(BuildContext context) {
@@ -102,14 +104,14 @@ class _MagicSectionState extends State<MagicSection> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- SectionType.content.sectionTitle(context),
+ SectionType.magic.sectionTitle(context),
style: textTheme.largeBold,
),
const SizedBox(height: 24),
Padding(
padding: const EdgeInsets.only(left: 4),
child: Text(
- SectionType.content.getEmptyStateText(context),
+ SectionType.magic.getEmptyStateText(context),
style: textTheme.smallMuted,
),
),
@@ -117,7 +119,7 @@ class _MagicSectionState extends State<MagicSection> {
),
),
const SizedBox(width: 8),
- const SearchSectionEmptyCTAIcon(SectionType.content),
+ const SearchSectionEmptyCTAIcon(SectionType.magic),
],
),
);
@@ -128,7 +130,7 @@ class _MagicSectionState extends State<MagicSection> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SectionHeader(
- SectionType.content,
+ SectionType.magic,
hasMore: (_magicSearchResults.length >= kSearchSectionLimit - 1),
),
const SizedBox(height: 2),
diff --git a/mobile/lib/ui/viewer/search_tab/search_tab.dart b/mobile/lib/ui/viewer/search_tab/search_tab.dart
index 9c3d1d2ae2..07a13d9e2b 100644
--- a/mobile/lib/ui/viewer/search_tab/search_tab.dart
+++ b/mobile/lib/ui/viewer/search_tab/search_tab.dart
@@ -153,7 +153,7 @@ class _AllSearchSectionsState extends State<AllSearchSections> {
snapshot.data!.elementAt(index)
as List<GenericSearchResult>,
);
- case SectionType.content:
+ case SectionType.magic:
return MagicSection(
snapshot.data!.elementAt(index)
as List<GenericSearchResult>,