mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
[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:
parent
e07a24a192
commit
2c0b6f6dbc
@ -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(() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user