Skip to content

Commit

Permalink
Highlight message that was jumped to
Browse files Browse the repository at this point in the history
  • Loading branch information
Wunderfitz committed Dec 2, 2023
1 parent 2dd1d2c commit 4ed9495
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
22 changes: 21 additions & 1 deletion qml/components/MessageListViewItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -195,6 +196,12 @@ ListItem {
selectReactionBubble.visible = false;
}
}
onNavigatedTo: {
if (targetIndex === index) {
messageListItem.wasNavigatedTo = true;
restoreNormalityTimer.start();
}
}
}

Loader {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions qml/pages/ChatPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Page {
property var availableReactions
signal resetElements()
signal elementSelected(int elementIndex)
signal navigatedTo(int targetIndex)

states: [
State {
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions translations/harbour-fernschreiber-de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1608,11 +1608,11 @@
</message>
<message>
<source>Go to quoted message</source>
<translation type="unfinished"></translation>
<translation>Zu zitierter Nachricht springen</translation>
</message>
<message>
<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>
</context>
<context>
Expand Down

0 comments on commit 4ed9495

Please sign in to comment.