diff --git a/MatrixSDK/JSONModels/Aggregations/MXAggregationPaginatedResponse.m b/MatrixSDK/JSONModels/Aggregations/MXAggregationPaginatedResponse.m index 19625d7d65..576e5327d4 100644 --- a/MatrixSDK/JSONModels/Aggregations/MXAggregationPaginatedResponse.m +++ b/MatrixSDK/JSONModels/Aggregations/MXAggregationPaginatedResponse.m @@ -35,12 +35,20 @@ + (instancetype)modelFromJSON:(NSDictionary *)JSONDictionary MXAggregationPaginatedResponse *paginatedResponse; NSArray *chunk; - MXJSONModelSetMXJSONModelArray(chunk, MXEvent.class, JSONDictionary[@"chunk"]) - + NSArray *chunkJson = JSONDictionary[@"chunk"]; + + // For some reason modelsFromJSON returns nil if you pass it an empty array. + // In this case we want an empty array or we get an error. + if([chunkJson isKindOfClass:NSArray.class] && chunkJson.count == 0) + { + chunk = @[]; + } else { + MXJSONModelSetMXJSONModelArray(chunk, MXEvent.class, chunkJson) + } + if (chunk) { paginatedResponse = [MXAggregationPaginatedResponse new]; - paginatedResponse->_chunk = chunk; MXJSONModelSetString(paginatedResponse->_nextBatch, JSONDictionary[@"next_batch"]) diff --git a/changelog.d/7551.bugfix b/changelog.d/7551.bugfix new file mode 100644 index 0000000000..71dbd80c5b --- /dev/null +++ b/changelog.d/7551.bugfix @@ -0,0 +1 @@ +Fixes a bug where an unhelpful message is shown rather than the threads empty state. \ No newline at end of file