From 04d452b0744aa7002d96bafd6a046876056a5e85 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 12 Sep 2017 17:47:43 -0400 Subject: [PATCH] Normalize conversation presentation logic. // FREEBIE --- Signal/src/environment/Environment.m | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Signal/src/environment/Environment.m b/Signal/src/environment/Environment.m index ff9e39b58..30e01c23b 100644 --- a/Signal/src/environment/Environment.m +++ b/Signal/src/environment/Environment.m @@ -200,15 +200,16 @@ static Environment *environment = nil; keyboardOnViewAppearing:(BOOL)keyboardOnViewAppearing callOnViewAppearing:(BOOL)callOnViewAppearing { - [[TSStorageManager sharedManager].dbReadWriteConnection - asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { - TSThread *thread = [TSContactThread getOrCreateThreadWithContactId:recipientId transaction:transaction]; - dispatch_async(dispatch_get_main_queue(), ^{ - [self presentConversationForThread:thread - keyboardOnViewAppearing:keyboardOnViewAppearing - callOnViewAppearing:callOnViewAppearing]; - }); - }]; + DispatchMainThreadSafe(^{ + __block TSThread *thread = nil; + [[TSStorageManager sharedManager].dbReadWriteConnection + readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { + thread = [TSContactThread getOrCreateThreadWithContactId:recipientId transaction:transaction]; + }]; + [self presentConversationForThread:thread + keyboardOnViewAppearing:keyboardOnViewAppearing + callOnViewAppearing:callOnViewAppearing]; + }); } + (void)presentConversationForThread:(TSThread *)thread