Merge branch 'charlesmchen/holidayCodeReviewOmnibus'

pull/1/head
Matthew Chen 8 years ago
commit c758f85cc8

@ -134,7 +134,7 @@ CHECKOUT OPTIONS:
:commit: 7054e4b13ee5bcd6d524adb6dc9a726e8c466308 :commit: 7054e4b13ee5bcd6d524adb6dc9a726e8c466308
:git: https://github.com/WhisperSystems/JSQMessagesViewController.git :git: https://github.com/WhisperSystems/JSQMessagesViewController.git
SignalServiceKit: SignalServiceKit:
:commit: a9bac8bce7ea3a0209024d0b0a937d45748aea97 :commit: c0cb153f29e0102355c01273570115217bb0454f
:git: https://github.com/WhisperSystems/SignalServiceKit.git :git: https://github.com/WhisperSystems/SignalServiceKit.git
SocketRocket: SocketRocket:
:commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf :commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf

@ -38,8 +38,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface OWSMessagesBubblesSizeCalculator () @interface OWSMessagesBubblesSizeCalculator ()
@property (nonatomic) OWSSystemMessageCell *referenceSystemMessageCell; @property (nonatomic, readonly) OWSSystemMessageCell *referenceSystemMessageCell;
@property (nonatomic) OWSUnreadIndicatorCell *referenceUnreadIndicatorCell; @property (nonatomic, readonly) OWSUnreadIndicatorCell *referenceUnreadIndicatorCell;
@end @end
@ -47,6 +47,15 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSMessagesBubblesSizeCalculator @implementation OWSMessagesBubblesSizeCalculator
- (instancetype)init
{
if (self = [super init]) {
_referenceSystemMessageCell = [OWSSystemMessageCell new];
_referenceUnreadIndicatorCell = [OWSUnreadIndicatorCell new];
}
return self;
}
/** /**
* Computes and returns the size of the `messageBubbleImageView` property * Computes and returns the size of the `messageBubbleImageView` property
* of a `JSQMessagesCollectionViewCell` for the specified messageData at indexPath. * of a `JSQMessagesCollectionViewCell` for the specified messageData at indexPath.
@ -119,10 +128,6 @@ NS_ASSUME_NONNULL_BEGIN
return [cachedSize CGSizeValue]; return [cachedSize CGSizeValue];
} }
if (!self.referenceSystemMessageCell) {
self.referenceSystemMessageCell = [OWSSystemMessageCell new];
}
CGSize result = [self.referenceSystemMessageCell cellSizeForInteraction:interaction CGSize result = [self.referenceSystemMessageCell cellSizeForInteraction:interaction
collectionViewWidth:layout.collectionView.width]; collectionViewWidth:layout.collectionView.width];
@ -143,10 +148,6 @@ NS_ASSUME_NONNULL_BEGIN
return [cachedSize CGSizeValue]; return [cachedSize CGSizeValue];
} }
if (!self.referenceUnreadIndicatorCell) {
self.referenceUnreadIndicatorCell = [OWSUnreadIndicatorCell new];
}
CGSize result = [self.referenceUnreadIndicatorCell cellSizeForInteraction:interaction CGSize result = [self.referenceUnreadIndicatorCell cellSizeForInteraction:interaction
collectionViewWidth:layout.collectionView.width]; collectionViewWidth:layout.collectionView.width];

@ -14,7 +14,7 @@ class ProfileFetcherJob: NSObject {
let thread: TSThread let thread: TSThread
// This property is only accessed on the default global queue. // This property is only accessed on the main queue.
static var fetchDateMap = [String: Date]() static var fetchDateMap = [String: Date]()
public class func run(thread: TSThread, networkManager: TSNetworkManager) { public class func run(thread: TSThread, networkManager: TSNetworkManager) {
@ -31,7 +31,7 @@ class ProfileFetcherJob: NSObject {
public func run() { public func run() {
AssertIsOnMainThread() AssertIsOnMainThread()
DispatchQueue.global().async { DispatchQueue.main.async {
for recipientId in self.thread.recipientIdentifiers { for recipientId in self.thread.recipientIdentifiers {
self.getProfile(recipientId: recipientId) self.getProfile(recipientId: recipientId)
} }
@ -40,27 +40,24 @@ class ProfileFetcherJob: NSObject {
public func getProfile(recipientId: String, remainingRetries: Int = 3) { public func getProfile(recipientId: String, remainingRetries: Int = 3) {
// Only throttle profile fetch in production builds in order to if let lastDate = ProfileFetcherJob.fetchDateMap[recipientId] {
// facilitate debugging. let lastTimeInterval = fabs(lastDate.timeIntervalSinceNow)
if !_isDebugAssertConfiguration() { // Don't check a profile more often than every N minutes.
if let lastDate = ProfileFetcherJob.fetchDateMap[recipientId] { //
let lastTimeInterval = fabs(lastDate.timeIntervalSinceNow) // Only throttle profile fetch in production builds in order to
// Don't check a profile more often than every N minutes. // facilitate debugging.
let kGetProfileMaxFrequencySeconds = 60.0 * 5.0 let kGetProfileMaxFrequencySeconds = _isDebugAssertConfiguration() ? 0 : 60.0 * 5.0
if lastTimeInterval < kGetProfileMaxFrequencySeconds { guard lastTimeInterval > kGetProfileMaxFrequencySeconds else {
Logger.info("\(self.TAG) skipping getProfile: \(recipientId), lastTimeInterval: \(lastTimeInterval)") Logger.info("\(self.TAG) skipping getProfile: \(recipientId), lastTimeInterval: \(lastTimeInterval)")
return return
}
} }
ProfileFetcherJob.fetchDateMap[recipientId] = Date()
} }
ProfileFetcherJob.fetchDateMap[recipientId] = Date()
Logger.error("\(self.TAG) getProfile: \(recipientId)") Logger.error("\(self.TAG) getProfile: \(recipientId)")
let request = OWSGetProfileRequest(recipientId: recipientId) let request = OWSGetProfileRequest(recipientId: recipientId)
// We don't need to retainUntilComplete() since the success and failure
// handlers both close over a strong reference to self.
self.networkManager.makeRequest( self.networkManager.makeRequest(
request, request,
success: { (_: URLSessionDataTask?, responseObject: Any?) -> Void in success: { (_: URLSessionDataTask?, responseObject: Any?) -> Void in

@ -685,7 +685,7 @@ typedef enum : NSUInteger {
[result addObject:recipientId]; [result addObject:recipientId];
} }
} }
return result; return [result copy];
} }
- (void)ensureBannerState - (void)ensureBannerState
@ -838,7 +838,7 @@ typedef enum : NSUInteger {
preferredStyle:UIAlertControllerStyleActionSheet]; preferredStyle:UIAlertControllerStyleActionSheet];
__weak MessagesViewController *weakSelf = self; __weak MessagesViewController *weakSelf = self;
UIAlertAction *unblockAction = [UIAlertAction UIAlertAction *verifyAction = [UIAlertAction
actionWithTitle: actionWithTitle:
NSLocalizedString(@"VERIFY_PRIVACY", NSLocalizedString(@"VERIFY_PRIVACY",
@"Label for button or row which allows users to verify the safety number of another user.") @"Label for button or row which allows users to verify the safety number of another user.")
@ -846,7 +846,7 @@ typedef enum : NSUInteger {
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
[weakSelf showConversationSettingsAndShowVerification:YES]; [weakSelf showConversationSettingsAndShowVerification:YES];
}]; }];
[actionSheetController addAction:unblockAction]; [actionSheetController addAction:verifyAction];
UIAlertAction *dismissAction = UIAlertAction *dismissAction =
[UIAlertAction actionWithTitle:NSLocalizedString(@"DISMISS_BUTTON_TEXT", [UIAlertAction actionWithTitle:NSLocalizedString(@"DISMISS_BUTTON_TEXT",
@ -882,7 +882,7 @@ typedef enum : NSUInteger {
[OWSIdentityManager.sharedManager setVerificationState:OWSVerificationStateDefault [OWSIdentityManager.sharedManager setVerificationState:OWSVerificationStateDefault
identityKey:identityKey identityKey:identityKey
recipientId:recipientId recipientId:recipientId
sendSyncMessage:YES]; isUserInitiatedChange:YES];
} }
} }
@ -1308,7 +1308,7 @@ typedef enum : NSUInteger {
} }
// Bubbles // Bubbles
self.collectionView.collectionViewLayout.bubbleSizeCalculator = [[OWSMessagesBubblesSizeCalculator alloc] init]; self.collectionView.collectionViewLayout.bubbleSizeCalculator = [OWSMessagesBubblesSizeCalculator new];
JSQMessagesBubbleImageFactory *bubbleFactory = [[JSQMessagesBubbleImageFactory alloc] init]; JSQMessagesBubbleImageFactory *bubbleFactory = [[JSQMessagesBubbleImageFactory alloc] init];
self.incomingBubbleImageData = self.incomingBubbleImageData =
[bubbleFactory incomingMessagesBubbleImageWithColor:[UIColor jsq_messageBubbleLightGrayColor]]; [bubbleFactory incomingMessagesBubbleImageWithColor:[UIColor jsq_messageBubbleLightGrayColor]];
@ -1341,7 +1341,7 @@ typedef enum : NSUInteger {
// return from FingerprintViewController. // return from FingerprintViewController.
[self dismissKeyBoard]; [self dismissKeyBoard];
[FingerprintViewController showVerificationViewFromViewController:self recipientId:recipientId]; [FingerprintViewController presentFromViewController:self recipientId:recipientId];
} }
#pragma mark - Calls #pragma mark - Calls

@ -90,10 +90,10 @@ NS_ASSUME_NONNULL_BEGIN
NSData *identityKey = NSData *identityKey =
[identityManger identityKeyForRecipientId:recipientId]; [identityManger identityKeyForRecipientId:recipientId];
[[OWSIdentityManager sharedManager] [[OWSIdentityManager sharedManager]
setVerificationState:OWSVerificationStateDefault setVerificationState:OWSVerificationStateDefault
identityKey:identityKey identityKey:identityKey
recipientId:recipientId recipientId:recipientId
sendSyncMessage:NO]; isUserInitiatedChange:NO];
}]]; }]];
[alertController addAction:[UIAlertAction actionWithTitle:@"Verified" [alertController addAction:[UIAlertAction actionWithTitle:@"Verified"
style:UIAlertActionStyleDefault style:UIAlertActionStyleDefault
@ -101,10 +101,10 @@ NS_ASSUME_NONNULL_BEGIN
NSData *identityKey = NSData *identityKey =
[identityManger identityKeyForRecipientId:recipientId]; [identityManger identityKeyForRecipientId:recipientId];
[[OWSIdentityManager sharedManager] [[OWSIdentityManager sharedManager]
setVerificationState:OWSVerificationStateVerified setVerificationState:OWSVerificationStateVerified
identityKey:identityKey identityKey:identityKey
recipientId:recipientId recipientId:recipientId
sendSyncMessage:NO]; isUserInitiatedChange:NO];
}]]; }]];
[alertController addAction:[UIAlertAction actionWithTitle:@"No Longer Verified" [alertController addAction:[UIAlertAction actionWithTitle:@"No Longer Verified"
style:UIAlertActionStyleDefault style:UIAlertActionStyleDefault
@ -112,10 +112,10 @@ NS_ASSUME_NONNULL_BEGIN
NSData *identityKey = NSData *identityKey =
[identityManger identityKeyForRecipientId:recipientId]; [identityManger identityKeyForRecipientId:recipientId];
[[OWSIdentityManager sharedManager] [[OWSIdentityManager sharedManager]
setVerificationState:OWSVerificationStateNoLongerVerified setVerificationState:OWSVerificationStateNoLongerVerified
identityKey:identityKey identityKey:identityKey
recipientId:recipientId recipientId:recipientId
sendSyncMessage:NO]; isUserInitiatedChange:NO];
}]]; }]];
[[UIApplication sharedApplication].frontmostViewController presentViewController:alertController [[UIApplication sharedApplication].frontmostViewController presentViewController:alertController

@ -69,7 +69,7 @@ NS_ASSUME_NONNULL_BEGIN
[OWSIdentityManager.sharedManager setVerificationState:verificationState [OWSIdentityManager.sharedManager setVerificationState:verificationState
identityKey:identityKey identityKey:identityKey
recipientId:recipientId recipientId:recipientId
sendSyncMessage:verificationState != OWSVerificationStateNoLongerVerified]; isUserInitiatedChange:verificationState != OWSVerificationStateNoLongerVerified];
} }
@end @end

@ -6,7 +6,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface FingerprintViewController : UIViewController @interface FingerprintViewController : UIViewController
+ (void)showVerificationViewFromViewController:(UIViewController *)viewController recipientId:(NSString *)recipientId; + (void)presentFromViewController:(UIViewController *)viewController recipientId:(NSString *)recipientId;
@end @end

@ -89,7 +89,7 @@ typedef void (^CustomLayoutBlock)();
@implementation FingerprintViewController @implementation FingerprintViewController
+ (void)showVerificationViewFromViewController:(UIViewController *)viewController recipientId:(NSString *)recipientId + (void)presentFromViewController:(UIViewController *)viewController recipientId:(NSString *)recipientId
{ {
OWSAssert(recipientId.length > 0); OWSAssert(recipientId.length > 0);
@ -510,10 +510,10 @@ typedef void (^CustomLayoutBlock)();
BOOL isVerified = [[OWSIdentityManager sharedManager] verificationStateForRecipientId:self.recipientId] BOOL isVerified = [[OWSIdentityManager sharedManager] verificationStateForRecipientId:self.recipientId]
== OWSVerificationStateVerified; == OWSVerificationStateVerified;
[[OWSIdentityManager sharedManager] [[OWSIdentityManager sharedManager]
setVerificationState:(isVerified ? OWSVerificationStateDefault : OWSVerificationStateVerified)identityKey setVerificationState:(isVerified ? OWSVerificationStateDefault : OWSVerificationStateVerified)identityKey
:self.identityKey :self.identityKey
recipientId:self.recipientId recipientId:self.recipientId
sendSyncMessage:YES]; isUserInitiatedChange:YES];
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
} }

@ -205,7 +205,7 @@ NS_ASSUME_NONNULL_BEGIN
[OWSIdentityManager.sharedManager setVerificationState:OWSVerificationStateVerified [OWSIdentityManager.sharedManager setVerificationState:OWSVerificationStateVerified
identityKey:identityKey identityKey:identityKey
recipientId:recipientId recipientId:recipientId
sendSyncMessage:YES]; isUserInitiatedChange:YES];
[viewController dismissViewControllerAnimated:true completion:nil]; [viewController dismissViewControllerAnimated:true completion:nil];
}]]; }]];
UIAlertAction *dismissAction = UIAlertAction *dismissAction =

@ -679,7 +679,7 @@ NS_ASSUME_NONNULL_BEGIN
NSString *recipientId = self.thread.contactIdentifier; NSString *recipientId = self.thread.contactIdentifier;
OWSAssert(recipientId.length > 0); OWSAssert(recipientId.length > 0);
[FingerprintViewController showVerificationViewFromViewController:self recipientId:recipientId]; [FingerprintViewController presentFromViewController:self recipientId:recipientId];
} }
- (void)showGroupMembersView - (void)showGroupMembersView

@ -55,7 +55,7 @@ class SafetyNumberConfirmationAlert: NSObject {
Logger.info("\(self.TAG) Confirmed identity: \(untrustedIdentity)") Logger.info("\(self.TAG) Confirmed identity: \(untrustedIdentity)")
OWSDispatch.sessionStoreQueue().async { OWSDispatch.sessionStoreQueue().async {
OWSIdentityManager.shared().setVerificationState(.default, identityKey: untrustedIdentity.identityKey, recipientId: untrustedIdentity.recipientId, sendSyncMessage: true) OWSIdentityManager.shared().setVerificationState(.default, identityKey: untrustedIdentity.identityKey, recipientId: untrustedIdentity.recipientId, isUserInitiatedChange: true)
DispatchQueue.main.async { DispatchQueue.main.async {
completion(true) completion(true)
} }
@ -86,7 +86,7 @@ class SafetyNumberConfirmationAlert: NSObject {
Logger.info("\(self.TAG) Missing frontmostViewController") Logger.info("\(self.TAG) Missing frontmostViewController")
return return
} }
FingerprintViewController.showVerificationView(from:fromViewController, recipientId:theirRecipientId) FingerprintViewController.present(from:fromViewController, recipientId:theirRecipientId)
} }
private func untrustedIdentityForSending(recipientIds: [String]) -> OWSRecipientIdentity? { private func untrustedIdentityForSending(recipientIds: [String]) -> OWSRecipientIdentity? {

@ -317,7 +317,7 @@ NS_ASSUME_NONNULL_BEGIN
{ {
OWSAssert(recipientId.length > 0); OWSAssert(recipientId.length > 0);
[FingerprintViewController showVerificationViewFromViewController:self recipientId:recipientId]; [FingerprintViewController presentFromViewController:self recipientId:recipientId];
} }
#pragma mark - ContactsViewHelperDelegate #pragma mark - ContactsViewHelperDelegate

@ -31,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSSystemMessageCell @implementation OWSSystemMessageCell
// `[UIView init]` invokes `[self initWithFrame:...]`.
- (instancetype)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
{ {
if (self = [super initWithFrame:frame]) { if (self = [super initWithFrame:frame]) {
@ -40,21 +41,9 @@ NS_ASSUME_NONNULL_BEGIN
return self; return self;
} }
- (instancetype)init
{
if (self = [super init]) {
[self commontInit];
}
return self;
}
- (void)commontInit - (void)commontInit
{ {
if (self.imageView) { OWSAssert(!self.imageView);
// Don't init twice.
return;
}
[self setTranslatesAutoresizingMaskIntoConstraints:NO]; [self setTranslatesAutoresizingMaskIntoConstraints:NO];

@ -29,6 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSUnreadIndicatorCell @implementation OWSUnreadIndicatorCell
// `[UIView init]` invokes `[self initWithFrame:...]`.
- (instancetype)initWithFrame:(CGRect)frame - (instancetype)initWithFrame:(CGRect)frame
{ {
if (self = [super initWithFrame:frame]) { if (self = [super initWithFrame:frame]) {
@ -38,21 +39,9 @@ NS_ASSUME_NONNULL_BEGIN
return self; return self;
} }
- (instancetype)init
{
if (self = [super init]) {
[self commontInit];
}
return self;
}
- (void)commontInit - (void)commontInit
{ {
if (self.bannerView) { OWSAssert(!self.bannerView);
// Don't init twice.
return;
}
[self setTranslatesAutoresizingMaskIntoConstraints:NO]; [self setTranslatesAutoresizingMaskIntoConstraints:NO];

@ -728,13 +728,13 @@
"MESSAGE_STATUS_UPLOADING" = "Uploading…"; "MESSAGE_STATUS_UPLOADING" = "Uploading…";
/* Indicates that one member of this group conversation is no longer verified. Embeds {{user's name or phone number}}. */ /* Indicates that one member of this group conversation is no longer verified. Embeds {{user's name or phone number}}. */
"MESSAGES_VIEW_1_MEMBER_NO_LONGER_VERIFIED_FORMAT" = "%@ is no longer verified. Tap for options."; "MESSAGES_VIEW_1_MEMBER_NO_LONGER_VERIFIED_FORMAT" = "%@ is no longer marked as verified. Tap for options.";
/* Indicates that this 1:1 conversation has been blocked. */ /* Indicates that this 1:1 conversation has been blocked. */
"MESSAGES_VIEW_CONTACT_BLOCKED" = "You Blocked this User"; "MESSAGES_VIEW_CONTACT_BLOCKED" = "You Blocked this User";
/* Indicates that this 1:1 conversation is no longer verified. Embeds {{user's name or phone number}}. */ /* Indicates that this 1:1 conversation is no longer verified. Embeds {{user's name or phone number}}. */
"MESSAGES_VIEW_CONTACT_NO_LONGER_VERIFIED_FORMAT" = "%@ is no longer verified. Tap for options."; "MESSAGES_VIEW_CONTACT_NO_LONGER_VERIFIED_FORMAT" = "%@ is no longer marked as verified. Tap for options.";
/* Action sheet title after tapping on failed download. */ /* Action sheet title after tapping on failed download. */
"MESSAGES_VIEW_FAILED_DOWNLOAD_ACTIONSHEET_TITLE" = "Download Failed."; "MESSAGES_VIEW_FAILED_DOWNLOAD_ACTIONSHEET_TITLE" = "Download Failed.";
@ -749,7 +749,7 @@
"MESSAGES_VIEW_GROUP_N_MEMBERS_BLOCKED_FORMAT" = "You Blocked %d Members of this Group"; "MESSAGES_VIEW_GROUP_N_MEMBERS_BLOCKED_FORMAT" = "You Blocked %d Members of this Group";
/* Indicates that more than one member of this group conversation is no longer verified. */ /* Indicates that more than one member of this group conversation is no longer verified. */
"MESSAGES_VIEW_N_MEMBERS_NO_LONGER_VERIFIED" = "More than one member of this group is no longer verified. Tap for options."; "MESSAGES_VIEW_N_MEMBERS_NO_LONGER_VERIFIED" = "More than one member of this group is no longer marked as verified. Tap for options.";
/* The subtitle for the messages view title indicates that the title can be tapped to access settings for this conversation. */ /* The subtitle for the messages view title indicates that the title can be tapped to access settings for this conversation. */
"MESSAGES_VIEW_TITLE_SUBTITLE" = "Tap here for settings"; "MESSAGES_VIEW_TITLE_SUBTITLE" = "Tap here for settings";
@ -962,7 +962,7 @@
"PHONE_NUMBER_TYPE_WORK_FAX" = "Work Fax"; "PHONE_NUMBER_TYPE_WORK_FAX" = "Work Fax";
/* Label indicating that the user is not verified. Embeds {{the user's name or phone number}}. */ /* Label indicating that the user is not verified. Embeds {{the user's name or phone number}}. */
"PRIVACY_IDENTITY_IS_NOT_VERIFIED_FORMAT" = "%@ is not verified."; "PRIVACY_IDENTITY_IS_NOT_VERIFIED_FORMAT" = "You have not marked %@ as verified.";
/* Badge indicating that the user is verified. */ /* Badge indicating that the user is verified. */
"PRIVACY_IDENTITY_IS_VERIFIED_BADGE" = "Verified"; "PRIVACY_IDENTITY_IS_VERIFIED_BADGE" = "Verified";

Loading…
Cancel
Save