diff --git a/lib/ui/views/authenticate/password_screen.dart b/lib/ui/views/authenticate/password_screen.dart index a641d19a7..4e2e7b9af 100644 --- a/lib/ui/views/authenticate/password_screen.dart +++ b/lib/ui/views/authenticate/password_screen.dart @@ -67,8 +67,18 @@ class _PasswordScreenState extends ConsumerState if (!_canBeSubmitted) return; if (!mounted) return; - // Do not use setState for that [isProcessing] flag : unlock operation stalls UI on web, so it delays setState operation. - isProcessing = true; + setState(() { + isProcessing = true; + }); + // wait for next redraw to perform operation. + // that way, we ensure [isProcessing] change is reflecter on the UI + // This is necessary because [setPassword] decyphering operation + // stalls UI on web platform (single-threaded) + await Future.delayed( + const Duration(milliseconds: 5), + () {}, + ); + final password = enterPasswordController!.text; final result = await ref .read( @@ -128,7 +138,7 @@ class _PasswordScreenState extends ConsumerState Dimens.buttonTopDimens, key: const Key('confirm'), onPressed: _verifyPassword, - disabled: !_canBeSubmitted, + disabled: !_canBeSubmitted || isProcessing, ), ], ); diff --git a/lib/ui/views/settings/set_password.dart b/lib/ui/views/settings/set_password.dart index 0a4e62b97..733787ff4 100755 --- a/lib/ui/views/settings/set_password.dart +++ b/lib/ui/views/settings/set_password.dart @@ -82,6 +82,7 @@ class _SetPasswordState extends ConsumerState Dimens.buttonTopDimens, key: const Key('confirm'), onPressed: _validateRequest, + disabled: isProcessing, ), ], ); @@ -237,7 +238,9 @@ class _SetPasswordState extends ConsumerState controller: confirmPasswordController, textInputAction: TextInputAction.done, autocorrect: false, - onSubmitted: (_) => _validateRequest(), + onSubmitted: (_) async { + await _validateRequest(); + }, onChanged: (String newText) { if (passwordError != null) { setState(() { @@ -326,8 +329,17 @@ class _SetPasswordState extends ConsumerState return; } - // Do not use setState for that [isProcessing] flag : unlock operation stalls UI on web, so it delays setState operation. - isProcessing = true; + setState(() { + isProcessing = true; + }); + // wait for next redraw to perfor operation. + // that way, we ensure [isProcessing] change is reflecter on the UI + // This is necessary because [setPassword] decyphering operation + // stalls UI on web platform (single-threaded) + await Future.delayed( + const Duration(milliseconds: 5), + () {}, + ); await ref .read(AuthenticationProviders.passwordAuthentication.notifier) .setPassword(setPasswordController!.text); diff --git a/test/vault_secure_storage_test.dart b/test/vault_secure_storage_test.dart index 6dd61d8ef..628e3faec 100644 --- a/test/vault_secure_storage_test.dart +++ b/test/vault_secure_storage_test.dart @@ -115,12 +115,12 @@ void main() { 'Should decrypt securedKey with right salt and password', () async { final securedKey = Uint8List.fromList([1, 2, 3, 4]); - final encryptedSecureKey = Hive.encryptSecureKey( + final encryptedSecureKey = await Hive.encryptSecureKey( 'salt_ok', 'password_ok', securedKey, ); - final decryptedSecureKey = Hive.decryptSecureKey( + final decryptedSecureKey = await Hive.decryptSecureKey( 'salt_ok', 'password_ok', encryptedSecureKey, @@ -143,7 +143,7 @@ void main() { () async => Hive.decryptSecureKey( 'wrong_salt', 'password_ok', - encryptedSecureKey, + await encryptedSecureKey, ), throwsA(isA()), ); @@ -162,7 +162,7 @@ void main() { () async => Hive.decryptSecureKey( 'salt_ok', 'wrong_password', - encryptedSecuredKey, + await encryptedSecuredKey, ), throwsA(isA()), ); diff --git a/web_chrome_extension/package-lock.json b/web_chrome_extension/package-lock.json index 050f1d489..801dd8501 100644 --- a/web_chrome_extension/package-lock.json +++ b/web_chrome_extension/package-lock.json @@ -57,6 +57,17 @@ "sjcl": "^1.0.8", "tweetnacl": "^1.0.3", "uninstall": "^0.0.0" + }, + "devDependencies": { + "@types/absinthe__socket": "^0.2.3", + "@types/elliptic": "^6.4.14", + "@types/jest": "^29.5.0", + "esbuild": "^0.19.0", + "jest": "^29.5.0", + "nock": "^13.3.0", + "prettier": "3.1.0", + "ts-jest": "^29.1.0", + "ts-jest-resolver": "^2.0.1" } }, "node_modules/@babel/runtime": { @@ -2298,4 +2309,4 @@ "dev": true } } -} +} \ No newline at end of file