diff --git a/src/Devices/OWSRecordTranscriptJob.m b/src/Devices/OWSRecordTranscriptJob.m index bafea8376..2b7d2a8af 100644 --- a/src/Devices/OWSRecordTranscriptJob.m +++ b/src/Devices/OWSRecordTranscriptJob.m @@ -86,8 +86,8 @@ NS_ASSUME_NONNULL_BEGIN attachmentIds:[NSMutableArray new] expiresInSeconds:transcript.expirationDuration expireStartedAt:transcript.expirationStartedAt]; - // Since updateWithWasDelivered is a new message, updateWithWasDelivered will save it. - [textMessage updateWithWasDelivered]; + // Since textMessage is a new message, updateWithWasSentAndDelivered will save it. + [textMessage updateWithWasSentAndDelivered]; } } diff --git a/src/Messages/Interactions/TSOutgoingMessage.h b/src/Messages/Interactions/TSOutgoingMessage.h index 1d7b5179c..af505589a 100644 --- a/src/Messages/Interactions/TSOutgoingMessage.h +++ b/src/Messages/Interactions/TSOutgoingMessage.h @@ -159,6 +159,7 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) { - (void)updateWithCustomMessage:(NSString *)customMessage; - (void)updateWithWasDeliveredWithTransaction:(YapDatabaseReadWriteTransaction *)transaction; - (void)updateWithWasDelivered; +- (void)updateWithWasSentAndDelivered; #pragma mark - Sent Recipients diff --git a/src/Messages/Interactions/TSOutgoingMessage.m b/src/Messages/Interactions/TSOutgoingMessage.m index 73e8befc4..a16995468 100644 --- a/src/Messages/Interactions/TSOutgoingMessage.m +++ b/src/Messages/Interactions/TSOutgoingMessage.m @@ -291,6 +291,17 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec }]; } +- (void)updateWithWasSentAndDelivered +{ + [self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { + [self applyChangeToSelfAndLatestOutgoingMessage:transaction + changeBlock:^(TSOutgoingMessage *message) { + [message setMessageState:TSOutgoingMessageStateSentToService]; + [message setWasDelivered:YES]; + }]; + }]; +} + #pragma mark - Sent Recipients - (NSArray *)sentRecipients diff --git a/src/Messages/OWSMessageSender.m b/src/Messages/OWSMessageSender.m index d566882a6..5533c901c 100644 --- a/src/Messages/OWSMessageSender.m +++ b/src/Messages/OWSMessageSender.m @@ -1005,7 +1005,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; - (void)handleMessageSentRemotely:(TSOutgoingMessage *)message sentAt:(uint64_t)sentAt { - [message updateWithWasDelivered]; + [message updateWithWasSentAndDelivered]; [self becomeConsistentWithDisappearingConfigurationForMessage:message]; [self.disappearingMessagesJob setExpirationForMessage:message expirationStartedAt:sentAt]; }