diff --git a/qml/components/MessageListViewItem.qml b/qml/components/MessageListViewItem.qml index 514ff41..f3e3468 100644 --- a/qml/components/MessageListViewItem.qml +++ b/qml/components/MessageListViewItem.qml @@ -497,8 +497,12 @@ ListItem { page.toggleMessageSelection(myMessage) } else { messageOptionsDrawer.open = false - messageOverlayLoader.overlayMessage = messageInReplyToRow.inReplyToMessage - messageOverlayLoader.active = true + if(appSettings.goToQuotedMessage) { + chatPage.showMessage(messageInReplyToRow.inReplyToMessage.id, true) + } else { + messageOverlayLoader.active = true + messageOverlayLoader.overlayMessage = messageInReplyToRow.inReplyToMessage + } } } onPressAndHold: { diff --git a/qml/components/settingsPage/SettingsBehavior.qml b/qml/components/settingsPage/SettingsBehavior.qml index 18b487e..2232791 100644 --- a/qml/components/settingsPage/SettingsBehavior.qml +++ b/qml/components/settingsPage/SettingsBehavior.qml @@ -103,6 +103,17 @@ AccordionItem { } } + TextSwitch { + width: parent.columnWidth + checked: appSettings.goToQuotedMessage + text: qsTr("Go to quoted message") + description: qsTr("When tapping a quoted message, open it in chat instead of showing it in an overlay.") + automaticCheck: false + onClicked: { + appSettings.goToQuotedMessage = !checked + } + } + ComboBox { id: feedbackComboBox width: parent.columnWidth diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml index 0b80651..a7a3fd6 100644 --- a/qml/pages/ChatPage.qml +++ b/qml/pages/ChatPage.qml @@ -54,6 +54,7 @@ Page { property bool iterativeInitialization: false; property var messageToShow; property string messageIdToShow; + property string messageIdToScrollTo; readonly property bool userIsMember: ((isPrivateChat || isSecretChat) && chatInformation["@type"]) || // should be optimized (isBasicGroup || isSuperGroup) && ( (chatGroupInformation.status["@type"] === "chatMemberStatusMember") @@ -409,6 +410,23 @@ Page { chatPage.focus = true; } + function showMessage(messageId, initialRun) { + // Means we tapped a quoted message and had to load it. + if(initialRun) { + chatPage.messageIdToScrollTo = messageId + } + if (chatPage.messageIdToScrollTo && chatPage.messageIdToScrollTo != "") { + var index = chatModel.getMessageIndex(chatPage.messageIdToScrollTo); + if(index !== -1) { + chatPage.messageIdToScrollTo = ""; + chatView.scrollToIndex(index); + } else if(initialRun) { + // we only want to do this once. + chatModel.triggerLoadHistoryForMessage(chatPage.messageIdToScrollTo) + } + } + } + Timer { id: forwardMessagesTimer interval: 200 @@ -650,6 +668,8 @@ Page { if (chatView.height > chatView.contentHeight) { Debug.log("[ChatPage] Chat content quite small..."); viewMessageTimer.queueViewMessage(chatView.count - 1); + } else if (chatPage.messageIdToScrollTo && chatPage.messageIdToScrollTo != "") { + showMessage(chatPage.messageIdToScrollTo, false) } chatViewCooldownTimer.restart(); chatViewStartupReadTimer.restart(); diff --git a/src/appsettings.cpp b/src/appsettings.cpp index 8ed3c52..1a4b376 100644 --- a/src/appsettings.cpp +++ b/src/appsettings.cpp @@ -32,6 +32,7 @@ namespace { const QString KEY_NOTIFICATION_SUPPRESS_ENABLED("notificationSuppressContent"); const QString KEY_NOTIFICATION_FEEDBACK("notificationFeedback"); const QString KEY_NOTIFICATION_ALWAYS_SHOW_PREVIEW("notificationAlwaysShowPreview"); + const QString KEY_GO_TO_QUOTED_MESSAGE("goToQuotedMessage"); const QString KEY_STORAGE_OPTIMIZER("useStorageOptimizer"); const QString KEY_INLINEBOT_LOCATION_ACCESS("allowInlineBotLocationAccess"); const QString KEY_REMAINING_INTERACTION_HINTS("remainingInteractionHints"); @@ -201,6 +202,20 @@ void AppSettings::setNotificationAlwaysShowPreview(bool enable) } } +bool AppSettings::goToQuotedMessage() const +{ + return settings.value(KEY_GO_TO_QUOTED_MESSAGE, false).toBool(); +} + +void AppSettings::setGoToQuotedMessage(bool enable) +{ + if (goToQuotedMessage() != enable) { + LOG(KEY_GO_TO_QUOTED_MESSAGE << enable); + settings.setValue(KEY_GO_TO_QUOTED_MESSAGE, enable); + emit goToQuotedMessageChanged(); + } +} + bool AppSettings::storageOptimizer() const { return settings.value(KEY_STORAGE_OPTIMIZER, true).toBool(); diff --git a/src/appsettings.h b/src/appsettings.h index 84e59d9..acc38b2 100644 --- a/src/appsettings.h +++ b/src/appsettings.h @@ -35,6 +35,7 @@ class AppSettings : public QObject { Q_PROPERTY(bool notificationSuppressContent READ notificationSuppressContent WRITE setNotificationSuppressContent NOTIFY notificationSuppressContentChanged) Q_PROPERTY(NotificationFeedback notificationFeedback READ notificationFeedback WRITE setNotificationFeedback NOTIFY notificationFeedbackChanged) Q_PROPERTY(bool notificationAlwaysShowPreview READ notificationAlwaysShowPreview WRITE setNotificationAlwaysShowPreview NOTIFY notificationAlwaysShowPreviewChanged) + Q_PROPERTY(bool goToQuotedMessage READ goToQuotedMessage WRITE setGoToQuotedMessage NOTIFY goToQuotedMessageChanged) Q_PROPERTY(bool storageOptimizer READ storageOptimizer WRITE setStorageOptimizer NOTIFY storageOptimizerChanged) Q_PROPERTY(bool allowInlineBotLocationAccess READ allowInlineBotLocationAccess WRITE setAllowInlineBotLocationAccess NOTIFY allowInlineBotLocationAccessChanged) Q_PROPERTY(int remainingInteractionHints READ remainingInteractionHints WRITE setRemainingInteractionHints NOTIFY remainingInteractionHintsChanged) @@ -96,6 +97,9 @@ public: bool notificationAlwaysShowPreview() const; void setNotificationAlwaysShowPreview(bool enable); + bool goToQuotedMessage() const; + void setGoToQuotedMessage(bool enable); + bool storageOptimizer() const; void setStorageOptimizer(bool enable); @@ -135,6 +139,7 @@ signals: void notificationSuppressContentChanged(); void notificationFeedbackChanged(); void notificationAlwaysShowPreviewChanged(); + void goToQuotedMessageChanged(); void storageOptimizerChanged(); void allowInlineBotLocationAccessChanged(); void remainingInteractionHintsChanged(); diff --git a/src/chatmodel.cpp b/src/chatmodel.cpp index b4bf632..96c40ce 100644 --- a/src/chatmodel.cpp +++ b/src/chatmodel.cpp @@ -363,6 +363,15 @@ void ChatModel::initialize(const QVariantMap &chatInformation) tdLibWrapper->getChatHistory(chatId, this->chatInformation.value(LAST_READ_INBOX_MESSAGE_ID).toLongLong()); } +void ChatModel::triggerLoadHistoryForMessage(qlonglong messageId) +{ + if (!this->inIncrementalUpdate && !messages.isEmpty()) { + LOG("Trigger loading message with id..." << messageId); + this->inIncrementalUpdate = true; + this->tdLibWrapper->getChatHistory(chatId, messageId); + } +} + void ChatModel::triggerLoadMoreHistory() { if (!this->inIncrementalUpdate && !messages.isEmpty()) { @@ -400,6 +409,17 @@ QVariantMap ChatModel::getMessage(int index) return QVariantMap(); } +int ChatModel::getMessageIndex(qlonglong messageId) +{ + if (messages.size() == 0) { + return -1; + } + if (messageIndexMap.contains(messageId)) { + return messageIndexMap.value(messageId); + } + return -1; +} + int ChatModel::getLastReadMessageIndex() { LOG("Obtaining last read message index"); diff --git a/src/chatmodel.h b/src/chatmodel.h index bf4781f..bbf1b4a 100644 --- a/src/chatmodel.h +++ b/src/chatmodel.h @@ -40,12 +40,14 @@ public: Q_INVOKABLE void clear(bool contentOnly = false); Q_INVOKABLE void initialize(const QVariantMap &chatInformation); Q_INVOKABLE void triggerLoadMoreHistory(); + Q_INVOKABLE void triggerLoadHistoryForMessage(qlonglong messageId); Q_INVOKABLE void triggerLoadMoreFuture(); Q_INVOKABLE QVariantMap getChatInformation(); Q_INVOKABLE QVariantMap getMessage(int index); Q_INVOKABLE int getLastReadMessageIndex(); Q_INVOKABLE void setSearchQuery(const QString newSearchQuery); + Q_INVOKABLE int getMessageIndex(qlonglong messageId); QVariantMap smallPhoto() const; qlonglong getChatId() const; diff --git a/translations/harbour-fernschreiber-de.ts b/translations/harbour-fernschreiber-de.ts index 45b4cdf..5cb5cb1 100644 --- a/translations/harbour-fernschreiber-de.ts +++ b/translations/harbour-fernschreiber-de.ts @@ -1599,6 +1599,14 @@ Hide content in notifications Inhalte in Hinweisen verbergen + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-en.ts b/translations/harbour-fernschreiber-en.ts index e33c491..d030fd2 100644 --- a/translations/harbour-fernschreiber-en.ts +++ b/translations/harbour-fernschreiber-en.ts @@ -1601,6 +1601,14 @@ messages Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-es.ts b/translations/harbour-fernschreiber-es.ts index 43a0a0a..ed11c29 100644 --- a/translations/harbour-fernschreiber-es.ts +++ b/translations/harbour-fernschreiber-es.ts @@ -1599,6 +1599,14 @@ Hide content in notifications Ocultar contenido a notificaciones + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-fi.ts b/translations/harbour-fernschreiber-fi.ts index 5af7081..d11cb99 100644 --- a/translations/harbour-fernschreiber-fi.ts +++ b/translations/harbour-fernschreiber-fi.ts @@ -1600,6 +1600,14 @@ Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-fr.ts b/translations/harbour-fernschreiber-fr.ts index 108609e..2c1ad8d 100644 --- a/translations/harbour-fernschreiber-fr.ts +++ b/translations/harbour-fernschreiber-fr.ts @@ -1599,6 +1599,14 @@ Hide content in notifications Masquer le contenu dans les notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-hu.ts b/translations/harbour-fernschreiber-hu.ts index 96c1f31..ccf965e 100644 --- a/translations/harbour-fernschreiber-hu.ts +++ b/translations/harbour-fernschreiber-hu.ts @@ -1572,6 +1572,14 @@ Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-it.ts b/translations/harbour-fernschreiber-it.ts index 077dc42..5303829 100644 --- a/translations/harbour-fernschreiber-it.ts +++ b/translations/harbour-fernschreiber-it.ts @@ -1599,6 +1599,14 @@ Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-pl.ts b/translations/harbour-fernschreiber-pl.ts index f063ebf..040f2bc 100644 --- a/translations/harbour-fernschreiber-pl.ts +++ b/translations/harbour-fernschreiber-pl.ts @@ -1626,6 +1626,14 @@ Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-ru.ts b/translations/harbour-fernschreiber-ru.ts index 71ca7a5..4e7d338 100644 --- a/translations/harbour-fernschreiber-ru.ts +++ b/translations/harbour-fernschreiber-ru.ts @@ -1629,6 +1629,14 @@ Hide content in notifications Не показывать содержимое сообщений в уведомлениях + + Go to quoted message + Переходить к цитируемому сообщению + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + По нажатию на цитируемое сообщение, переходить к нему в чате вместо отображения во всплывающем окне. + SettingsPage diff --git a/translations/harbour-fernschreiber-sk.ts b/translations/harbour-fernschreiber-sk.ts index feb8003..e8b9dce 100644 --- a/translations/harbour-fernschreiber-sk.ts +++ b/translations/harbour-fernschreiber-sk.ts @@ -1626,6 +1626,14 @@ Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-sv.ts b/translations/harbour-fernschreiber-sv.ts index 462fda1..dc5ce5e 100644 --- a/translations/harbour-fernschreiber-sv.ts +++ b/translations/harbour-fernschreiber-sv.ts @@ -1599,6 +1599,14 @@ Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber-zh_CN.ts b/translations/harbour-fernschreiber-zh_CN.ts index fec9b66..7887ddb 100644 --- a/translations/harbour-fernschreiber-zh_CN.ts +++ b/translations/harbour-fernschreiber-zh_CN.ts @@ -1573,6 +1573,14 @@ Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage diff --git a/translations/harbour-fernschreiber.ts b/translations/harbour-fernschreiber.ts index 72c8cae..2481b12 100644 --- a/translations/harbour-fernschreiber.ts +++ b/translations/harbour-fernschreiber.ts @@ -1599,6 +1599,14 @@ Hide content in notifications + + Go to quoted message + + + + When tapping a quoted message, open it in chat instead of showing it in an overlay. + + SettingsPage