fixed app lifecycle state init

This commit is contained in:
Thibault Deckers 2024-12-30 16:18:57 +01:00
parent cfb546f056
commit 68a285b7fa
2 changed files with 8 additions and 6 deletions

View file

@ -493,17 +493,13 @@ abstract class CollectionSource with SourceBase, AlbumMixin, CountryMixin, Place
// cataloguing // cataloguing
if (!startAnalysisService) { if (!startAnalysisService) {
final opCount = (force ? todoEntries : todoEntries.where(TagMixin.catalogEntriesTest)).length; final opCount = (force ? todoEntries : todoEntries.where(TagMixin.catalogEntriesTest)).length;
if (opCount > TagMixin.commitCountThreshold) { startAnalysisService = opCount > TagMixin.commitCountThreshold;
startAnalysisService = true;
}
} }
// ignore locating countries // ignore locating countries
// locating places // locating places
if (!startAnalysisService && await availability.canLocatePlaces) { if (!startAnalysisService && await availability.canLocatePlaces) {
final opCount = (force ? todoEntries.where((entry) => entry.hasGps) : todoEntries.where(LocationMixin.locatePlacesTest)).length; final opCount = (force ? todoEntries.where((entry) => entry.hasGps) : todoEntries.where(LocationMixin.locatePlacesTest)).length;
if (opCount > LocationMixin.commitCountThreshold) { startAnalysisService = opCount > LocationMixin.commitCountThreshold;
startAnalysisService = true;
}
} }
} }

View file

@ -203,7 +203,10 @@ class _AvesAppState extends State<AvesApp> with WidgetsBindingObserver {
_subscriptions.add(_errorChannel.receiveBroadcastStream().listen((event) => _onError(event as String?))); _subscriptions.add(_errorChannel.receiveBroadcastStream().listen((event) => _onError(event as String?)));
_updateCutoutInsets(); _updateCutoutInsets();
_appModeNotifier.addListener(_onAppModeChanged); _appModeNotifier.addListener(_onAppModeChanged);
debugPrint('start listening to app lifecycle');
WidgetsBinding.instance.addObserver(this); WidgetsBinding.instance.addObserver(this);
AvesApp.lifecycleStateNotifier.value = WidgetsBinding.instance.lifecycleState ?? AppLifecycleState.detached;
} }
@override @override
@ -211,7 +214,10 @@ class _AvesAppState extends State<AvesApp> with WidgetsBindingObserver {
_subscriptions _subscriptions
..forEach((sub) => sub.cancel()) ..forEach((sub) => sub.cancel())
..clear(); ..clear();
debugPrint('stop listening to app lifecycle');
WidgetsBinding.instance.removeObserver(this); WidgetsBinding.instance.removeObserver(this);
_pageTransitionsBuilderNotifier.dispose(); _pageTransitionsBuilderNotifier.dispose();
_tvMediaQueryModifierNotifier.dispose(); _tvMediaQueryModifierNotifier.dispose();
_appModeNotifier.dispose(); _appModeNotifier.dispose();