From 49c1736f7c3608bd804bd634c289cd8736b9a3ee Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Mon, 24 May 2021 16:48:05 +0200 Subject: [PATCH] Make sure message are loaded when scrolling to the top --- imports/NeoChat/Page/RoomPage.qml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/imports/NeoChat/Page/RoomPage.qml b/imports/NeoChat/Page/RoomPage.qml index ad53aa1e7..645b8cdf5 100644 --- a/imports/NeoChat/Page/RoomPage.qml +++ b/imports/NeoChat/Page/RoomPage.qml @@ -237,6 +237,18 @@ Kirigami.ScrollablePage { room: currentRoom } + Timer { + interval: 1000 + running: messageListView.atYBeginning + triggeredOnStart: true + onTriggered: { + if (messageListView.atYBeginning && messageEventModel.canFetchMore(messageEventModel.index(0, 0))) { + messageEventModel.fetchMore(messageEventModel.index(0, 0)); + } + } + repeat: true + } + // HACK: The view should do this automatically but doesn't. onAtYBeginningChanged: if (atYBeginning && messageEventModel.canFetchMore(messageEventModel.index(0, 0))) { messageEventModel.fetchMore(messageEventModel.index(0, 0));