Improve the behaviour of jump to last unread message.
Improve the behaviour of jump to last unread message. The view will now jump as high as possible if the last unread message isn't loaded. This at least triggers more items to load which will eventually get the user to the last unread message.
This commit is contained in:
@@ -69,7 +69,7 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
|
||||
setHasFileUploading(false);
|
||||
});
|
||||
|
||||
connect(this, &Room::aboutToAddHistoricalMessages, this, &NeoChatRoom::readMarkerLoadedChanged);
|
||||
connect(this, &Room::addedMessages, this, &NeoChatRoom::readMarkerLoadedChanged);
|
||||
|
||||
const auto &roomLastMessageProvider = RoomLastMessageProvider::self();
|
||||
|
||||
|
||||
@@ -190,12 +190,15 @@ QQC2.ScrollView {
|
||||
implicitHeight: Kirigami.Units.gridUnit * 2
|
||||
|
||||
z: 2
|
||||
visible: root.currentRoom && root.currentRoom.hasUnreadMessages && root.currentRoom.readMarkerLoaded
|
||||
visible: root.currentRoom && root.currentRoom.hasUnreadMessages
|
||||
|
||||
text: root.currentRoom.readMarkerLoaded ? i18n("Jump to first unread message") : i18n("Jump to oldest loaded message")
|
||||
action: Kirigami.Action {
|
||||
onTriggered: {
|
||||
if (!Kirigami.Settings.isMobile) {
|
||||
root.focusChatBar();
|
||||
}
|
||||
goReadMarkerFab.textChanged()
|
||||
messageListView.goToEvent(root.currentRoom.readMarkerEventId);
|
||||
}
|
||||
icon.name: "go-up"
|
||||
@@ -203,7 +206,10 @@ QQC2.ScrollView {
|
||||
}
|
||||
|
||||
QQC2.ToolTip {
|
||||
text: i18n("Jump to first unread message")
|
||||
id: goReadMarkerFabTooltip
|
||||
text: goReadMarkerFab.text
|
||||
delay: Kirigami.Units.toolTipDelay
|
||||
visible: goReadMarkerFab.hovered
|
||||
}
|
||||
}
|
||||
KirigamiComponents.FloatingButton {
|
||||
@@ -274,6 +280,10 @@ QQC2.ScrollView {
|
||||
|
||||
function goToEvent(eventID) {
|
||||
const index = eventToIndex(eventID);
|
||||
if (index == -1) {
|
||||
messageListView.positionViewAtEnd();
|
||||
return;
|
||||
}
|
||||
messageListView.positionViewAtIndex(index, ListView.Center);
|
||||
itemAtIndex(index).isTemporaryHighlighted = true;
|
||||
}
|
||||
|
||||
@@ -10,22 +10,22 @@ import org.kde.kirigami as Kirigami
|
||||
|
||||
TimelineDelegate {
|
||||
id: root
|
||||
|
||||
property bool isTemporaryHighlighted: false
|
||||
onIsTemporaryHighlightedChanged: if (isTemporaryHighlighted) {
|
||||
temporaryHighlightTimer.start();
|
||||
}
|
||||
|
||||
contentItem: QQC2.ItemDelegate {
|
||||
padding: Kirigami.Units.largeSpacing
|
||||
topInset: Kirigami.Units.largeSpacing
|
||||
topPadding: Kirigami.Units.largeSpacing * 2
|
||||
|
||||
property bool isTemporaryHighlighted: false
|
||||
|
||||
onIsTemporaryHighlightedChanged: if (isTemporaryHighlighted) {
|
||||
temporaryHighlightTimer.start();
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: temporaryHighlightTimer
|
||||
|
||||
interval: 1500
|
||||
onTriggered: isTemporaryHighlighted = false
|
||||
onTriggered: root.isTemporaryHighlighted = false
|
||||
}
|
||||
|
||||
contentItem: QQC2.Label {
|
||||
|
||||
Reference in New Issue
Block a user