Fix formatting

This commit is contained in:
Godwin Asuquo 2022-12-09 20:18:36 +01:00
parent f6c5f96929
commit 6836ac6d1a
2 changed files with 15 additions and 20 deletions

View file

@ -21,8 +21,7 @@ class AuthService with Store {
Future<bool> canAuthenticate() async {
final key = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
final walletName =
sharedPreferences.getString(PreferencesKey.currentWalletName) ?? '';
final walletName = sharedPreferences.getString(PreferencesKey.currentWalletName) ?? '';
var password = '';
try {
@ -43,13 +42,11 @@ class AuthService with Store {
}
void saveLastAuthTime() {
int timestamp = DateTime.now().millisecondsSinceEpoch;
sharedPreferences.setInt(PreferencesKey.lastAuthTimeMilliseconds, timestamp);
}
bool requireAuth() {
final timestamp = sharedPreferences.getInt(PreferencesKey.lastAuthTimeMilliseconds);
final duration = _durationToRequireAuth(timestamp ?? 0);
final requiredPinInterval = getIt.get<SettingsStore>().pinTimeOutDuration;
@ -58,7 +55,6 @@ class AuthService with Store {
}
int _durationToRequireAuth(int timestamp) {
DateTime before = DateTime.fromMillisecondsSinceEpoch(timestamp);
DateTime now = DateTime.now();
Duration timeDifference = now.difference(before);

View file

@ -14,10 +14,10 @@ part 'auth_view_model.g.dart';
class AuthViewModel = AuthViewModelBase with _$AuthViewModel;
abstract class AuthViewModelBase with Store {
AuthViewModelBase(this._authService, this._sharedPreferences,
this._settingsStore, this._biometricAuth)
AuthViewModelBase(
this._authService, this._sharedPreferences, this._settingsStore, this._biometricAuth)
: _failureCounter = 0,
state = InitialExecutionState(){
state = InitialExecutionState() {
reaction((_) => state, _saveLastAuthTime);
}
@ -30,8 +30,7 @@ abstract class AuthViewModelBase with Store {
int get pinLength => _settingsStore.pinCodeLength;
bool get isBiometricalAuthenticationAllowed =>
_settingsStore.allowBiometricalAuthentication;
bool get isBiometricalAuthenticationAllowed => _settingsStore.allowBiometricalAuthentication;
@observable
int _failureCounter;
@ -116,13 +115,13 @@ abstract class AuthViewModelBase with Store {
state = ExecutedSuccessfullyState();
}
}
} catch(e) {
} catch (e) {
state = FailureState(e.toString());
}
}
void _saveLastAuthTime(ExecutionState state) {
if(state is ExecutedSuccessfullyState) {
if (state is ExecutedSuccessfullyState) {
_authService.saveLastAuthTime();
}
}