From 44d7f61788ab6a33d42fb81f6b947b9d60158a6f Mon Sep 17 00:00:00 2001 From: Krille Date: Wed, 31 May 2023 09:22:14 +0200 Subject: [PATCH] fix: Try to reload timeline on IOException --- lib/pages/chat/chat.dart | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index fe5f139a..37e127b3 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -290,7 +290,7 @@ class ChatController extends State { Future _getTimeline({ String? eventContextId, - Duration timeout = const Duration(seconds: 5), + Duration timeout = const Duration(seconds: 7), }) async { await Matrix.of(context).client.roomsLoading; await Matrix.of(context).client.accountDataLoading; @@ -305,19 +305,22 @@ class ChatController extends State { eventContextId: eventContextId, ) .timeout(timeout); - } on TimeoutException catch (_) { + } catch (e, s) { + Logs().w('Unable to load timeline on event ID $eventContextId', e, s); if (!mounted) return; timeline = await room.getTimeline(onUpdate: updateView); if (!mounted) return; - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text(L10n.of(context)!.jumpToLastReadMessage), - action: SnackBarAction( - label: L10n.of(context)!.jump, - onPressed: () => scrollToEventId(eventContextId!), + if (e is TimeoutException || e is IOException) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(L10n.of(context)!.jumpToLastReadMessage), + action: SnackBarAction( + label: L10n.of(context)!.jump, + onPressed: () => scrollToEventId(eventContextId!), + ), ), - ), - ); + ); + } } timeline!.requestKeys(onlineKeyBackupOnly: false); if (timeline!.events.isNotEmpty) {