diff --git a/lib/services/authenticator_service.dart b/lib/services/authenticator_service.dart index 4d739d1bb..57b999bba 100644 --- a/lib/services/authenticator_service.dart +++ b/lib/services/authenticator_service.dart @@ -62,7 +62,7 @@ class AuthenticatorService { return entries; } - Future addEntry(String plainText) async { + Future addEntry(String plainText, bool shouldSync) async { var key = await getOrCreateAuthDataKey(); final encryptedKeyData = await CryptoUtil.encryptChaCha( utf8.encode(plainText) as Uint8List, @@ -71,7 +71,9 @@ class AuthenticatorService { String encryptedData = Sodium.bin2base64(encryptedKeyData.encryptedData!); String header = Sodium.bin2base64(encryptedKeyData.header!); final insertedID = await _db.insert(encryptedData, header); - unawaited(sync()); + if (shouldSync) { + unawaited(sync()); + } return insertedID; } diff --git a/lib/store/code_store.dart b/lib/store/code_store.dart index f4c418d5b..0447a1251 100644 --- a/lib/store/code_store.dart +++ b/lib/store/code_store.dart @@ -31,7 +31,10 @@ class CodeStore { return codes; } - Future addCode(Code code) async { + Future addCode( + Code code, { + bool shouldSync = true, + }) async { final codes = await getAllCodes(); for (final existingCode in codes) { if (existingCode == code) { @@ -39,7 +42,10 @@ class CodeStore { return; } } - code.id = await _authenticatorService.addEntry(jsonEncode(code.rawData)); + code.id = await _authenticatorService.addEntry( + jsonEncode(code.rawData), + shouldSync, + ); Bus.instance.fire(CodesUpdatedEvent()); }