Added throttle on refetch queries on AppLifecycleChange

This commit is contained in:
Elias Müller 2024-02-12 14:11:56 +01:00
parent e0f6ac2356
commit cb8c65bec1

View File

@ -2,6 +2,7 @@
import 'dart:async';
import 'dart:developer';
import 'package:easy_debounce/easy_throttle.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:persistent_bottom_nav_bar_v2/persistent-tab-view.dart';
@ -41,8 +42,15 @@ class _AppState extends State<App> with WidgetsBindingObserver {
log("AppLifecycle: ${state.toString()}");
if(state == AppLifecycleState.resumed) {
NotificationTasks.updateProviders(context);
Provider.of<TimetableProps>(context, listen: false).run();
EasyThrottle.throttle(
"appLifecycleState",
const Duration(seconds: 10),
() {
log("Refreshing due to LifecycleChange");
NotificationTasks.updateProviders(context);
Provider.of<TimetableProps>(context, listen: false).run();
}
);
}
}