From db15ff5e87f1f8bea281f89ea5f7c22f2d2fb369 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 17 Mar 2017 12:48:33 -0400 Subject: [PATCH] Save message before sending starts. Otherwise the message doesn't get saved until it's in the queue. Interestingly, this could also address some of the perceived lag mentioned in: https://github.com/WhisperSystems/Signal-iOS/pull/1850 // FREEBIE --- src/Messages/OWSMessageSender.m | 6 +----- src/Network/API/OWSUploadingService.m | 3 --- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Messages/OWSMessageSender.m b/src/Messages/OWSMessageSender.m index 197cf7361..f47e71976 100644 --- a/src/Messages/OWSMessageSender.m +++ b/src/Messages/OWSMessageSender.m @@ -246,6 +246,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; success:(void (^)())successHandler failure:(void (^)(NSError *error))failureHandler { + [self saveMessage:message withState:TSOutgoingMessageStateAttemptingOut]; OWSSendMessageOperation *sendMessageOperation = [[OWSSendMessageOperation alloc] initWithMessage:message messageSender:self success:successHandler @@ -339,8 +340,6 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; [attachmentStream save]; [message.attachmentIds addObject:attachmentStream.uniqueId]; - - message.messageState = TSOutgoingMessageStateAttemptingOut; [message save]; [self sendMessage:message success:successHandler failure:failureHandler]; @@ -438,9 +437,6 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; || [message isKindOfClass:[OWSOutgoingSyncMessage class]]) { TSContactThread *contactThread = (TSContactThread *)thread; - - [self saveMessage:message withState:TSOutgoingMessageStateAttemptingOut]; - if ([contactThread.contactIdentifier isEqualToString:self.storageManager.localNumber] && ![message isKindOfClass:[OWSOutgoingSyncMessage class]]) { diff --git a/src/Network/API/OWSUploadingService.m b/src/Network/API/OWSUploadingService.m index a509f8804..6dd3b4831 100644 --- a/src/Network/API/OWSUploadingService.m +++ b/src/Network/API/OWSUploadingService.m @@ -41,9 +41,6 @@ NSString *const kAttachmentUploadAttachmentIDKey = @"kAttachmentUploadAttachment success:(void (^)())successHandler failure:(void (^)(NSError *_Nonnull))failureHandler { - outgoingMessage.messageState = TSOutgoingMessageStateAttemptingOut; - [outgoingMessage save]; - if (attachmentStream.serverId) { DDLogDebug(@"%@ Attachment previously uploaded.", self.tag); successHandler(outgoingMessage);