Respond to post-holiday code reviews.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent a9bac8bce7
commit 18e6a1b1cb

@ -176,9 +176,6 @@ NS_ASSUME_NONNULL_BEGIN
// data loss and will resolve all known issues. // data loss and will resolve all known issues.
- (void)updateWithMutedUntilDate:(NSDate *)mutedUntilDate; - (void)updateWithMutedUntilDate:(NSDate *)mutedUntilDate;
// Returns YES IFF the interaction should show up in the inbox as the last message.
+ (BOOL)shouldInteractionAppearInInbox:(TSInteraction *)interaction;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -283,6 +283,7 @@ NS_ASSUME_NONNULL_BEGIN
} }
} }
// Returns YES IFF the interaction should show up in the inbox as the last message.
+ (BOOL)shouldInteractionAppearInInbox:(TSInteraction *)interaction + (BOOL)shouldInteractionAppearInInbox:(TSInteraction *)interaction
{ {
OWSAssert(interaction); OWSAssert(interaction);

@ -33,7 +33,7 @@ extern const NSUInteger kIdentityKeyLength;
- (void)setVerificationState:(OWSVerificationState)verificationState - (void)setVerificationState:(OWSVerificationState)verificationState
identityKey:(NSData *)identityKey identityKey:(NSData *)identityKey
recipientId:(NSString *)recipientId recipientId:(NSString *)recipientId
sendSyncMessage:(BOOL)sendSyncMessage; isUserInitiatedChange:(BOOL)isUserInitiatedChange;
- (OWSVerificationState)verificationStateForRecipientId:(NSString *)recipientId; - (OWSVerificationState)verificationStateForRecipientId:(NSString *)recipientId;

@ -205,7 +205,7 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
- (void)setVerificationState:(OWSVerificationState)verificationState - (void)setVerificationState:(OWSVerificationState)verificationState
identityKey:(NSData *)identityKey identityKey:(NSData *)identityKey
recipientId:(NSString *)recipientId recipientId:(NSString *)recipientId
sendSyncMessage:(BOOL)sendSyncMessage isUserInitiatedChange:(BOOL)isUserInitiatedChange
{ {
OWSAssert(identityKey.length > 0); OWSAssert(identityKey.length > 0);
OWSAssert(recipientId.length > 0); OWSAssert(recipientId.length > 0);
@ -235,7 +235,7 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
[recipientIdentity updateWithVerificationState:verificationState]; [recipientIdentity updateWithVerificationState:verificationState];
if (sendSyncMessage) { if (isUserInitiatedChange) {
[self enqueueSyncMessageForVerificationState:verificationState [self enqueueSyncMessageForVerificationState:verificationState
identityKey:identityKey identityKey:identityKey
recipientId:recipientId]; recipientId:recipientId];

@ -159,7 +159,6 @@ NSUInteger const OWSSendMessageOperationMaxRetries = 4;
@property (nonatomic, readonly) void (^failureHandler)(NSError *_Nonnull error); @property (nonatomic, readonly) void (^failureHandler)(NSError *_Nonnull error);
@property (nonatomic) OWSSendMessageOperationState operationState; @property (nonatomic) OWSSendMessageOperationState operationState;
@property (nonatomic) UIBackgroundTaskIdentifier backgroundTaskIdentifier; @property (nonatomic) UIBackgroundTaskIdentifier backgroundTaskIdentifier;
@property (nonatomic) BOOL hasCompleted;
@end @end
@ -191,18 +190,17 @@ NSUInteger const OWSSendMessageOperationMaxRetries = 4;
return; return;
} }
// Ensure we call the success or failure handler exactly once.
@synchronized(strongSelf)
{
OWSCAssert(!strongSelf.hasCompleted);
strongSelf.hasCompleted = YES;
}
[message updateWithMessageState:TSOutgoingMessageStateSentToService]; [message updateWithMessageState:TSOutgoingMessageStateSentToService];
DDLogDebug(@"%@ succeeded.", strongSelf.tag); DDLogDebug(@"%@ succeeded.", strongSelf.tag);
aSuccessHandler(); aSuccessHandler();
// Ensure we call the success or failure handler exactly once.
@synchronized(strongSelf)
{
OWSCAssert(strongSelf.operationState != OWSSendMessageOperationStateFinished);
[strongSelf markAsComplete]; [strongSelf markAsComplete];
}
}; };
_failureHandler = ^(NSError *_Nonnull error) { _failureHandler = ^(NSError *_Nonnull error) {
@ -212,18 +210,17 @@ NSUInteger const OWSSendMessageOperationMaxRetries = 4;
return; return;
} }
// Ensure we call the success or failure handler exactly once.
@synchronized(strongSelf)
{
OWSCAssert(!strongSelf.hasCompleted);
strongSelf.hasCompleted = YES;
}
[strongSelf.message updateWithSendingError:error]; [strongSelf.message updateWithSendingError:error];
DDLogDebug(@"%@ failed with error: %@", strongSelf.tag, error); DDLogDebug(@"%@ failed with error: %@", strongSelf.tag, error);
aFailureHandler(error); aFailureHandler(error);
// Ensure we call the success or failure handler exactly once.
@synchronized(strongSelf)
{
OWSCAssert(strongSelf.operationState != OWSSendMessageOperationStateFinished);
[strongSelf markAsComplete]; [strongSelf markAsComplete];
}
}; };
return self; return self;

@ -102,8 +102,6 @@ NSUInteger TSCallCurrentSchemaVersion = 1;
[self touchThreadWithTransaction:transaction]; [self touchThreadWithTransaction:transaction];
// Ignore sendReadReceipt and updateExpiration; they don't apply to calls. // Ignore sendReadReceipt and updateExpiration; they don't apply to calls.
//
// TODO: Should we update expiration of calls?
} }
#pragma mark - Methods #pragma mark - Methods

Loading…
Cancel
Save