add signupEpoch to prefs

This commit is contained in:
sneurlax 2023-01-25 11:08:05 -06:00
parent f87acdc721
commit 9746e6ab17

View file

@ -40,6 +40,7 @@ class Prefs extends ChangeNotifier {
_externalCalls = await _getHasExternalCalls(); _externalCalls = await _getHasExternalCalls();
_familiarity = await _getHasFamiliarity(); _familiarity = await _getHasFamiliarity();
_userId = await _getUserId(); _userId = await _getUserId();
_signupEpoch = await _getSignupEpoch();
_initialized = true; _initialized = true;
} }
@ -624,4 +625,25 @@ class Prefs extends ChangeNotifier {
.put<dynamic>(boxName: DB.boxNamePrefs, key: "userID", value: _userId); .put<dynamic>(boxName: DB.boxNamePrefs, key: "userID", value: _userId);
// notifyListeners(); // notifyListeners();
} }
int? _signupEpoch;
int? get signupEpoch => _signupEpoch;
Future<int?> _getSignupEpoch() async {
int? signupEpoch = await DB.instance
.get<dynamic>(boxName: DB.boxNamePrefs, key: "signupEpoch") as int?;
if (signupEpoch == null) {
signupEpoch = DateTime.now().millisecondsSinceEpoch ~/
Duration.millisecondsPerSecond;
await saveSignupEpoch(signupEpoch);
}
return signupEpoch;
}
Future<void> saveSignupEpoch(int signupEpoch) async {
_signupEpoch = signupEpoch;
await DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, key: "signupEpoch", value: _signupEpoch);
// notifyListeners();
}
} }