From b5bd752855b32be5e5902dbb21cfbe321f8a0047 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Sun, 1 Mar 2026 14:47:57 -0500 Subject: [PATCH] nicer automatic loadOlder handling --- lib/controllers/room_chat_controller.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/controllers/room_chat_controller.dart b/lib/controllers/room_chat_controller.dart index 02ad366..e7851f1 100644 --- a/lib/controllers/room_chat_controller.dart +++ b/lib/controllers/room_chat_controller.dart @@ -133,8 +133,9 @@ class RoomChatController extends AsyncNotifier { ref.onDispose(controller.dispose); - for (final _ in List.filled(2, null)) { - if (messages.length < 20) await loadOlder(controller); + // While there are under 20 messages, try up to two times to load more messages. + for (var i = 0; i < 2 && messages.length < 20; i++) { + await loadOlder(controller); } return controller;