[mob][photos] Make debouncer used in AllSectionsExampleProvider a leading debouncer + delay initial load on app start + avoid a case where initial loading would have happened twice

This commit is contained in:
ashilkn 2025-02-07 17:56:30 +05:30
parent e07a24a192
commit 2c0b6f6dbc

View File

@ -36,11 +36,13 @@ class _AllSectionsExamplesProviderState
late StreamSubscription<TabChangedEvent> _tabChangeEvent;
bool hasPendingUpdate = false;
bool isOnSearchTab = false;
bool firstLoadInProgressOrComplete = false;
final _logger = Logger("AllSectionsExamplesProvider");
final _debouncer = Debouncer(
const Duration(seconds: 3),
executionInterval: const Duration(seconds: 12),
leading: true,
);
@override
@ -66,7 +68,12 @@ class _AllSectionsExamplesProviderState
isOnSearchTab = false;
}
});
reloadAllSections();
Future.delayed(const Duration(seconds: 3), () {
if (!firstLoadInProgressOrComplete) {
reloadAllSections();
}
});
}
void onDataUpdate() {
@ -82,6 +89,7 @@ class _AllSectionsExamplesProviderState
}
void reloadAllSections() {
firstLoadInProgressOrComplete = true;
_logger.info('queue reload all sections');
_debouncer.run(() async {
setState(() {