Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F106462
D80.1730811310.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D80.1730811310.diff
View Options
diff --git a/src/contents/ui/EventView.qml b/src/contents/ui/EventView.qml
--- a/src/contents/ui/EventView.qml
+++ b/src/contents/ui/EventView.qml
@@ -30,11 +30,10 @@
property var senderNameSize: Kirigami.Units.gridUnit * 1.2
property var redactPromise: null
- property var minHeight: Kirigami.Units.gridUnit * 2
property var isGapped: false
property var compactMode: false
- property var calculatedHeight: (gappedLabel.visible ? gappedLabel.height : 0) + (loader.item ? loader.item.implicitHeight : 0)
+ property var calculatedHeight: (loader.item ? loader.item.implicitHeight : 0)
height: calculatedHeight
implicitHeight: calculatedHeight
@@ -147,24 +146,12 @@
}
}
- ToolButton {
- id: gappedLabel
- visible: eventView.isGapped && !eventView.compactMode
- icon.name: 'content-loading-symbolic'
- text: l10n.get('room-timeline-load-more-action')
- anchors.top: eventView.top
- anchors.bottom: loader.top
- anchors.left: eventView.left
- anchors.right: eventView.right
- onClicked: eventView.paginateBack()
- }
-
Loader {
sourceComponent: getSource(messageType)
id: loader
anchors.left: eventView.left
anchors.right: eventView.right
- anchors.bottom: eventView.bottom
+ anchors.top: eventView.top
}
function getSource(t) {
@@ -283,10 +270,27 @@
}
function paginateBack() {
- room.paginateBackFrom(event.eventId);
+ paginateBackRequested(event.eventId);
}
function reactWith(reactionText) {
room.sendReaction(reactionText, event.eventId);
}
+
+ onIsGappedChanged: maybePaginateBack()
+ onEventChanged: maybePaginateBack()
+ Component.onCompleted: maybePaginateBack()
+ Connections {
+ target: eventView.event
+
+ function onEventIdChanged() {
+ eventView.maybePaginateBack();
+ }
+ }
+
+ function maybePaginateBack() {
+ if (isGapped) {
+ paginateBack();
+ }
+ }
}
diff --git a/src/contents/ui/RoomPage.qml b/src/contents/ui/RoomPage.qml
--- a/src/contents/ui/RoomPage.qml
+++ b/src/contents/ui/RoomPage.qml
@@ -24,9 +24,11 @@
}
property var roomTimeline: room.timeline()
property var lastReceiptableEventId: getLastReceiptableEventId(roomTimeline, roomTimeline.count)
+ property var paginationRequests: ({})
signal mentionUserRequested(string userId)
signal replaceDraftRequested(string newDraft)
+ signal paginateBackRequested(string eventId)
title: roomNameProvider.name
@@ -206,4 +208,17 @@
roomPage.room.postReadReceipt(eventId);
}
}
+
+ onPaginateBackRequested: (eventId) => {
+ if (!paginationRequests[eventId]) {
+ console.debug('paginating back from', eventId);
+ paginationRequests[eventId] = room.paginateBackFrom(eventId);
+ paginationRequests[eventId].resolved.connect(() => {
+ console.debug('finished paginating back from', eventId);
+ delete paginationRequests[eventId];
+ });
+ } else {
+ console.debug('pagination request of', eventId, 'is already under way');
+ }
+ }
}
diff --git a/src/tests/quick-tests/tst_EventView.qml b/src/tests/quick-tests/tst_EventView.qml
--- a/src/tests/quick-tests/tst_EventView.qml
+++ b/src/tests/quick-tests/tst_EventView.qml
@@ -22,6 +22,7 @@
property var mockHelper: TestHelpers.MockHelper {}
property var activateUserPage: mockHelper.noop()
+ property var paginateBackRequested: mockHelper.noop()
property var timeline: ({
gaps: [],
@@ -227,6 +228,25 @@
avatarMxcUri: '',
})
+ property var eventViewComp: Component {
+ Kazv.EventView {
+ Layout.fillWidth: true
+ event: QtObject {
+ property var eventId: '$some-event-id'
+ function readers() { return 0; }
+ }
+ sender: item.sender
+ isGapped: true
+ }
+ }
+
+ property var eventComp: Component {
+ QtObject {
+ property var eventId: '$some-event-id'
+ function readers() { return 0; }
+ }
+ }
+
ColumnLayout {
anchors.fill: parent
Kazv.EventView {
@@ -493,5 +513,26 @@
const name = findChild(eventViewTextBySomeoneElse, 'userNicknameText');
compare(name.text, 'bar');
}
+
+ function test_paginateBack() {
+ const obj = item.eventViewComp.createObject(item);
+ tryVerify(() => item.paginateBackRequested.calledTimes());
+ verify(item.paginateBackRequested.lastArgs()[0] === '$some-event-id');
+
+ item.paginateBackRequested.clear();
+ obj.event.eventId = '$some-other-event-id';
+ tryVerify(() => item.paginateBackRequested.calledTimes() === 1);
+ verify(item.paginateBackRequested.lastArgs()[0] === '$some-other-event-id');
+
+ item.paginateBackRequested.clear();
+ const newEvent = eventComp.createObject(item);
+ obj.event = newEvent;
+ tryVerify(() => item.paginateBackRequested.calledTimes() === 1);
+ verify(item.paginateBackRequested.lastArgs()[0] === '$some-event-id');
+
+ item.paginateBackRequested.clear();
+ obj.isGapped = false;
+ verify(item.paginateBackRequested.calledTimes() === 0);
+ }
}
}
diff --git a/src/tests/quick-tests/tst_RoomPage.qml b/src/tests/quick-tests/tst_RoomPage.qml
--- a/src/tests/quick-tests/tst_RoomPage.qml
+++ b/src/tests/quick-tests/tst_RoomPage.qml
@@ -19,6 +19,7 @@
width: 800
height: 600
+ property var mockHelper: TestHelpers.MockHelper {}
property var roomTimeline: QtObject {
property var count: 5
function at(i) {
@@ -49,6 +50,7 @@
property var roomJoin: Helpers.factory.room({
membership: MK.MatrixRoom.Join,
+ paginateBackFrom: mockHelper.promise(),
})
property var roomLeave: Helpers.factory.room({
@@ -83,6 +85,10 @@
name: 'RoomPageTest'
when: windowShown
+ function init() {
+ mockHelper.clearAll();
+ }
+
function test_inviteRoom() {
const sendMessageBox = findChild(pageInvite, 'sendMessageBox');
verify(sendMessageBox);
@@ -104,5 +110,23 @@
function test_receiptableEventId() {
verify(pageJoin.getLastReceiptableEventId(item.roomTimeline, item.roomTimeline.count) === '$event3');
}
+
+ function test_paginateBack() {
+ pageJoin.paginateBackRequested('$1');
+ tryVerify(() => roomJoin.paginateBackFrom.calledTimes() === 1);
+ verify(roomJoin.paginateBackFrom.lastArgs()[0] === '$1');
+ // one pagination under way, do not call it twice
+ pageJoin.paginateBackRequested('$1');
+ verify(roomJoin.paginateBackFrom.calledTimes() === 1);
+ // paginating from another event is not affected
+ pageJoin.paginateBackRequested('$2');
+ tryVerify(() => roomJoin.paginateBackFrom.calledTimes() === 2);
+ verify(roomJoin.paginateBackFrom.lastArgs()[0] === '$2');
+ // after the promise resolves, we can paginate from this id again
+ roomJoin.paginateBackFrom.retVals[0].resolve(true);
+ pageJoin.paginateBackRequested('$1');
+ tryVerify(() => roomJoin.paginateBackFrom.calledTimes() === 3);
+ verify(roomJoin.paginateBackFrom.lastArgs()[0] === '$1');
+ }
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 5, 4:55 AM (8 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34734
Default Alt Text
D80.1730811310.diff (6 KB)
Attached To
Mode
D80: Paginate back from gaps automatically
Attached
Detach File
Event Timeline
Log In to Comment