Avoid deadlock when receiving read receipt before incoming message

// FREEBIE
pull/1/head
Michael Kirk 9 years ago
parent eb96f846a4
commit af155bf9ed

@ -328,9 +328,9 @@
NSData *groupId = dataMessage.hasGroup ? dataMessage.group.id : nil; NSData *groupId = dataMessage.hasGroup ? dataMessage.group.id : nil;
__block TSIncomingMessage *incomingMessage; __block TSIncomingMessage *incomingMessage;
__block TSThread *thread;
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
TSThread *thread;
if (groupId) { if (groupId) {
NSMutableArray *uniqueMemberIds = [[[NSSet setWithArray:dataMessage.group.members] allObjects] mutableCopy]; NSMutableArray *uniqueMemberIds = [[[NSSet setWithArray:dataMessage.group.members] allObjects] mutableCopy];
TSGroupModel *model = [[TSGroupModel alloc] initWithTitle:dataMessage.group.name TSGroupModel *model = [[TSGroupModel alloc] initWithTitle:dataMessage.group.name
@ -426,22 +426,20 @@
[incomingMessage saveWithTransaction:transaction]; [incomingMessage saveWithTransaction:transaction];
} }
}];
NSString *name = [thread name]; if (incomingMessage && thread) {
OWSReadReceiptsProcessor *readReceiptsProcessor =
if (incomingMessage && thread) { [[OWSReadReceiptsProcessor alloc] initWithIncomingMessage:incomingMessage];
// TODO Delay by 100ms? [readReceiptsProcessor process];
OWSReadReceiptsProcessor *readReceiptsProcessor =
[[OWSReadReceiptsProcessor alloc] initWithIncomingMessage:incomingMessage];
[readReceiptsProcessor process];
[[TextSecureKitEnv sharedEnv] // TODO Delay notification by 100ms?
.notificationsManager notifyUserForIncomingMessage:incomingMessage // It's pretty annoying when you're phone keeps buzzing while you're having a conversation on Desktop.
from:name NSString *name = [thread name];
inThread:thread]; [[TextSecureKitEnv sharedEnv].notificationsManager notifyUserForIncomingMessage:incomingMessage
} from:name
}]; inThread:thread];
}
return incomingMessage; return incomingMessage;
} }

Loading…
Cancel
Save