Skip to content

Commit

Permalink
Merge pull request #668 from matrix-org/fix_aggregation_hack
Browse files Browse the repository at this point in the history
Reactions: Fix hack to make tests pass
  • Loading branch information
manuroe committed May 23, 2019
2 parents 47c3407 + 6867f79 commit 49b7cf4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions MatrixSDK/Aggregations/MXAggregations.m
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@ - (void)handleReaction:(MXEvent *)event direction:(MXTimelineDirection)direction
MXEvent *parentEvent = [self.matrixStore eventWithEventId:parentEventId inRoom:event.roomId];
if (parentEvent)
{
[self storeRelationForReaction:reaction toEvent:parentEventId reactionEvent:event];

if (direction == MXTimelineDirectionForwards)
{
[self updateReactionCountForReaction:reaction toEvent:parentEventId reactionEvent:event];
}

[self storeRelationForReaction:reaction toEvent:parentEventId reactionEvent:event];
}
else
{
Expand All @@ -229,8 +229,8 @@ - (void)handleRedaction:(MXEvent *)event

if (relation)
{
[self removeReaction:relation.reaction onEvent:relation.eventId inRoomId:event.roomId];
[self.store deleteReactionRelation:relation];
[self removeReaction:relation.reaction onEvent:relation.eventId inRoomId:event.roomId];
}
}

Expand Down Expand Up @@ -428,11 +428,17 @@ - (MXHTTPOperation*)sendReactionUsingHack:(NSString*)reaction
{
NSDate *startDate = [NSDate date];

NSMutableDictionary<NSString*, MXReactionCount*> *reactionCountDict = [NSMutableDictionary dictionary];
NSMutableDictionary<NSString*, MXReactionCount*> *reactionCountDict;

NSArray<MXReactionRelation*> *relations = [self.store reactionRelationsOnEvent:eventId];
for (MXReactionRelation *relation in relations)
{
if (!reactionCountDict)
{
// Have the same behavior as reactionCountsFromMatrixStoreOnEvent
reactionCountDict = [NSMutableDictionary dictionary];
}

MXReactionCount *reactionCount = reactionCountDict[relation.reaction];
if (!reactionCount)
{
Expand Down

0 comments on commit 49b7cf4

Please sign in to comment.