Skip to content

armgit / ente

Public Imported from GitHub
0

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

[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

ashilkn2c0b6f6dbc37
diff --git a/mobile/lib/states/all_sections_examples_state.dart b/mobile/lib/states/all_sections_examples_state.dart
index 9feb3d96bd..5797cae26e 100644
--- a/mobile/lib/states/all_sections_examples_state.dart
+++ b/mobile/lib/states/all_sections_examples_state.dart
@@ -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(() {