Added throttle on refetch queries on AppLifecycleChange
This commit is contained in:
parent
e0f6ac2356
commit
cb8c65bec1
@ -2,6 +2,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:persistent_bottom_nav_bar_v2/persistent-tab-view.dart';
|
import 'package:persistent_bottom_nav_bar_v2/persistent-tab-view.dart';
|
||||||
@ -41,9 +42,16 @@ class _AppState extends State<App> with WidgetsBindingObserver {
|
|||||||
log("AppLifecycle: ${state.toString()}");
|
log("AppLifecycle: ${state.toString()}");
|
||||||
|
|
||||||
if(state == AppLifecycleState.resumed) {
|
if(state == AppLifecycleState.resumed) {
|
||||||
|
EasyThrottle.throttle(
|
||||||
|
"appLifecycleState",
|
||||||
|
const Duration(seconds: 10),
|
||||||
|
() {
|
||||||
|
log("Refreshing due to LifecycleChange");
|
||||||
NotificationTasks.updateProviders(context);
|
NotificationTasks.updateProviders(context);
|
||||||
Provider.of<TimetableProps>(context, listen: false).run();
|
Provider.of<TimetableProps>(context, listen: false).run();
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user