Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[auth] Implemented function to set the app install time

Aman Raj Singh Mourya6ed52034858b
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<void> init() async {
_prefs = await SharedPreferences.getInstance();
+ await setAppInstallTime();
}
bool hasShownCoachMark() {
@@ -103,4 +105,19 @@ class PreferenceService {
Future<void> 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<void> setAppInstallTime() async {
+ if (!_prefs.containsKey(kAppInstallTime)) {
+ final installedTimeinMillis = DateTime.now().millisecondsSinceEpoch;
+ await _prefs.setInt(kAppInstallTime, installedTimeinMillis);
+ }
+ }
}