diff --git a/src/app/commoncomponents/SBSMessageBase.qml b/src/app/commoncomponents/SBSMessageBase.qml index 686b710cbfe947d32d9ac0f1974b9721869eceec..321df2ece4f8f955bbc8e28ee55cf1f176127ed0 100644 --- a/src/app/commoncomponents/SBSMessageBase.qml +++ b/src/app/commoncomponents/SBSMessageBase.qml @@ -54,6 +54,7 @@ Control { readonly property real msgRadius: 20 readonly property real hPadding: JamiTheme.sbsMessageBasePreferredPadding property bool textHovered: false + property alias replyAnimation: selectAnimation width: ListView.view ? ListView.view.width : 0 height: mainColumnLayout.implicitHeight @@ -353,6 +354,20 @@ Control { to: 0 duration: JamiTheme.longFadeDuration } + PropertyAnimation { + properties: "opacity" + target: opacityMask + from: 0 + to: 1 + duration: JamiTheme.longFadeDuration + } + PropertyAnimation { + properties: "opacity" + target: opacityMask + from: 1 + to: 0 + duration: JamiTheme.longFadeDuration + } } OpacityMask { diff --git a/src/app/mainview/components/MessageListView.qml b/src/app/mainview/components/MessageListView.qml index 2eb6a94d51eba21a89e3cf2e50720488f5694adf..81d33ace1524d8b86feb8056782a0d8fa2aec1c0 100644 --- a/src/app/mainview/components/MessageListView.qml +++ b/src/app/mainview/components/MessageListView.qml @@ -152,16 +152,9 @@ JamiListView { Connections { target: CurrentConversation - function onIdChanged() { fadeAnimation.start() } function onScrollTo(id) { - var idx = -1 - for (var i = 1; i < root.count; i++) { - var delegate = root.itemAtIndex(i) - if (delegate && delegate.id === id) { - idx = i - } - } - positionViewAtIndex(idx, ListView.Center) + var idx = MessagesAdapter.getMessageIndexFromId(id) + positionViewAtIndex(idx, ListView.Visible) } } diff --git a/src/app/messagesadapter.cpp b/src/app/messagesadapter.cpp index 2bc816d37023cbcbdb72ff6aeff6f5efb734f7d5..a13aaa44690b32e8a5d8c6f0cc969e9edecccaf8 100644 --- a/src/app/messagesadapter.cpp +++ b/src/app/messagesadapter.cpp @@ -761,6 +761,23 @@ MessagesAdapter::getConvMedias() } } +int +MessagesAdapter::getMessageIndexFromId(QString& id) +{ + const QString& convId = lrcInstance_->get_selectedConvUid(); + const auto& conversation = lrcInstance_->getConversationFromConvUid(convId); + auto allInteractions = conversation.interactions.get(); + int index = 0; + for (auto it = allInteractions->rbegin(); it != allInteractions->rend(); it++) { + if (interaction::isDisplayedInChatview(it->second.type)) { + if (it->first == id) + return index; + index++; + } + } + return -1; +} + MessageListModel* MessagesAdapter::getMsgListSourceModel() const { diff --git a/src/app/messagesadapter.h b/src/app/messagesadapter.h index 8913d89a2331db58063b09234a7b48c050d35dab..b01b4496d0ff5619af9f610ea368325877a4969c 100644 --- a/src/app/messagesadapter.h +++ b/src/app/messagesadapter.h @@ -42,9 +42,7 @@ public: auto index = sourceModel()->index(sourceRow, 0, sourceParent); auto type = static_cast<interaction::Type>( sourceModel()->data(index, MessageList::Role::Type).toInt()); - return type != interaction::Type::MERGE && type != interaction::Type::EDITED - && type != interaction::Type::REACTION && type != interaction::Type::VOTE - && type != interaction::Type::UPDATE_PROFILE && type != interaction::Type::INVALID; + return interaction::isDisplayedInChatview(type); }; bool lessThan(const QModelIndex& left, const QModelIndex& right) const override { @@ -136,6 +134,7 @@ protected: Q_INVOKABLE QVariant dataForInteraction(const QString& interactionId, int role = Qt::DisplayRole) const; Q_INVOKABLE void getConvMedias(); + Q_INVOKABLE int getMessageIndexFromId(QString& id); // Run corrsponding js functions, c++ to qml. void setMessagesImageContent(const QString& path, bool isBased64 = false); diff --git a/src/libclient/api/interaction.h b/src/libclient/api/interaction.h index 3abfb2dfbc6c9112279420debfc8ea883845d4b5..9e928ceaa0d2a958877be3e082c4f453346befe9 100644 --- a/src/libclient/api/interaction.h +++ b/src/libclient/api/interaction.h @@ -47,6 +47,13 @@ enum class Type { COUNT__ }; Q_ENUM_NS(Type) +static inline bool +isDisplayedInChatview(const Type& type) +{ + return type != interaction::Type::MERGE && type != interaction::Type::EDITED + && type != interaction::Type::REACTION && type != interaction::Type::VOTE + && type != interaction::Type::UPDATE_PROFILE && type != interaction::Type::INVALID; +} static inline const QString to_string(const Type& type) diff --git a/src/libclient/messagelistmodel.cpp b/src/libclient/messagelistmodel.cpp index b9c98b188b0cf8e3d6a3da838641c6a7f2aae7f4..6c21719374ba84df5aa5d78a84d88b16338b563f 100644 --- a/src/libclient/messagelistmodel.cpp +++ b/src/libclient/messagelistmodel.cpp @@ -152,6 +152,12 @@ MessageListModel::end() const return interactions_.end(); } +reverseIterator +MessageListModel::rend() +{ + return interactions_.rend(); +} + constIterator MessageListModel::cend() const { diff --git a/src/libclient/messagelistmodel.h b/src/libclient/messagelistmodel.h index 452be1b8a8835ef9c9ff327859e4b7356645fd38..302f94fe623a6650b8bb6e01c4b16734c992897d 100644 --- a/src/libclient/messagelistmodel.h +++ b/src/libclient/messagelistmodel.h @@ -96,6 +96,8 @@ public: interaction::Info& operator[](const QString& messageId); iterator end(); constIterator end() const; + reverseIterator rend(); + constIterator cend() const; iterator begin(); constIterator begin() const;