Skip to content

Commit

Permalink
Reactions: Fix hack to make tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
manuroe committed May 23, 2019
1 parent 47c3407 commit 6867f79
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 6867f79

Please sign in to comment.