Highlight message that was jumped to

This commit is contained in:
Sebastian Wolf 2023-12-03 00:44:17 +01:00 committed by Denis Fedoseev
parent e5d1ecd9f3
commit edfce9b492
3 changed files with 25 additions and 3 deletions

View file

@ -47,6 +47,7 @@ ListItem {
readonly property bool canDeleteMessage: myMessage.can_be_deleted_for_all_users || (myMessage.can_be_deleted_only_for_self && myMessage.chat_id === page.myUserId) readonly property bool canDeleteMessage: myMessage.can_be_deleted_for_all_users || (myMessage.can_be_deleted_only_for_self && myMessage.chat_id === page.myUserId)
property bool hasContentComponent property bool hasContentComponent
property bool additionalOptionsOpened property bool additionalOptionsOpened
property bool wasNavigatedTo: false
readonly property var additionalItemsModel: (extraContentLoader.item && ("extraContextMenuItems" in extraContentLoader.item)) ? readonly property var additionalItemsModel: (extraContentLoader.item && ("extraContextMenuItems" in extraContentLoader.item)) ?
extraContentLoader.item.extraContextMenuItems : 0 extraContentLoader.item.extraContextMenuItems : 0
@ -67,7 +68,7 @@ ListItem {
property var chatReactions property var chatReactions
property var messageReactions property var messageReactions
highlighted: (down || isSelected || additionalOptionsOpened) && !menuOpen highlighted: (down || isSelected || additionalOptionsOpened || wasNavigatedTo) && !menuOpen
openMenuOnPressAndHold: !messageListItem.precalculatedValues.pageIsSelecting openMenuOnPressAndHold: !messageListItem.precalculatedValues.pageIsSelecting
signal replyToMessage() signal replyToMessage()
@ -203,6 +204,12 @@ ListItem {
selectReactionBubble.visible = false; selectReactionBubble.visible = false;
} }
} }
onNavigatedTo: {
if (targetIndex === index) {
messageListItem.wasNavigatedTo = true;
restoreNormalityTimer.start();
}
}
} }
Loader { Loader {
@ -335,6 +342,19 @@ ListItem {
} }
} }
Timer {
id: restoreNormalityTimer
repeat: false
running: false
interval: 1000
triggeredOnStart: false
onTriggered: {
Debug.log("Restore normality for index " + index);
messageListItem.wasNavigatedTo = false;
}
}
Component.onCompleted: { Component.onCompleted: {
delegateComponentLoadingTimer.start(); delegateComponentLoadingTimer.start();
if (myMessage.reply_to_message_id) { if (myMessage.reply_to_message_id) {

View file

@ -70,6 +70,7 @@ Page {
property var availableReactions property var availableReactions
signal resetElements() signal resetElements()
signal elementSelected(int elementIndex) signal elementSelected(int elementIndex)
signal navigatedTo(int targetIndex)
states: [ states: [
State { State {
@ -420,6 +421,7 @@ Page {
if(index !== -1) { if(index !== -1) {
chatPage.messageIdToScrollTo = ""; chatPage.messageIdToScrollTo = "";
chatView.scrollToIndex(index); chatView.scrollToIndex(index);
navigatedTo(index);
} else if(initialRun) { } else if(initialRun) {
// we only want to do this once. // we only want to do this once.
chatModel.triggerLoadHistoryForMessage(chatPage.messageIdToScrollTo) chatModel.triggerLoadHistoryForMessage(chatPage.messageIdToScrollTo)

View file

@ -1601,11 +1601,11 @@
</message> </message>
<message> <message>
<source>Go to quoted message</source> <source>Go to quoted message</source>
<translation type="unfinished"></translation> <translation>Zu zitierter Nachricht springen</translation>
</message> </message>
<message> <message>
<source>When tapping a quoted message, open it in chat instead of showing it in an overlay.</source> <source>When tapping a quoted message, open it in chat instead of showing it in an overlay.</source>
<translation type="unfinished"></translation> <translation>Beim Tippen auf eine zitierte Nachricht zu dieser springen anstatt es in einem Overlay anzuzeigen.</translation>
</message> </message>
</context> </context>
<context> <context>