Skip to content

Commit

Permalink
Notification should not update if less than 6 hours
Browse files Browse the repository at this point in the history
[DEBUG PURPOSEES]
  • Loading branch information
iqfareez committed Jan 23, 2021
1 parent af1fd4e commit 3cf936b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/utils/prevent_update_notifs.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
//If less than 3 days, since the last notif is scheduled, do not rescehdule
//3 days = 259200000 millis
//15 seconds = 15000
//6 hours = 21600000
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get_storage/get_storage.dart';
import 'package:waktusolatmalaysia/CONSTANTS.dart';
Expand All @@ -7,13 +10,13 @@ class PreventUpdatingNotifs {
static void now() {
if ((DateTime.now().millisecondsSinceEpoch -
GetStorage().read(kStoredLastUpdateNotif)) <
259200000) {
15000) {
print('Notification should not update');
//TODO: Remove when release, toast is for debug purposes
Fluttertoast.showToast(msg: 'Notification should not update');
GetStorage().write(kStoredShouldUpdateNotif, false);
} else {
GetStorage().write(kStoredLastUpdateNotif, true);
GetStorage().write(kStoredShouldUpdateNotif, true);
print('Notification should update');
Fluttertoast.showToast(msg: 'Notification should update');
}
Expand Down
2 changes: 2 additions & 0 deletions lib/views/Settings part/ThemeController.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:waktusolatmalaysia/utils/prevent_update_notifs.dart';

class ThemeController extends GetxController {
static ThemeController get to => Get.find();
Expand All @@ -12,6 +13,7 @@ class ThemeController extends GetxController {
ThemeMode get themeMode => _themeMode;

Future<void> setThemeMode(ThemeMode themeMode) async {
PreventUpdatingNotifs.now();
Get.changeThemeMode(themeMode);
_themeMode = themeMode;
update();
Expand Down

0 comments on commit 3cf936b

Please sign in to comment.