diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m index 4dac9732c..adc0eb23f 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m @@ -602,6 +602,10 @@ static const int kYapDatabaseRangeMinLength = 0; } for (TSOutgoingMessage *unsavedOutgoingMessage in self.unsavedOutgoingMessages) { + // unsavedOutgoingMessages should only exist for a short period (usually 30-50ms) before + // they are saved and moved into the `persistedViewItems` + OWSAssertDebug( + unsavedOutgoingMessage.timestampForSorting >= ([NSDate ows_millisecondTimeStamp] - 1 * kSecondInMs)); NSUInteger index = [rowChanges indexOfObjectPassingTest:^BOOL( YapDatabaseViewRowChange *_Nonnull rowChange, NSUInteger idx, BOOL *_Nonnull stop) { return [rowChange.collectionKey.key isEqualToString:unsavedOutgoingMessage.uniqueId]; diff --git a/SignalMessaging/utils/ThreadUtil.m b/SignalMessaging/utils/ThreadUtil.m index f56bf438a..2e6694f3d 100644 --- a/SignalMessaging/utils/ThreadUtil.m +++ b/SignalMessaging/utils/ThreadUtil.m @@ -83,7 +83,7 @@ NS_ASSUME_NONNULL_BEGIN quotedMessage:[quotedReplyModel buildQuotedMessageForSending]]; [BenchManager benchAsyncWithTitle:@"Saving outgoing message" block:^(void (^benchmarkCompletion)(void)) { - // To avoid blocking the send flow, we disapatch an async write from within this read transaction + // To avoid blocking the send flow, we dispatch an async write from within this read transaction [self.dbConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction * _Nonnull writeTransaction) { [message saveWithTransaction:writeTransaction]; [self.messageSenderJobQueue addMessage:message transaction:writeTransaction];