|
|
|
|
@ -14,6 +14,7 @@ import 'package:hmg_qline/models/prayers_widget_model.dart';
|
|
|
|
|
import 'package:hmg_qline/models/rss_feed_model.dart';
|
|
|
|
|
import 'package:hmg_qline/models/weathers_widget_model.dart';
|
|
|
|
|
import 'package:hmg_qline/repositories/screen_details_repo.dart';
|
|
|
|
|
import 'package:hmg_qline/repositories/signalR_repo.dart';
|
|
|
|
|
import 'package:hmg_qline/services/cache_service.dart';
|
|
|
|
|
import 'package:hmg_qline/services/connectivity_service.dart';
|
|
|
|
|
import 'package:hmg_qline/services/logger_service.dart';
|
|
|
|
|
@ -57,7 +58,7 @@ class ScreenConfigViewModel extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
// nativeMethodChannelService.reopenApp();
|
|
|
|
|
nativeMethodChannelService.restartApp();
|
|
|
|
|
runApp(const MyApp());
|
|
|
|
|
// runApp(const MyApp());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> waitForIPAndInitializeConfigVM() async {
|
|
|
|
|
@ -229,18 +230,7 @@ class ScreenConfigViewModel extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
void getNextPrayerToShow() async {
|
|
|
|
|
final current = DateTime.now();
|
|
|
|
|
log("Checking Namaz time Locally at ${current.toString()} and ${current.timeZoneName} ");
|
|
|
|
|
|
|
|
|
|
if (!isHubConnected) {
|
|
|
|
|
log("Hub is Not Connected!, I will try to reconnect now.");
|
|
|
|
|
QueuingViewModel queuingViewModel = getIt.get<QueuingViewModel>();
|
|
|
|
|
bool? status = await queuingViewModel.startHubConnection();
|
|
|
|
|
if (status != false) {
|
|
|
|
|
updateIsHubConnected(true);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
log("Hub is Connected!");
|
|
|
|
|
}
|
|
|
|
|
log("Checking Namaz time Locally at $current and ${current.timeZoneName}");
|
|
|
|
|
|
|
|
|
|
// log("Data Before Check : ${prayersWidgetModel.fajr}");
|
|
|
|
|
// log("Data Before Check : ${globalConfigurationsModel.isPrayerTimeReq}");
|
|
|
|
|
@ -287,7 +277,7 @@ class ScreenConfigViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int counter = 0;
|
|
|
|
|
|
|
|
|
|
DateTime lastChecked = DateTime.now();
|
|
|
|
|
Timer? _midnightTimer;
|
|
|
|
|
|
|
|
|
|
Future<void> getTheWidgetsConfigurationsEveryMidnight() async {
|
|
|
|
|
@ -298,16 +288,18 @@ class ScreenConfigViewModel extends ChangeNotifier {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int counter = 0;
|
|
|
|
|
DateTime lastChecked = DateTime.now();
|
|
|
|
|
// Only start timer if not already running
|
|
|
|
|
if (_midnightTimer != null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_midnightTimer = Timer.periodic(const Duration(minutes: 5), (timer) async {
|
|
|
|
|
_midnightTimer = Timer.periodic(const Duration(minutes: 1), (timer) async {
|
|
|
|
|
counter++;
|
|
|
|
|
DateTime now = DateTime.now();
|
|
|
|
|
log("counterValue: $counter");
|
|
|
|
|
|
|
|
|
|
// Every hour, update RSS feed if required
|
|
|
|
|
if (counter % 12 == 0 && globalConfigurationsModel.isRssFeedReq) {
|
|
|
|
|
if (counter % 60 == 0 && globalConfigurationsModel.isRssFeedReq) {
|
|
|
|
|
await getRssFeedDetailsFromServer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -326,6 +318,7 @@ class ScreenConfigViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getNextPrayerToShow();
|
|
|
|
|
syncHubConnectionState();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -534,4 +527,20 @@ class ScreenConfigViewModel extends ChangeNotifier {
|
|
|
|
|
await qrViewController!.flipCamera();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void syncHubConnectionState() async {
|
|
|
|
|
QueuingViewModel queuingViewModel = getIt.get<QueuingViewModel>();
|
|
|
|
|
bool newState = (queuingViewModel.signalrRepo as SignalrRepoImp).isConnected;
|
|
|
|
|
if (isHubConnected != newState) {
|
|
|
|
|
updateIsHubConnected(newState);
|
|
|
|
|
}
|
|
|
|
|
if (!isHubConnected) {
|
|
|
|
|
log("Hub is Not Connected!, I will try to reconnect now.");
|
|
|
|
|
QueuingViewModel queuingViewModel = getIt.get<QueuingViewModel>();
|
|
|
|
|
bool? status = await queuingViewModel.startHubConnection();
|
|
|
|
|
// syncHubConnectionState will update isHubConnected
|
|
|
|
|
} else {
|
|
|
|
|
log("Hub is Connected!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|