Skip to content

armgit / ente

Public Imported from GitHub
0

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

Rename variable

Neeraj Gupta5dd09a79aefe
diff --git a/lib/states/all_sections_examples_state.dart b/lib/states/all_sections_examples_state.dart
index 0e2512abe1..8cccb7132c 100644
--- a/lib/states/all_sections_examples_state.dart
+++ b/lib/states/all_sections_examples_state.dart
@@ -32,7 +32,7 @@ class _AllSectionsExamplesProviderState
final _logger = Logger("AllSectionsExamplesProvider");
final _debouncer =
- Debouncer(const Duration(seconds: 3), executionInterval: 6000);
+ Debouncer(const Duration(seconds: 3), executionIntervalInSeconds: 6000);
@override
void initState() {
super.initState();
diff --git a/lib/ui/map/map_view.dart b/lib/ui/map/map_view.dart
index 64f65767e4..c7e4f14758 100644
--- a/lib/ui/map/map_view.dart
+++ b/lib/ui/map/map_view.dart
@@ -40,8 +40,8 @@ class MapView extends StatefulWidget {
class _MapViewState extends State<MapView> {
late List<Marker> _markers;
- final _debouncer =
- Debouncer(const Duration(milliseconds: 300), executionInterval: 750);
+ final _debouncer = Debouncer(const Duration(milliseconds: 300),
+ executionIntervalInSeconds: 750);
@override
void initState() {
diff --git a/lib/utils/debouncer.dart b/lib/utils/debouncer.dart
index 97332382d2..755348042b 100644
--- a/lib/utils/debouncer.dart
+++ b/lib/utils/debouncer.dart
@@ -9,17 +9,18 @@ class Debouncer {
///in milliseconds
final ValueNotifier<bool> _debounceActiveNotifier = ValueNotifier(false);
- /// If executionInterval is not null, then the debouncer will execute the
+ /// If executionIntervalInSeconds is not null, then the debouncer will execute the
/// current callback it has in run() method repeatedly in the given interval.
- final int? executionInterval;
+ /// This is useful for example when you want to execute a callback every 5 seconds
+ final int? executionIntervalInSeconds;
Timer? _debounceTimer;
- Debouncer(this._duration, {this.executionInterval});
+ Debouncer(this._duration, {this.executionIntervalInSeconds});
final Stopwatch _stopwatch = Stopwatch();
void run(FutureVoidCallback fn) {
- if (executionInterval != null) {
+ if (executionIntervalInSeconds != null) {
runCallbackIfIntervalTimeElapses(fn);
}
@@ -41,7 +42,7 @@ class Debouncer {
runCallbackIfIntervalTimeElapses(FutureVoidCallback fn) {
_stopwatch.isRunning ? null : _stopwatch.start();
- if (_stopwatch.elapsedMilliseconds > executionInterval!) {
+ if (_stopwatch.elapsedMilliseconds > executionIntervalInSeconds!) {
_stopwatch.reset();
fn();
}