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
pull/1/head
Michael Kirk 9 years ago
parent df51523a84
commit db15ff5e87

@ -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]]) {

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

Loading…
Cancel
Save