From 3287d5cda65e692084940f5823597d120251b44c Mon Sep 17 00:00:00 2001 From: David Langley Date: Thu, 18 May 2023 16:46:18 +0100 Subject: [PATCH] this probably makes more sense --- .../Aggregations/MXAggregationPaginatedResponse.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MatrixSDK/JSONModels/Aggregations/MXAggregationPaginatedResponse.m b/MatrixSDK/JSONModels/Aggregations/MXAggregationPaginatedResponse.m index ad57f26d0..576e5327d 100644 --- a/MatrixSDK/JSONModels/Aggregations/MXAggregationPaginatedResponse.m +++ b/MatrixSDK/JSONModels/Aggregations/MXAggregationPaginatedResponse.m @@ -36,12 +36,14 @@ + (instancetype)modelFromJSON:(NSDictionary *)JSONDictionary NSArray *chunk; NSArray *chunkJson = JSONDictionary[@"chunk"]; - MXJSONModelSetMXJSONModelArray(chunk, MXEvent.class, chunkJson) + // 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(!chunk && [chunkJson isKindOfClass:NSArray.class]) + if([chunkJson isKindOfClass:NSArray.class] && chunkJson.count == 0) { chunk = @[]; + } else { + MXJSONModelSetMXJSONModelArray(chunk, MXEvent.class, chunkJson) } if (chunk)