mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Store first run time
This commit is contained in:
parent
3d81fb39a6
commit
770d4527da
2 changed files with 11 additions and 0 deletions
|
@ -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<bool> setFirstRunTime(int value) => _set<int>(
|
||||
PrefKey.firstRunTime, value, (key, value) => provider.setInt(key, value));
|
||||
|
||||
Future<bool> _set<T>(PrefKey key, T value,
|
||||
Future<bool> 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:
|
||||
|
|
|
@ -41,6 +41,9 @@ class _SplashState extends State<Splash> {
|
|||
}
|
||||
|
||||
Future<void> _doWork() async {
|
||||
if (Pref().getFirstRunTime() == null) {
|
||||
await Pref().setFirstRunTime(DateTime.now().millisecondsSinceEpoch);
|
||||
}
|
||||
if (_shouldUpgrade()) {
|
||||
await _handleUpgrade();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue