From fb9a1d5529a457be1202886eb705c09a075f7e9d Mon Sep 17 00:00:00 2001 From: Gabby Gurdin Date: Mon, 19 Feb 2024 13:43:41 -0500 Subject: [PATCH 1/3] don't erase already loaded rooms from space response map before loading more --- lib/pages/chat_list/space_view.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/pages/chat_list/space_view.dart b/lib/pages/chat_list/space_view.dart index 3092840ff3..4de73dcea3 100644 --- a/lib/pages/chat_list/space_view.dart +++ b/lib/pages/chat_list/space_view.dart @@ -61,7 +61,9 @@ class _SpaceViewState extends State { // Pangea# void _refresh() { - _lastResponse.remove(widget.controller.activeSpaceId); + // #Pangea + // _lastResponse.remove(widget.controller.activseSpaceId); + // Pangea# loadHierarchy(); } @@ -93,9 +95,13 @@ class _SpaceViewState extends State { ); if (prevBatch != null) { + debugPrint( + "Adding ${_lastResponse[activeSpaceId]?.rooms} to ${response.rooms}", + ); response.rooms.insertAll(0, _lastResponse[activeSpaceId]?.rooms ?? []); } setState(() { + debugPrint("Setting state response to ${response.rooms}"); _lastResponse[activeSpaceId] = response; }); return _lastResponse[activeSpaceId]!; @@ -526,6 +532,7 @@ class _SpaceViewState extends State { Builder( builder: (context) { final response = _lastResponse[activeSpaceId]; + debugPrint('building space view wth response: $response'); final error = this.error; if (error != null) { return SliverFillRemaining( From e39b19877f2b680181adb9fc92af94171549824a Mon Sep 17 00:00:00 2001 From: Gabby Gurdin Date: Mon, 19 Feb 2024 13:48:17 -0500 Subject: [PATCH 2/3] remove debug print statements --- lib/pages/chat_list/space_view.dart | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/pages/chat_list/space_view.dart b/lib/pages/chat_list/space_view.dart index 4de73dcea3..8e499deb8d 100644 --- a/lib/pages/chat_list/space_view.dart +++ b/lib/pages/chat_list/space_view.dart @@ -95,13 +95,9 @@ class _SpaceViewState extends State { ); if (prevBatch != null) { - debugPrint( - "Adding ${_lastResponse[activeSpaceId]?.rooms} to ${response.rooms}", - ); response.rooms.insertAll(0, _lastResponse[activeSpaceId]?.rooms ?? []); } setState(() { - debugPrint("Setting state response to ${response.rooms}"); _lastResponse[activeSpaceId] = response; }); return _lastResponse[activeSpaceId]!; @@ -532,7 +528,6 @@ class _SpaceViewState extends State { Builder( builder: (context) { final response = _lastResponse[activeSpaceId]; - debugPrint('building space view wth response: $response'); final error = this.error; if (error != null) { return SliverFillRemaining( From d8927b606dd881bec487447850e4175df952ab8c Mon Sep 17 00:00:00 2001 From: Gabby Gurdin Date: Mon, 19 Feb 2024 14:01:45 -0500 Subject: [PATCH 3/3] replace error popup with scaffold message --- lib/utils/error_reporter.dart | 126 +++++++++++++++++----------------- 1 file changed, 62 insertions(+), 64 deletions(-) diff --git a/lib/utils/error_reporter.dart b/lib/utils/error_reporter.dart index cd051abbdc..2449761c34 100644 --- a/lib/utils/error_reporter.dart +++ b/lib/utils/error_reporter.dart @@ -1,17 +1,6 @@ -import 'dart:io'; - -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; - import 'package:flutter_gen/gen_l10n/l10n.dart'; -import 'package:flutter_highlighter/flutter_highlighter.dart'; -import 'package:flutter_highlighter/themes/shades-of-purple.dart'; import 'package:matrix/matrix.dart'; -import 'package:url_launcher/url_launcher.dart'; - -import 'package:fluffychat/config/app_config.dart'; -import 'package:fluffychat/utils/platform_infos.dart'; class ErrorReporter { final BuildContext context; @@ -21,63 +10,72 @@ class ErrorReporter { void onErrorCallback(Object error, [StackTrace? stackTrace]) async { Logs().e(message ?? 'Error caught', error, stackTrace); - final text = '$error\n${stackTrace ?? ''}'; - final consent = 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, - ), - ), + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + L10n.of(context)!.oopsSomethingWentWrong, ), - actions: [ - TextButton( - onPressed: () => Navigator.of(context).pop(false), - child: Text(L10n.of(context)!.close), - ), - TextButton( - onPressed: () => Clipboard.setData( - ClipboardData(text: text), - ), - child: Text(L10n.of(context)!.copy), - ), - TextButton( - onPressed: () => Navigator.of(context).pop(true), - child: Text(L10n.of(context)!.report), - ), - ], ), ); - if (consent != true) return; - final os = kIsWeb ? 'web' : Platform.operatingSystem; - final version = await PlatformInfos.getVersion(); - final description = ''' -- Operating system: $os -- Version: $version + // #Pangea +// final text = '$error\n${stackTrace ?? ''}'; +// final consent = 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(false), +// child: Text(L10n.of(context)!.close), +// ), +// TextButton( +// onPressed: () => Clipboard.setData( +// ClipboardData(text: text), +// ), +// child: Text(L10n.of(context)!.copy), +// ), +// TextButton( +// onPressed: () => Navigator.of(context).pop(true), +// child: Text(L10n.of(context)!.report), +// ), +// ], +// ), +// ); +// if (consent != true) return; +// final os = kIsWeb ? 'web' : Platform.operatingSystem; +// final version = await PlatformInfos.getVersion(); +// final description = ''' +// - Operating system: $os +// - Version: $version -### Exception -$error +// ### Exception +// $error -### StackTrace -${stackTrace?.toString().split('\n').take(10).join('\n')} -'''; - launchUrl( - AppConfig.newIssueUrl.resolveUri( - Uri( - queryParameters: { - 'title': '[BUG]: ${message ?? error.toString()}', - 'body': description, - }, - ), - ), - mode: LaunchMode.externalApplication, - ); +// ### StackTrace +// ${stackTrace?.toString().split('\n').take(10).join('\n')} +// '''; +// launchUrl( +// AppConfig.newIssueUrl.resolveUri( +// Uri( +// queryParameters: { +// 'title': '[BUG]: ${message ?? error.toString()}', +// 'body': description, +// }, +// ), +// ), +// mode: LaunchMode.externalApplication, +// ); +// Pangea# } }