fix: Try to reload timeline on IOException

pull/444/head
Krille 2 years ago
parent f10e56e674
commit 3856745ce4

@ -290,7 +290,7 @@ class ChatController extends State<ChatPageWithRoom> {
Future<void> _getTimeline({ Future<void> _getTimeline({
String? eventContextId, String? eventContextId,
Duration timeout = const Duration(seconds: 5), Duration timeout = const Duration(seconds: 7),
}) async { }) async {
await Matrix.of(context).client.roomsLoading; await Matrix.of(context).client.roomsLoading;
await Matrix.of(context).client.accountDataLoading; await Matrix.of(context).client.accountDataLoading;
@ -305,10 +305,12 @@ class ChatController extends State<ChatPageWithRoom> {
eventContextId: eventContextId, eventContextId: eventContextId,
) )
.timeout(timeout); .timeout(timeout);
} on TimeoutException catch (_) { } catch (e, s) {
Logs().w('Unable to load timeline on event ID $eventContextId', e, s);
if (!mounted) return; if (!mounted) return;
timeline = await room.getTimeline(onUpdate: updateView); timeline = await room.getTimeline(onUpdate: updateView);
if (!mounted) return; if (!mounted) return;
if (e is TimeoutException || e is IOException) {
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: Text(L10n.of(context)!.jumpToLastReadMessage), content: Text(L10n.of(context)!.jumpToLastReadMessage),
@ -319,6 +321,7 @@ class ChatController extends State<ChatPageWithRoom> {
), ),
); );
} }
}
timeline!.requestKeys(onlineKeyBackupOnly: false); timeline!.requestKeys(onlineKeyBackupOnly: false);
if (timeline!.events.isNotEmpty) { if (timeline!.events.isNotEmpty) {
if (room.markedUnread) room.markUnread(false); if (room.markedUnread) room.markUnread(false);

Loading…
Cancel
Save