Fix glitches in outgoing messages.

pull/1/head
Matthew Chen 7 years ago
parent 2ebd2f65d0
commit 752bca313c

@ -25,6 +25,9 @@ NS_ASSUME_NONNULL_BEGIN
@interface OWSOutgoingSentMessageTranscript () @interface OWSOutgoingSentMessageTranscript ()
@property (nonatomic, readonly) TSOutgoingMessage *message; @property (nonatomic, readonly) TSOutgoingMessage *message;
// sentRecipientId is the recipient of message, for contact thread messages.
// It is used to identify the thread/conversation to desktop.
@property (nonatomic, readonly, nullable) NSString *sentRecipientId;
@end @end
@ -39,6 +42,8 @@ NS_ASSUME_NONNULL_BEGIN
} }
_message = message; _message = message;
// This will be nil for groups.
_sentRecipientId = message.thread.contactIdentifier;
return self; return self;
} }
@ -50,10 +55,8 @@ NS_ASSUME_NONNULL_BEGIN
OWSSignalServiceProtosSyncMessageSentBuilder *sentBuilder = [OWSSignalServiceProtosSyncMessageSentBuilder new]; OWSSignalServiceProtosSyncMessageSentBuilder *sentBuilder = [OWSSignalServiceProtosSyncMessageSentBuilder new];
[sentBuilder setTimestamp:self.message.timestamp]; [sentBuilder setTimestamp:self.message.timestamp];
// Sync messages have no thread or destination. [sentBuilder setDestination:self.sentRecipientId];
OWSAssert(!self.message.thread.contactIdentifier); [sentBuilder setMessage:[self.message buildDataMessage:self.sentRecipientId]];
[sentBuilder setDestination:nil];
[sentBuilder setMessage:[self.message buildDataMessage:nil]];
[sentBuilder setExpirationStartTimestamp:self.message.timestamp]; [sentBuilder setExpirationStartTimestamp:self.message.timestamp];
[syncMessageBuilder setSentBuilder:sentBuilder]; [syncMessageBuilder setSentBuilder:sentBuilder];

@ -882,7 +882,10 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
dispatch_async([OWSDispatch sendingQueue], ^{ dispatch_async([OWSDispatch sendingQueue], ^{
// This emulates the completion logic of an actual successful save (see below). // This emulates the completion logic of an actual successful save (see below).
[recipient save]; [self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[message updateWithSkippedRecipient:localNumber transaction:transaction];
[recipient saveWithTransaction:transaction];
}];
successHandler(); successHandler();
}); });

Loading…
Cancel
Save