diff options
author | Joseph Donofry <joedonofry@gmail.com> | 2020-05-07 20:53:24 -0400 |
---|---|---|
committer | Joseph Donofry <joedonofry@gmail.com> | 2020-05-07 20:53:24 -0400 |
commit | a1661f7006d7661bfd54cdd9971afd6717ed9c92 (patch) | |
tree | 8d8a221740487d0411795a17918715e15e89cf99 /src/timeline | |
parent | Merge pull request #192 from Nheko-Reborn/reactions (diff) | |
download | nheko-a1661f7006d7661bfd54cdd9971afd6717ed9c92.tar.xz |
merge master into reactions
Diffstat (limited to 'src/timeline')
-rw-r--r-- | src/timeline/TimelineModel.cpp | 7 | ||||
-rw-r--r-- | src/timeline/TimelineModel.h | 20 | ||||
-rw-r--r-- | src/timeline/TimelineViewManager.cpp | 14 | ||||
-rw-r--r-- | src/timeline/TimelineViewManager.h | 4 |
4 files changed, 43 insertions, 2 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 388a5842..022267d0 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -915,6 +915,13 @@ TimelineModel::decryptEvent(const mtx::events::EncryptedEvent<mtx::events::msg:: } void +TimelineModel::reactAction(QString id) +{ + setReaction(id); + ChatPage::instance()->reactMessage(id); +} + +void TimelineModel::replyAction(QString id) { setReply(id); diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index a737aac7..df231925 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -126,6 +126,7 @@ class TimelineModel : public QAbstractListModel int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(std::vector<QString> typingUsers READ typingUsers WRITE updateTypingUsers NOTIFY typingUsersChanged) + Q_PROPERTY(QString reaction READ reaction WRITE setReaction NOTIFY reactionChanged RESET resetReaction) Q_PROPERTY(QString reply READ reply WRITE setReply NOTIFY replyChanged RESET resetReply) Q_PROPERTY( bool paginationInProgress READ paginationInProgress NOTIFY paginationInProgressChanged) @@ -187,6 +188,7 @@ public: Q_INVOKABLE void viewRawMessage(QString id) const; Q_INVOKABLE void viewDecryptedRawMessage(QString id) const; Q_INVOKABLE void openUserProfile(QString userid) const; + Q_INVOKABLE void reactAction(QString id); Q_INVOKABLE void replyAction(QString id); Q_INVOKABLE void readReceiptsAction(QString id) const; Q_INVOKABLE void redactEvent(QString id); @@ -215,7 +217,21 @@ public slots: } std::vector<QString> typingUsers() const { return typingUsers_; } bool paginationInProgress() const { return m_paginationInProgress; } - + QString reaction() const { return reaction_; } + void setReaction(QString reaction) + { + if (reaction_ != reaction) { + reaction_ = reaction; + emit reactionChanged(reaction_); + } + } + void resetReaction() + { + if (!reaction_.isEmpty()) { + reaction_ = ""; + emit reactionChanged(reaction_); + } + } QString reply() const { return reply_; } void setReply(QString newReply) { @@ -252,6 +268,7 @@ signals: void newEncryptedImage(mtx::crypto::EncryptedFile encryptionInfo); void eventFetched(QString requestingEvent, mtx::events::collections::TimelineEvents event); void typingUsersChanged(std::vector<QString> users); + void reactionChanged(QString reaction); void replyChanged(QString reply); void paginationInProgressChanged(const bool); @@ -285,6 +302,7 @@ private: bool m_paginationInProgress = false; QString currentId; + QString reaction_; QString reply_; std::vector<QString> typingUsers_; diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index b9565be8..f17e3090 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -283,6 +283,20 @@ TimelineViewManager::queueEmoteMessage(const QString &msg) } void +TimelineViewManager::queueReactionMessage(const QString &roomId, + const QString &reactedEvent, + const QString &reactionKey) +{ + mtx::events::msg::Reaction reaction; + reaction.relates_to.rel_type = mtx::common::RelationType::Annotation; + reaction.relates_to.event_id = reactedEvent.toStdString(); + reaction.relates_to.key = reactionKey.toStdString(); + + auto model = models.value(roomId); + model->sendMessage(reaction); +} + +void TimelineViewManager::queueImageMessage(const QString &roomid, const QString &filename, const std::optional<mtx::crypto::EncryptedFile> &file, diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h index 45a603af..eb2223e2 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h @@ -55,7 +55,9 @@ public slots: void setHistoryView(const QString &room_id); void updateColorPalette(); - + void queueReactionMessage(const QString &roomId, + const QString &reactedEvent, + const QString &reaction); void queueTextMessage(const QString &msg); void queueEmoteMessage(const QString &msg); void queueImageMessage(const QString &roomid, |