From fcb79907cfe997488d55b98f0dbace6c60b176d2 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Tue, 25 Jun 2024 09:51:25 +0530 Subject: [PATCH] [mob][photos] Remove code that was for handling edge cases when magic section was depending on newly computed results every time instead of using cache --- mobile/lib/models/search/search_types.dart | 3 --- .../ui/viewer/search_tab/magic_section.dart | 23 ------------------- 2 files changed, 26 deletions(-) diff --git a/mobile/lib/models/search/search_types.dart b/mobile/lib/models/search/search_types.dart index e6dab467e1..1b5a186522 100644 --- a/mobile/lib/models/search/search_types.dart +++ b/mobile/lib/models/search/search_types.dart @@ -13,7 +13,6 @@ import "package:photos/models/collection/collection_items.dart"; import "package:photos/models/search/search_result.dart"; import "package:photos/models/typedefs.dart"; import "package:photos/services/collections_service.dart"; -import "package:photos/services/machine_learning/semantic_search/frameworks/ml_framework.dart"; import "package:photos/services/search_service.dart"; import "package:photos/ui/viewer/gallery/collection_page.dart"; import "package:photos/ui/viewer/location/add_location_sheet.dart"; @@ -292,8 +291,6 @@ extension SectionTypeExtensions on SectionType { switch (this) { case SectionType.location: return [Bus.instance.on()]; - case SectionType.magic: - return [Bus.instance.on()]; default: return []; } diff --git a/mobile/lib/ui/viewer/search_tab/magic_section.dart b/mobile/lib/ui/viewer/search_tab/magic_section.dart index d088de92e5..c3a4a98712 100644 --- a/mobile/lib/ui/viewer/search_tab/magic_section.dart +++ b/mobile/lib/ui/viewer/search_tab/magic_section.dart @@ -33,28 +33,6 @@ class _MagicSectionState extends State { super.initState(); _magicSearchResults = widget.magicSearchResults; - //At times, ml framework is not initialized when the search results are - //requested (widget.momentsSearchResults is empty) and is initialized - //(which fires MLFrameworkInitializationUpdateEvent with - //InitializationState.initialized) before initState of this widget is - //called. We do listen to MLFrameworkInitializationUpdateEvent and reload - //this widget but the event with InitializationState.initialized would have - //already been fired in the above case. - if (_magicSearchResults.isEmpty) { - SectionType.magic - .getData( - context, - limit: kSearchSectionLimit, - ) - .then((value) { - if (mounted) { - setState(() { - _magicSearchResults = value as List; - }); - } - }); - } - final streamsToListenTo = SectionType.magic.sectionUpdateEvents(); for (Stream stream in streamsToListenTo) { streamSubscriptions.add( @@ -84,7 +62,6 @@ class _MagicSectionState extends State { @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; }