Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions MatrixSDK/MXSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,17 @@ - (void)handleAccountData:(NSDictionary*)accountDataUpdate
NSMutableSet<NSString*> *directRoomIds = [NSMutableSet set];
[directRoomIds unionSet:[self directRoomIds]];

NSMutableDictionary<NSString*, NSArray<NSString*>*> *_directRooms;
_directRooms = [directRooms mutableCopy];
/// fixes Thread 1: "*** -[NSMutableSet addObjectsFromArray:]: array argument is not an NSArray" error
for (NSString* key in directRooms) {
/// the check for class kind is needed when event.content has exactly one direct room and MXJSONModelSetDictionary converts it to an NSString and not an NSArray. Ideally the server would always send an array even with one direct room, but that's not always the case, ergo the sanity check on client side.
if ([directRooms[key] isKindOfClass:[NSString class]]) {
_directRooms[key] = @[directRooms[key]];
}
}
directRooms = [_directRooms copy];

self.directRooms = directRooms;

// And collect current ones
Expand Down
1 change: 1 addition & 0 deletions changelog.d/1371.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
🐛 Fix directRooms array argument is not an NSArray exception - This exception would occur when event.content has exactly one direct room and MXJSONModelSetDictionary converts it to an NSString and not an NSArray