More debug logs and stricter input check.
This commit is contained in:
@@ -4,7 +4,7 @@ import QtQuick.Layouts 1.12
|
|||||||
import Spectral.Setting 0.1
|
import Spectral.Setting 0.1
|
||||||
|
|
||||||
Flow {
|
Flow {
|
||||||
visible: reaction || false
|
visible: (reaction && reaction.length > 0) || false
|
||||||
|
|
||||||
spacing: 8
|
spacing: 8
|
||||||
|
|
||||||
|
|||||||
@@ -423,13 +423,16 @@ void SpectralRoom::postHtmlMessage(const QString& text,
|
|||||||
|
|
||||||
void SpectralRoom::toggleReaction(const QString& eventId,
|
void SpectralRoom::toggleReaction(const QString& eventId,
|
||||||
const QString& reaction) {
|
const QString& reaction) {
|
||||||
|
if (eventId.isEmpty() || reaction.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
const auto eventIt = findInTimeline(eventId);
|
const auto eventIt = findInTimeline(eventId);
|
||||||
if (eventIt == timelineEdge())
|
if (eventIt == timelineEdge())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto& evt = **eventIt;
|
const auto& evt = **eventIt;
|
||||||
|
|
||||||
QString redactEventId = "";
|
QStringList redactEventIds; // What if there are multiple reaction events?
|
||||||
|
|
||||||
const auto& annotations = relatedEvents(evt, EventRelation::Annotation());
|
const auto& annotations = relatedEvents(evt, EventRelation::Annotation());
|
||||||
if (!annotations.isEmpty()) {
|
if (!annotations.isEmpty()) {
|
||||||
@@ -439,16 +442,23 @@ void SpectralRoom::toggleReaction(const QString& eventId,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (e->senderId() == localUser()->id()) {
|
if (e->senderId() == localUser()->id()) {
|
||||||
redactEventId = e->id();
|
redactEventIds.push_back(e->id());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!redactEventId.isEmpty()) {
|
if (!redactEventIds.isEmpty()) {
|
||||||
redactEvent(redactEventId);
|
qDebug() << "Remove reaction event" << redactEventIds << "of event"
|
||||||
|
<< eventId << ":" << reaction;
|
||||||
|
for (auto redactEventId : redactEventIds) {
|
||||||
|
redactEvent(redactEventId);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
postEvent(new ReactionEvent(EventRelation::annotate(eventId, reaction)));
|
qDebug() << "Add reaction event" << eventId << ":" << reaction;
|
||||||
|
postEvent(new ReactionEvent(EventRelation::annotate(eventId, reaction)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << "End of SpectralRoom::toggleReaction()";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user