[auth] Implemented function to set the app install time

This commit is contained in:
Aman Raj Singh Mourya 2025-01-24 17:06:14 +05:30
parent bbf001e5cb
commit 6ed5203485

View File

@ -23,9 +23,11 @@ class PreferenceService {
static const kShouldAutoFocusOnSearchBar = "should_auto_focus_on_search_bar"; static const kShouldAutoFocusOnSearchBar = "should_auto_focus_on_search_bar";
static const kShouldMinimizeOnCopy = "should_minimize_on_copy"; static const kShouldMinimizeOnCopy = "should_minimize_on_copy";
static const kCompactMode = "vi.compactMode"; static const kCompactMode = "vi.compactMode";
static const kAppInstallTime = "appInstallTime";
Future<void> init() async { Future<void> init() async {
_prefs = await SharedPreferences.getInstance(); _prefs = await SharedPreferences.getInstance();
await setAppInstallTime();
} }
bool hasShownCoachMark() { bool hasShownCoachMark() {
@ -103,4 +105,19 @@ class PreferenceService {
Future<void> setShouldMinimizeOnCopy(bool value) async { Future<void> setShouldMinimizeOnCopy(bool value) async {
await _prefs.setBool(kShouldMinimizeOnCopy, value); await _prefs.setBool(kShouldMinimizeOnCopy, value);
} }
int getAppInstalledTime() {
if (_prefs.containsKey(kAppInstallTime)) {
return _prefs.getInt(kAppInstallTime)!;
} else {
return DateTime.now().millisecondsSinceEpoch;
}
}
Future<void> setAppInstallTime() async {
if (!_prefs.containsKey(kAppInstallTime)) {
final installedTimeinMillis = DateTime.now().millisecondsSinceEpoch;
await _prefs.setInt(kAppInstallTime, installedTimeinMillis);
}
}
} }