diff --git a/auth/lib/services/preference_service.dart b/auth/lib/services/preference_service.dart index 1760fd884d..4d5c1bd7ef 100644 --- a/auth/lib/services/preference_service.dart +++ b/auth/lib/services/preference_service.dart @@ -23,9 +23,11 @@ class PreferenceService { static const kShouldAutoFocusOnSearchBar = "should_auto_focus_on_search_bar"; static const kShouldMinimizeOnCopy = "should_minimize_on_copy"; static const kCompactMode = "vi.compactMode"; + static const kAppInstallTime = "appInstallTime"; Future init() async { _prefs = await SharedPreferences.getInstance(); + await setAppInstallTime(); } bool hasShownCoachMark() { @@ -103,4 +105,19 @@ class PreferenceService { Future setShouldMinimizeOnCopy(bool value) async { await _prefs.setBool(kShouldMinimizeOnCopy, value); } + + int getAppInstalledTime() { + if (_prefs.containsKey(kAppInstallTime)) { + return _prefs.getInt(kAppInstallTime)!; + } else { + return DateTime.now().millisecondsSinceEpoch; + } + } + + Future setAppInstallTime() async { + if (!_prefs.containsKey(kAppInstallTime)) { + final installedTimeinMillis = DateTime.now().millisecondsSinceEpoch; + await _prefs.setInt(kAppInstallTime, installedTimeinMillis); + } + } }