Fix reactions
This commit is contained in:
parent
6f2bc908ba
commit
19f27236ea
12 changed files with 89 additions and 48 deletions
|
|
@ -314,35 +314,38 @@ TimelineViewManager::queueEmoteMessage(const QString &msg)
|
|||
}
|
||||
|
||||
void
|
||||
TimelineViewManager::reactToMessage(const QString &roomId,
|
||||
const QString &reactedEvent,
|
||||
const QString &reactionKey,
|
||||
const QString &selfReactedEvent)
|
||||
TimelineViewManager::queueReactionMessage(const QString &reactedEvent, const QString &reactionKey)
|
||||
{
|
||||
if (!timeline_)
|
||||
return;
|
||||
|
||||
auto reactions = timeline_->reactions(reactedEvent.toStdString());
|
||||
|
||||
QString selfReactedEvent;
|
||||
for (const auto &reaction : reactions) {
|
||||
if (reactionKey == reaction.key_) {
|
||||
selfReactedEvent = reaction.selfReactedEvent_;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (selfReactedEvent.startsWith("m"))
|
||||
return;
|
||||
|
||||
// If selfReactedEvent is empty, that means we haven't previously reacted
|
||||
if (selfReactedEvent.isEmpty()) {
|
||||
queueReactionMessage(roomId, reactedEvent, 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();
|
||||
|
||||
timeline_->sendMessage(reaction);
|
||||
// Otherwise, we have previously reacted and the reaction should be redacted
|
||||
} else {
|
||||
auto model = models.value(roomId);
|
||||
model->redactEvent(selfReactedEvent);
|
||||
timeline_->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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue