summary refs log tree commit diff
path: root/src/timeline/TimelineViewManager.cpp
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2020-06-11 22:27:17 -0400
committerGitHub <noreply@github.com>2020-06-11 22:27:17 -0400
commit813884ee0cbacf5b5b7facab445d3c7cdc712084 (patch)
treef31c6e9545b58d873484e35ea987d486046faa0d /src/timeline/TimelineViewManager.cpp
parentMerge pull request #218 from z33ky/alert-notifications (diff)
parentUpdate translations (diff)
downloadnheko-813884ee0cbacf5b5b7facab445d3c7cdc712084.tar.xz
Merge pull request #217 from Nheko-Reborn/reactions
Reactions
Diffstat (limited to 'src/timeline/TimelineViewManager.cpp')
-rw-r--r--src/timeline/TimelineViewManager.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp

index 30abe506..d6f9fde1 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp
@@ -13,6 +13,8 @@ #include "MxcImageProvider.h" #include "UserSettingsPage.h" #include "dialogs/ImageOverlay.h" +#include "emoji/EmojiModel.h" +#include "emoji/Provider.h" Q_DECLARE_METATYPE(mtx::events::collections::TimelineEvents) @@ -72,6 +74,18 @@ TimelineViewManager::TimelineViewManager(QSharedPointer<UserSettings> userSettin qmlRegisterType<DelegateChoice>("im.nheko", 1, 0, "DelegateChoice"); qmlRegisterType<DelegateChooser>("im.nheko", 1, 0, "DelegateChooser"); qRegisterMetaType<mtx::events::collections::TimelineEvents>(); + qmlRegisterType<emoji::EmojiModel>("im.nheko.EmojiModel", 1, 0, "EmojiModel"); + qmlRegisterType<emoji::EmojiProxyModel>("im.nheko.EmojiModel", 1, 0, "EmojiProxyModel"); + qmlRegisterUncreatableType<QAbstractItemModel>( + "im.nheko.EmojiModel", 1, 0, "QAbstractItemModel", "Used by proxy models"); + qmlRegisterUncreatableType<emoji::Emoji>( + "im.nheko.EmojiModel", 1, 0, "Emoji", "Used by emoji models"); + qmlRegisterUncreatableMetaObject(emoji::staticMetaObject, + "im.nheko.EmojiModel", + 1, + 0, + "EmojiCategory", + "Error: Only enums"); #ifdef USE_QUICK_VIEW view = new QQuickView(); @@ -284,6 +298,36 @@ TimelineViewManager::queueEmoteMessage(const QString &msg) } void +TimelineViewManager::reactToMessage(const QString &roomId, + const QString &reactedEvent, + const QString &reactionKey, + const QString &selfReactedEvent) +{ + // If selfReactedEvent is empty, that means we haven't previously reacted + if (selfReactedEvent.isEmpty()) { + queueReactionMessage(roomId, reactedEvent, reactionKey); + // Otherwise, we have previously reacted and the reaction should be redacted + } else { + auto model = models.value(roomId); + model->redactEvent(selfReactedEvent); + } +} + +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,