From 4ed949537605cf329288ef2208740bcd8b3606eb Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Sun, 3 Dec 2023 00:44:17 +0100 Subject: [PATCH] Highlight message that was jumped to --- qml/components/MessageListViewItem.qml | 22 +++++++++++++++++++++- qml/pages/ChatPage.qml | 2 ++ translations/harbour-fernschreiber-de.ts | 4 ++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 9baf0c17..523f74c4 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -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) property bool hasContentComponent property bool additionalOptionsOpened + property bool wasNavigatedTo: false readonly property var additionalItemsModel: (extraContentLoader.item && ("extraContextMenuItems" in extraContentLoader.item)) ? extraContentLoader.item.extraContextMenuItems : 0 @@ -67,7 +68,7 @@ ListItem { property var chatReactions property var messageReactions - highlighted: (down || isSelected || additionalOptionsOpened) && !menuOpen + highlighted: (down || isSelected || additionalOptionsOpened || wasNavigatedTo) && !menuOpen openMenuOnPressAndHold: !messageListItem.precalculatedValues.pageIsSelecting signal replyToMessage() @@ -195,6 +196,12 @@ ListItem { selectReactionBubble.visible = false; } } + onNavigatedTo: { + if (targetIndex === index) { + messageListItem.wasNavigatedTo = true; + restoreNormalityTimer.start(); + } + } } Loader { @@ -327,6 +334,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: { delegateComponentLoadingTimer.start(); if (myMessage.reply_to_message_id) { diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 4150c507..17ced0bb 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -70,6 +70,7 @@ Page { property var availableReactions signal resetElements() signal elementSelected(int elementIndex) + signal navigatedTo(int targetIndex) states: [ State { @@ -420,6 +421,7 @@ Page { if(index !== -1) { chatPage.messageIdToScrollTo = ""; chatView.scrollToIndex(index); + navigatedTo(index); } else if(initialRun) { // we only want to do this once. chatModel.triggerLoadHistoryForMessage(chatPage.messageIdToScrollTo) diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index bef61753..1662801d 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1608,11 +1608,11 @@ Go to quoted message - + Zu zitierter Nachricht springen When tapping a quoted message, open it in chat instead of showing it in an overlay. - + Beim Tippen auf eine zitierte Nachricht zu dieser springen anstatt es in einem Overlay anzuzeigen.