From baeb47f94bc1d01da9c9f42683d39bfabbbc7101 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Fri, 13 Sep 2024 09:21:19 +0530 Subject: [PATCH] [auth] Ignore exception during os share --- auth/lib/ui/share/code_share.dart | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/auth/lib/ui/share/code_share.dart b/auth/lib/ui/share/code_share.dart index 2e6875b0cd..43ecd34ff3 100644 --- a/auth/lib/ui/share/code_share.dart +++ b/auth/lib/ui/share/code_share.dart @@ -115,16 +115,15 @@ class _ShareCodeDialogState extends State { 'step': widget.code.period, 'codes': result.$2.join(","), }; + final Uint8List key = _generate256BitKey(); + Uint8List input = utf8.encode(jsonEncode(data)); + final encResult = await CryptoUtil.encryptData(input, key); + String url = + 'https://auth.ente.io/share?data=${_uint8ListToUrlSafeBase64(encResult.encryptedData!)}&header=${_uint8ListToUrlSafeBase64(encResult.header!)}#${_uint8ListToUrlSafeBase64(key)}'; try { - final Uint8List key = _generate256BitKey(); - Uint8List input = utf8.encode(jsonEncode(data)); - final encResult = await CryptoUtil.encryptData(input, key); - String url = - 'https://auth.ente.io/share?data=${_uint8ListToUrlSafeBase64(encResult.encryptedData!)}&header=${_uint8ListToUrlSafeBase64(encResult.header!)}#${_uint8ListToUrlSafeBase64(key)}'; - shareText(url, context: context).ignore(); + await shareText(url, context: context); } catch (e) { - logger.severe('Failed to encrypt data: ${e.toString()}'); - await showGenericErrorDialog(context: context, error: e); + logger.warning('Failed to share code: ${e.toString()}'); } }