From 770d4527dad8975a52cfac050cf38ccd850584e2 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Tue, 17 May 2022 19:32:19 +0800 Subject: [PATCH] Store first run time --- app/lib/pref.dart | 8 ++++++++ app/lib/widget/splash.dart | 3 +++ 2 files changed, 11 insertions(+) diff --git a/app/lib/pref.dart b/app/lib/pref.dart index c4009065..0faa0ce0 100644 --- a/app/lib/pref.dart +++ b/app/lib/pref.dart @@ -193,6 +193,11 @@ class Pref { value, (key, value) => provider.setBool(key, value)); + int? getFirstRunTime() => provider.getInt(PrefKey.firstRunTime); + int getFirstRunTimeOr(int def) => getFirstRunTime() ?? def; + Future setFirstRunTime(int value) => _set( + PrefKey.firstRunTime, value, (key, value) => provider.setInt(key, value)); + Future _set(PrefKey key, T value, Future Function(PrefKey key, T value) setFn) async { if (await setFn(key, value)) { @@ -485,6 +490,7 @@ enum PrefKey { enhanceMaxWidth, enhanceMaxHeight, hasShownEnhanceInfo, + firstRunTime, // account pref isEnableFaceRecognitionApp, @@ -545,6 +551,8 @@ extension on PrefKey { return "enhanceMaxHeight"; case PrefKey.hasShownEnhanceInfo: return "hasShownEnhanceInfo"; + case PrefKey.firstRunTime: + return "firstRunTime"; // account pref case PrefKey.isEnableFaceRecognitionApp: diff --git a/app/lib/widget/splash.dart b/app/lib/widget/splash.dart index c130d8d9..52e19936 100644 --- a/app/lib/widget/splash.dart +++ b/app/lib/widget/splash.dart @@ -41,6 +41,9 @@ class _SplashState extends State { } Future _doWork() async { + if (Pref().getFirstRunTime() == null) { + await Pref().setFirstRunTime(DateTime.now().millisecondsSinceEpoch); + } if (_shouldUpgrade()) { await _handleUpgrade(); }