Skip to content

Commit

Permalink
Merge pull request #1408 from nextcloud/fix-reaction-crashes
Browse files Browse the repository at this point in the history
Fix crashes when adding/removing reactions
  • Loading branch information
Ivansss authored Nov 3, 2023
2 parents 24ac5c8 + 740306d commit 0ec421f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions NextcloudTalk/NCAPIController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,13 @@ - (NSURLSessionDataTask *)addReaction:(NSString *)reaction toMessage:(NSInteger)
NSDictionary *reactionsDict = [[responseObject objectForKey:@"ocs"] objectForKey:@"data"];
if (block) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)task.response;
block(reactionsDict, nil, httpResponse.statusCode);

// When there are no elements, the server returns an empty array instead of an empty dictionary
if (![reactionsDict isKindOfClass:[NSDictionary class]]) {
block(@{}, nil, httpResponse.statusCode);
} else {
block(reactionsDict, nil, httpResponse.statusCode);
}
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSInteger statusCode = [self getResponseStatusCode:task.response];
Expand All @@ -1729,7 +1735,13 @@ - (NSURLSessionDataTask *)removeReaction:(NSString *)reaction fromMessage:(NSInt
NSDictionary *reactionsDict = [[responseObject objectForKey:@"ocs"] objectForKey:@"data"];
if (block) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)task.response;
block(reactionsDict, nil, httpResponse.statusCode);

// When there are no elements, the server returns an empty array instead of an empty dictionary
if (![reactionsDict isKindOfClass:[NSDictionary class]]) {
block(@{}, nil, httpResponse.statusCode);
} else {
block(reactionsDict, nil, httpResponse.statusCode);
}
}
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSInteger statusCode = [self getResponseStatusCode:task.response];
Expand Down

0 comments on commit 0ec421f

Please sign in to comment.