From 1c199f635106d6afe2aa4d72b0056f404c0811bd Mon Sep 17 00:00:00 2001 From: FaizHashmiCS22 Date: Tue, 10 Oct 2023 10:38:17 +0300 Subject: [PATCH] Counter Fix --- lib/home/app_provider.dart | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/home/app_provider.dart b/lib/home/app_provider.dart index 0720e9e..35b51ef 100644 --- a/lib/home/app_provider.dart +++ b/lib/home/app_provider.dart @@ -185,6 +185,8 @@ class AppProvider extends ChangeNotifier { await setLastTimeUpdatedInCache(lasTimeUpdated: currentDate.toString()); } + int counter = 0; + Future getTheWidgetsConfigurationsEveryMidnight() async { if (currentWidgetsConfigModel == null) return; if (!currentWidgetsConfigModel!.isWeatherReq! && !currentWidgetsConfigModel!.isPrayerTimeReq! && !currentWidgetsConfigModel!.isRssFeedReq!) { @@ -197,14 +199,17 @@ class AppProvider extends ChangeNotifier { return current; }); - Stream timerForRssFeed = Stream.periodic(const Duration(hours: 1), (i) { - current = current.add(const Duration(hours: 1)); - return current; - }); - timer.listen((data) async { DateTime dateTime = DateTime.parse(data.toString()); + counter++; + + log("counterValue: $counter"); + + if (counter == 60 && currentWidgetsConfigModel!.isRssFeedReq!) { + await getRssFeedDetailsFromServer(); + } + if (currentWidgetsConfigModel!.isWeatherReq!) { if (dateTime.day > currentLastTimeUpdated.day) { await getWeatherDetailsFromServer(); @@ -224,12 +229,6 @@ class AppProvider extends ChangeNotifier { } getNextPrayerToShow(); }); - - timerForRssFeed.listen((data) async { - if (currentWidgetsConfigModel!.isRssFeedReq!) { - await getRssFeedDetailsFromServer(); - } - }); } Future startSignalHubConnection() async {