From a5cdafcb659d0f03ffa1658ff09e1d40063fa4bc Mon Sep 17 00:00:00 2001 From: bluearevalo <90929912+bluearevalo@users.noreply.github.com> Date: Wed, 10 Jul 2024 13:24:13 -0400 Subject: [PATCH 1/8] Added null checks, error handling, and used non-null version of l10n --- lib/utils/error_reporter.dart | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/utils/error_reporter.dart b/lib/utils/error_reporter.dart index f3b3bfabdb..76e39c193e 100644 --- a/lib/utils/error_reporter.dart +++ b/lib/utils/error_reporter.dart @@ -9,15 +9,26 @@ class ErrorReporter { const ErrorReporter(this.context, [this.message]); void onErrorCallback(Object error, [StackTrace? stackTrace]) async { - Logs().e(message ?? 'Error caught', error, stackTrace); - // #Pangea - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - L10n.of(context)!.oopsSomethingWentWrong, - ), + Logs().e(message ?? 'Error caught', error, stackTrace); + // #Pangea + // Attempt to retrieve the L10n instance using the current context + final L10n? l10n = L10n.of(context); + + // Check if the L10n instance is null + if (l10n == null) { + // Log an error message saying that the localization object is null + Logs().e('Localization object is null, cannot show error message.'); + // Exits early to prevent further execution + return; + } + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + l10n.oopsSomethingWentWrong, // Use the non-null L10n instance to get the error message ), - ); + ), + ); +} // final text = '$error\n${stackTrace ?? ''}'; // await showAdaptiveDialog( // context: context, @@ -64,4 +75,4 @@ class ErrorReporter { // ); // Pangea# } -} + From 425b7ddcf12b85611d0edaf14f94f2509f5bfb88 Mon Sep 17 00:00:00 2001 From: bluearevalo <90929912+bluearevalo@users.noreply.github.com> Date: Wed, 10 Jul 2024 13:37:39 -0400 Subject: [PATCH 2/8] oops formatting fix --- lib/utils/error_reporter.dart | 127 +++++++++++++++++----------------- 1 file changed, 63 insertions(+), 64 deletions(-) diff --git a/lib/utils/error_reporter.dart b/lib/utils/error_reporter.dart index 76e39c193e..d44b48dcb7 100644 --- a/lib/utils/error_reporter.dart +++ b/lib/utils/error_reporter.dart @@ -9,70 +9,69 @@ class ErrorReporter { const ErrorReporter(this.context, [this.message]); void onErrorCallback(Object error, [StackTrace? stackTrace]) async { - Logs().e(message ?? 'Error caught', error, stackTrace); - // #Pangea - // Attempt to retrieve the L10n instance using the current context - final L10n? l10n = L10n.of(context); + Logs().e(message ?? 'Error caught', error, stackTrace); + // #Pangea + // Attempt to retrieve the L10n instance using the current context + final L10n? l10n = L10n.of(context); - // Check if the L10n instance is null - if (l10n == null) { - // Log an error message saying that the localization object is null - Logs().e('Localization object is null, cannot show error message.'); - // Exits early to prevent further execution - return; - } - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text( - l10n.oopsSomethingWentWrong, // Use the non-null L10n instance to get the error message + // Check if the L10n instance is null + if (l10n == null) { + // Log an error message saying that the localization object is null + Logs().e('Localization object is null, cannot show error message.'); + // Exits early to prevent further execution + return; + } + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + l10n.oopsSomethingWentWrong, // Use the non-null L10n instance to get the error message + ), ), - ), - ); -} - // final text = '$error\n${stackTrace ?? ''}'; - // await showAdaptiveDialog( - // context: context, - // builder: (context) => AlertDialog.adaptive( - // title: Text(L10n.of(context)!.reportErrorDescription), - // content: SizedBox( - // height: 256, - // width: 256, - // child: SingleChildScrollView( - // child: HighlightView( - // text, - // language: 'sh', - // theme: shadesOfPurpleTheme, - // ), - // ), - // ), - // actions: [ - // TextButton( - // onPressed: () => Navigator.of(context).pop(), - // child: Text(L10n.of(context)!.close), - // ), - // TextButton( - // onPressed: () => Clipboard.setData( - // ClipboardData(text: text), - // ), - // child: Text(L10n.of(context)!.copy), - // ), - // TextButton( - // onPressed: () => launchUrl( - // AppConfig.newIssueUrl.resolveUri( - // Uri( - // queryParameters: { - // 'template': 'bug_report.yaml', - // 'title': '[BUG]: ${message ?? error.toString()}', - // }, - // ), - // ), - // mode: LaunchMode.externalApplication, - // ), - // child: Text(L10n.of(context)!.report), - // ), - // ], - // ), - // ); - // Pangea# + ); } - + // final text = '$error\n${stackTrace ?? ''}'; + // await showAdaptiveDialog( + // context: context, + // builder: (context) => AlertDialog.adaptive( + // title: Text(L10n.of(context)!.reportErrorDescription), + // content: SizedBox( + // height: 256, + // width: 256, + // child: SingleChildScrollView( + // child: HighlightView( + // text, + // language: 'sh', + // theme: shadesOfPurpleTheme, + // ), + // ), + // ), + // actions: [ + // TextButton( + // onPressed: () => Navigator.of(context).pop(), + // child: Text(L10n.of(context)!.close), + // ), + // TextButton( + // onPressed: () => Clipboard.setData( + // ClipboardData(text: text), + // ), + // child: Text(L10n.of(context)!.copy), + // ), + // TextButton( + // onPressed: () => launchUrl( + // AppConfig.newIssueUrl.resolveUri( + // Uri( + // queryParameters: { + // 'template': 'bug_report.yaml', + // 'title': '[BUG]: ${message ?? error.toString()}', + // }, + // ), + // ), + // mode: LaunchMode.externalApplication, + // ), + // child: Text(L10n.of(context)!.report), + // ), + // ], + // ), + // ); + // Pangea# +} From 5494019be5407fa720dd54186ef87b5d6d1b252a Mon Sep 17 00:00:00 2001 From: bluearevalo <90929912+bluearevalo@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:47:22 -0400 Subject: [PATCH 3/8] set max char size for input field --- lib/pages/chat/input_bar.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pages/chat/input_bar.dart b/lib/pages/chat/input_bar.dart index a02626978b..04d1be9db3 100644 --- a/lib/pages/chat/input_bar.dart +++ b/lib/pages/chat/input_bar.dart @@ -490,8 +490,10 @@ class InputBar extends StatelessWidget { keyboardType: keyboardType!, textInputAction: textInputAction, autofocus: autofocus!, + //setting max character count to 1000 + //after max, nothing else can be typed inputFormatters: [ - LengthLimitingTextInputFormatter((maxPDUSize / 3).floor()), + LengthLimitingTextInputFormatter(1000), ], onSubmitted: (text) { // fix for library for now From 35434b09d1b389f8f4bcf7cd2d458f832aa96769 Mon Sep 17 00:00:00 2001 From: bluearevalo <90929912+bluearevalo@users.noreply.github.com> Date: Fri, 12 Jul 2024 11:14:00 -0400 Subject: [PATCH 4/8] Add mounted check to prevent updates on unmounted widgets --- lib/pangea/widgets/chat/message_toolbar.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/pangea/widgets/chat/message_toolbar.dart b/lib/pangea/widgets/chat/message_toolbar.dart index 8d2d66b7d6..e10d637e04 100644 --- a/lib/pangea/widgets/chat/message_toolbar.dart +++ b/lib/pangea/widgets/chat/message_toolbar.dart @@ -194,6 +194,8 @@ class MessageToolbarState extends State { late StreamSubscription toolbarModeStream; void updateMode(MessageMode newMode) { + //Early exit from the function if the widget has been unmounted to prevent updates on an inactive widget. + if (!mounted) return; if (updatingMode) return; debugPrint("updating toolbar mode"); final bool subscribed = @@ -347,6 +349,7 @@ class MessageToolbarState extends State { Timer? timer; selectionStream = widget.textSelection.selectionStream.stream.listen((value) { + //talk about this timer?.cancel(); timer = Timer(const Duration(milliseconds: 500), () { if (value != null && value.isNotEmpty) { From 5f59a39c72c5f5378c44391daf3439e0df217003 Mon Sep 17 00:00:00 2001 From: bluearevalo <90929912+bluearevalo@users.noreply.github.com> Date: Fri, 12 Jul 2024 11:16:37 -0400 Subject: [PATCH 5/8] removed comment --- lib/pangea/widgets/chat/message_toolbar.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pangea/widgets/chat/message_toolbar.dart b/lib/pangea/widgets/chat/message_toolbar.dart index e10d637e04..f06b9d1b48 100644 --- a/lib/pangea/widgets/chat/message_toolbar.dart +++ b/lib/pangea/widgets/chat/message_toolbar.dart @@ -349,7 +349,6 @@ class MessageToolbarState extends State { Timer? timer; selectionStream = widget.textSelection.selectionStream.stream.listen((value) { - //talk about this timer?.cancel(); timer = Timer(const Duration(milliseconds: 500), () { if (value != null && value.isNotEmpty) { From bb32f584f4295c6f2b1baf0759017a6e3c9044f7 Mon Sep 17 00:00:00 2001 From: bluearevalo <90929912+bluearevalo@users.noreply.github.com> Date: Fri, 12 Jul 2024 12:48:12 -0400 Subject: [PATCH 6/8] Fixed background for login view --- .../pages/p_user_age/p_user_age_view.dart | 51 +++++++------------ 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/lib/pangea/pages/p_user_age/p_user_age_view.dart b/lib/pangea/pages/p_user_age/p_user_age_view.dart index 1438cf0fe2..6930999949 100644 --- a/lib/pangea/pages/p_user_age/p_user_age_view.dart +++ b/lib/pangea/pages/p_user_age/p_user_age_view.dart @@ -17,32 +17,25 @@ class PUserAgeView extends StatelessWidget { ), body: ListView( children: [ - Container( - margin: const EdgeInsets.only(top: 10), - padding: const EdgeInsets.all(15), - child: Text( - L10n.of(context)!.yourBirthdayPlease, - textAlign: TextAlign.justify, - style: const TextStyle( - color: Colors.black, - fontSize: 14, - fontWeight: FontWeight.bold, - ), - ), - ), - const SizedBox( - height: 10, - ), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), - color: Theme.of(context) - .colorScheme - .onSecondaryContainer - .withAlpha(50), + color: Theme.of(context).colorScheme.onSecondaryContainer.withAlpha(50), ), child: Column( children: [ + Padding( + padding: const EdgeInsets.all(15), + child: Text( + L10n.of(context)!.yourBirthdayPlease, + textAlign: TextAlign.justify, + style: const TextStyle( + color: Colors.black, + fontSize: 14, + fontWeight: FontWeight.normal, + ), + ), + ), ListTile( title: Text( L10n.of(context)!.certifyAge(13), @@ -70,23 +63,16 @@ class PUserAgeView extends StatelessWidget { ], ), ), - const SizedBox( - height: 10, - ), - if (controller.error != null) - Padding( - padding: const EdgeInsets.all(12), - child: Text( - controller.error!, - style: const TextStyle(color: Colors.white), - ), - ), + const SizedBox(height: 20), Hero( tag: 'loginButton', child: Padding( - padding: const EdgeInsets.all(12), + padding: const EdgeInsets.symmetric(horizontal: 12), child: ElevatedButton( onPressed: controller.createUserInPangea, + style: ElevatedButton.styleFrom( + minimumSize: const Size.fromHeight(50), + ), child: controller.loading ? const LinearProgressIndicator() : Text(L10n.of(context)!.getStarted), @@ -95,7 +81,6 @@ class PUserAgeView extends StatelessWidget { ), ], ), - // ), ); } } From e6fa69df3910d9f77c671a4159e5dc753ed3634e Mon Sep 17 00:00:00 2001 From: bluearevalo <90929912+bluearevalo@users.noreply.github.com> Date: Mon, 15 Jul 2024 15:28:16 -0400 Subject: [PATCH 7/8] add back #pangea comment tags --- lib/pages/chat/input_bar.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/pages/chat/input_bar.dart b/lib/pages/chat/input_bar.dart index 04d1be9db3..9337b488a6 100644 --- a/lib/pages/chat/input_bar.dart +++ b/lib/pages/chat/input_bar.dart @@ -490,10 +490,13 @@ class InputBar extends StatelessWidget { keyboardType: keyboardType!, textInputAction: textInputAction, autofocus: autofocus!, - //setting max character count to 1000 - //after max, nothing else can be typed inputFormatters: [ + //#Pangea + //LengthLimitingTextInputFormatter((maxPDUSize / 3).floor()), + //setting max character count to 1000 + //after max, nothing else can be typed LengthLimitingTextInputFormatter(1000), + //Pangea# ], onSubmitted: (text) { // fix for library for now From 057f07d2104d8d9e003644fb67d517a23dd29848 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Tue, 16 Jul 2024 10:04:34 -0400 Subject: [PATCH 8/8] removed debugger statement from my_analytics_controller update function - not an error state --- lib/pangea/controllers/my_analytics_controller.dart | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/pangea/controllers/my_analytics_controller.dart b/lib/pangea/controllers/my_analytics_controller.dart index 058bad3595..12baeb689e 100644 --- a/lib/pangea/controllers/my_analytics_controller.dart +++ b/lib/pangea/controllers/my_analytics_controller.dart @@ -229,11 +229,8 @@ class MyAnalyticsController { /// top level analytics sending function. Gather recent messages and activity records, /// convert them into the correct formats, and send them to the analytics room Future _updateAnalytics() async { - // if missing important info, don't send analytics - if (userL2 == null || _client.userID == null) { - debugger(when: kDebugMode); - return; - } + // if missing important info, don't send analytics. Could happen if user just signed up. + if (userL2 == null || _client.userID == null) return; // analytics room for the user and current target language final Room analyticsRoom = await _client.getMyAnalyticsRoom(userL2!);