Private
Public Access
1
0

Batch updates, and fixing bug where daemon would crash when accessing IMCore stuff from different threads

This commit is contained in:
James Magahern
2018-11-21 15:51:51 -07:00
parent 3186f1948a
commit dba4910a82
10 changed files with 155 additions and 90 deletions

View File

@@ -23,13 +23,15 @@
- (void)main
{
NSArray<IMChat *> *chats = [sChatRegistry allExistingChats];
__block NSMutableArray *conversations = [NSMutableArray array];
NSMutableArray *conversations = [NSMutableArray array];
for (IMChat *chat in chats) {
NSDictionary *chatDict = [chat mbim_dictionaryRepresentation];
[conversations addObject:chatDict];
}
dispatch_sync([[self class] sharedIMAccessQueue], ^{
NSArray<IMChat *> *chats = [sChatRegistry allExistingChats];
for (IMChat *chat in chats) {
NSDictionary *chatDict = [chat mbim_dictionaryRepresentation];
[conversations addObject:chatDict];
}
});
MBIMJSONDataResponse *response = [MBIMJSONDataResponse responseWithJSONObject:conversations];
self.serverCompletionBlock(response);