CR: add debug asserts

This commit is contained in:
Michael Kirk 2018-12-17 10:34:12 -07:00
parent 81bc357bbb
commit 6232b1ef67
2 changed files with 5 additions and 1 deletions

View file

@ -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];

View file

@ -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];