From 9746e6ab172157a76c5a594376d2eb594a79ee40 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Wed, 25 Jan 2023 11:08:05 -0600 Subject: [PATCH] add signupEpoch to prefs --- lib/utilities/prefs.dart | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/utilities/prefs.dart b/lib/utilities/prefs.dart index 54e8e2b62..14f95d039 100644 --- a/lib/utilities/prefs.dart +++ b/lib/utilities/prefs.dart @@ -40,6 +40,7 @@ class Prefs extends ChangeNotifier { _externalCalls = await _getHasExternalCalls(); _familiarity = await _getHasFamiliarity(); _userId = await _getUserId(); + _signupEpoch = await _getSignupEpoch(); _initialized = true; } @@ -624,4 +625,25 @@ class Prefs extends ChangeNotifier { .put(boxName: DB.boxNamePrefs, key: "userID", value: _userId); // notifyListeners(); } + + int? _signupEpoch; + int? get signupEpoch => _signupEpoch; + + Future _getSignupEpoch() async { + int? signupEpoch = await DB.instance + .get(boxName: DB.boxNamePrefs, key: "signupEpoch") as int?; + if (signupEpoch == null) { + signupEpoch = DateTime.now().millisecondsSinceEpoch ~/ + Duration.millisecondsPerSecond; + await saveSignupEpoch(signupEpoch); + } + return signupEpoch; + } + + Future saveSignupEpoch(int signupEpoch) async { + _signupEpoch = signupEpoch; + await DB.instance.put( + boxName: DB.boxNamePrefs, key: "signupEpoch", value: _signupEpoch); + // notifyListeners(); + } }