From 6232b1ef676c0158a0cd5c3043d92a25852ad035 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 17 Dec 2018 10:34:12 -0700 Subject: [PATCH] CR: add debug asserts --- .../ViewControllers/ConversationView/ConversationViewModel.m | 4 ++++ SignalMessaging/utils/ThreadUtil.m | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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];