Step 2/2 %s/OWSAssert/OWSAssertDebug for existing previous assert semantics

Going forward, we want to prefer safer asserts, but we don't want to blindly
apply crashing asserts across the codebase
This commit is contained in:
Michael Kirk 2018-09-06 11:01:24 -06:00
parent a54ed8b201
commit c7662b5a86
223 changed files with 2280 additions and 2280 deletions

View File

@ -307,7 +307,7 @@ static NSTimeInterval launchStartedAt;
return NO;
}
OWSAssert(backgroundTask);
OWSAssertDebug(backgroundTask);
backgroundTask = nil;
return YES;
@ -781,7 +781,7 @@ static NSTimeInterval launchStartedAt;
}
OutboundCallInitiator *outboundCallInitiator = SignalApp.sharedApp.outboundCallInitiator;
OWSAssert(outboundCallInitiator);
OWSAssertDebug(outboundCallInitiator);
[outboundCallInitiator initiateCallWithHandle:phoneNumber];
}];
return YES;
@ -824,7 +824,7 @@ static NSTimeInterval launchStartedAt;
}
OutboundCallInitiator *outboundCallInitiator = SignalApp.sharedApp.outboundCallInitiator;
OWSAssert(outboundCallInitiator);
OWSAssertDebug(outboundCallInitiator);
[outboundCallInitiator initiateCallWithHandle:phoneNumber];
}];
return YES;

View File

@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)phoneNumberWasSelected:(NSString *)phoneNumber
{
OWSAssert(phoneNumber.length > 0);
OWSAssertDebug(phoneNumber.length > 0);
__weak AddToBlockListViewController *weakSelf = self;
[BlockListUIUtils showBlockPhoneNumberActionSheet:phoneNumber
@ -62,7 +62,7 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)canSignalAccountBeSelected:(SignalAccount *)signalAccount
{
OWSAssert(signalAccount);
OWSAssertDebug(signalAccount);
ContactsViewHelper *helper = self.contactsViewHelper;
return ![helper isRecipientIdBlocked:signalAccount.recipientId];
@ -70,7 +70,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)signalAccountWasSelected:(SignalAccount *)signalAccount
{
OWSAssert(signalAccount);
OWSAssertDebug(signalAccount);
__weak AddToBlockListViewController *weakSelf = self;
ContactsViewHelper *helper = self.contactsViewHelper;

View File

@ -182,7 +182,7 @@ NS_ASSUME_NONNULL_BEGIN
if (OWSSignalService.sharedInstance.isCensorshipCircumventionManuallyActivated) {
OWSCountryMetadata *manualCensorshipCircumventionCountry =
[weakSelf ensureManualCensorshipCircumventionCountry];
OWSAssert(manualCensorshipCircumventionCountry);
OWSAssertDebug(manualCensorshipCircumventionCountry);
NSString *text = [NSString
stringWithFormat:NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION_COUNTRY_FORMAT",
@"Label for the 'manual censorship circumvention' country. Embeds {{the manual "
@ -235,7 +235,7 @@ NS_ASSUME_NONNULL_BEGIN
if (!countryMetadata) {
countryCode = @"US";
countryMetadata = [OWSCountryMetadata countryMetadataForCountryCode:countryCode];
OWSAssert(countryMetadata);
OWSAssertDebug(countryMetadata);
}
if (countryMetadata) {

View File

@ -79,7 +79,7 @@
[super viewDidLoad];
[self.navigationItem setHidesBackButton:YES];
OWSAssert([self.navigationController isKindOfClass:[OWSNavigationController class]]);
OWSAssertDebug([self.navigationController isKindOfClass:[OWSNavigationController class]]);
self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop
@ -286,7 +286,7 @@
UIImage *avatarImage = (localProfileAvatarImage
?: [[UIImage imageNamed:@"profile_avatar_default"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]);
OWSAssert(avatarImage);
OWSAssertDebug(avatarImage);
AvatarImageView *avatarView = [[AvatarImageView alloc] initWithImage:avatarImage];
if (!localProfileAvatarImage) {
@ -342,7 +342,7 @@
[subtitleLabel autoPinEdgeToSuperviewEdge:ALEdgeBottom];
UIImage *disclosureImage = [UIImage imageNamed:(CurrentAppContext().isRTL ? @"NavBarBack" : @"NavBarBackRTL")];
OWSAssert(disclosureImage);
OWSAssertDebug(disclosureImage);
UIImageView *disclosureButton =
[[UIImageView alloc] initWithImage:[disclosureImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];
disclosureButton.tintColor = [UIColor colorWithRGBHex:0xcccccc];

View File

@ -84,7 +84,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)selectCountry:(OWSCountryMetadata *)countryMetadata
{
OWSAssert(countryMetadata);
OWSAssertDebug(countryMetadata);
OWSSignalService.sharedInstance.manualCensorshipCircumventionCountryCode = countryMetadata.countryCode;

View File

@ -148,7 +148,7 @@ NS_ASSUME_NONNULL_BEGIN
[OWSDeviceManager.sharedManager setMayHaveLinkedDevices];
ECKeyPair *_Nullable identityKeyPair = [[OWSIdentityManager sharedManager] identityKeyPair];
OWSAssert(identityKeyPair);
OWSAssertDebug(identityKeyPair);
NSData *myPublicKey = identityKeyPair.publicKey;
NSData *myPrivateKey = identityKeyPair.privateKey;
NSString *accountIdentifier = [TSAccountManager localNumber];

View File

@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)showChangeAvatarUI
{
OWSAssertIsOnMainThread();
OWSAssert(self.delegate);
OWSAssertDebug(self.delegate);
UIAlertController *actionSheetController =
[UIAlertController alertControllerWithTitle:self.delegate.avatarActionSheetTitle
@ -67,7 +67,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)takePicture
{
OWSAssertIsOnMainThread();
OWSAssert(self.delegate);
OWSAssertDebug(self.delegate);
[self.delegate.fromViewController ows_askForCameraPermissions:^(BOOL granted) {
if (!granted) {
@ -88,7 +88,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)chooseFromLibrary
{
OWSAssertIsOnMainThread();
OWSAssert(self.delegate);
OWSAssertDebug(self.delegate);
[self.delegate.fromViewController ows_askForMediaLibraryPermissions:^(BOOL granted) {
if (!granted) {
@ -112,7 +112,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
OWSAssertIsOnMainThread();
OWSAssert(self.delegate);
OWSAssertDebug(self.delegate);
[self.delegate.fromViewController dismissViewControllerAnimated:YES completion:nil];
}
@ -123,7 +123,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
OWSAssertIsOnMainThread();
OWSAssert(self.delegate);
OWSAssertDebug(self.delegate);
UIImage *rawAvatar = [info objectForKey:UIImagePickerControllerOriginalImage];

View File

@ -39,7 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
self = [super init];
if (self) {
OWSAssert(attachment);
OWSAssertDebug(attachment);
self.attachment = attachment;
self.attachmentStateCallback = attachmentStateCallback;

View File

@ -66,7 +66,7 @@ NS_ASSUME_NONNULL_BEGIN
- (CGFloat)audioDurationSeconds
{
OWSAssert(self.viewItem.audioDurationSeconds > 0.f);
OWSAssertDebug(self.viewItem.audioDurationSeconds > 0.f);
return self.viewItem.audioDurationSeconds;
}
@ -96,7 +96,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setAudioIcon:(UIImage *)icon
{
OWSAssert(icon.size.height == self.iconSize);
OWSAssertDebug(icon.size.height == self.iconSize);
icon = [icon imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[_audioPlayPauseButton setImage:icon forState:UIControlStateNormal];

View File

@ -245,7 +245,7 @@ const CGFloat kOWSMessageCellCornerRadius_Small = 4;
- (void)addPartnerView:(id<OWSBubbleViewPartner>)partnerView
{
OWSAssert(self.partnerViews);
OWSAssertDebug(self.partnerViews);
[partnerView setBubbleView:self];
@ -254,7 +254,7 @@ const CGFloat kOWSMessageCellCornerRadius_Small = 4;
- (void)clearPartnerViews
{
OWSAssert(self.partnerViews);
OWSAssertDebug(self.partnerViews);
[self.partnerViews removeAllObjects];
}

View File

@ -39,7 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)commontInit
{
OWSAssert(!self.titleLabel);
OWSAssertDebug(!self.titleLabel);
self.layoutMargins = UIEdgeInsetsZero;
self.contentView.layoutMargins = UIEdgeInsetsZero;
@ -110,10 +110,10 @@ NS_ASSUME_NONNULL_BEGIN
- (void)loadForDisplay
{
OWSAssert(self.conversationStyle);
OWSAssert(self.conversationStyle.viewWidth > 0);
OWSAssert(self.viewItem);
OWSAssert([self.viewItem.interaction isKindOfClass:[OWSContactOffersInteraction class]]);
OWSAssertDebug(self.conversationStyle);
OWSAssertDebug(self.conversationStyle.viewWidth > 0);
OWSAssertDebug(self.viewItem);
OWSAssertDebug([self.viewItem.interaction isKindOfClass:[OWSContactOffersInteraction class]]);
self.backgroundColor = [Theme backgroundColor];
@ -131,7 +131,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSContactOffersInteraction *interaction = (OWSContactOffersInteraction *)self.viewItem.interaction;
OWSAssert(
OWSAssertDebug(
interaction.hasBlockOffer || interaction.hasAddToContactsOffer || interaction.hasAddToProfileWhitelistOffer);
self.addToContactsButton.hidden = !interaction.hasAddToContactsOffer;
@ -175,10 +175,10 @@ NS_ASSUME_NONNULL_BEGIN
- (CGSize)cellSize
{
OWSAssert(self.conversationStyle);
OWSAssert(self.conversationStyle.viewWidth > 0);
OWSAssert(self.viewItem);
OWSAssert([self.viewItem.interaction isKindOfClass:[OWSContactOffersInteraction class]]);
OWSAssertDebug(self.conversationStyle);
OWSAssertDebug(self.conversationStyle.viewWidth > 0);
OWSAssertDebug(self.viewItem);
OWSAssertDebug([self.viewItem.interaction isKindOfClass:[OWSContactOffersInteraction class]]);
[self configureFonts];
@ -201,8 +201,8 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable OWSContactOffersInteraction *)interaction
{
OWSAssert(self.viewItem);
OWSAssert(self.viewItem.interaction);
OWSAssertDebug(self.viewItem);
OWSAssertDebug(self.viewItem.interaction);
if (![self.viewItem.interaction isKindOfClass:[OWSContactOffersInteraction class]]) {
OWSFailDebug(@"expected OWSContactOffersInteraction but found: %@", self.viewItem.interaction);
return nil;
@ -212,24 +212,24 @@ NS_ASSUME_NONNULL_BEGIN
- (void)addToContacts
{
OWSAssert(self.delegate);
OWSAssert(self.interaction);
OWSAssertDebug(self.delegate);
OWSAssertDebug(self.interaction);
[self.delegate tappedAddToContactsOfferMessage:self.interaction];
}
- (void)addToProfileWhitelist
{
OWSAssert(self.delegate);
OWSAssert(self.interaction);
OWSAssertDebug(self.delegate);
OWSAssertDebug(self.interaction);
[self.delegate tappedAddToProfileWhitelistOfferMessage:self.interaction];
}
- (void)block
{
OWSAssert(self.delegate);
OWSAssert(self.interaction);
OWSAssertDebug(self.delegate);
OWSAssertDebug(self.interaction);
[self.delegate tappedUnknownContactBlockOfferMessage:self.interaction];
}

View File

@ -49,30 +49,30 @@ NS_ASSUME_NONNULL_BEGIN
+ (BOOL)hasSendTextButton:(ContactShareViewModel *)contactShare contactsManager:(OWSContactsManager *)contactsManager
{
OWSAssert(contactShare);
OWSAssert(contactsManager);
OWSAssertDebug(contactShare);
OWSAssertDebug(contactsManager);
return [contactShare systemContactsWithSignalAccountPhoneNumbers:contactsManager].count > 0;
}
+ (BOOL)hasInviteButton:(ContactShareViewModel *)contactShare contactsManager:(OWSContactsManager *)contactsManager
{
OWSAssert(contactShare);
OWSAssert(contactsManager);
OWSAssertDebug(contactShare);
OWSAssertDebug(contactsManager);
return [contactShare systemContactPhoneNumbers:contactsManager].count > 0;
}
+ (BOOL)hasAddToContactsButton:(ContactShareViewModel *)contactShare
{
OWSAssert(contactShare);
OWSAssertDebug(contactShare);
return [contactShare e164PhoneNumbers].count > 0;
}
+ (BOOL)hasAnyButton:(ContactShareViewModel *)contactShare
{
OWSAssert(contactShare);
OWSAssertDebug(contactShare);
OWSContactsManager *contactsManager = [Environment current].contactsManager;
@ -81,7 +81,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (BOOL)hasAnyButton:(ContactShareViewModel *)contactShare contactsManager:(OWSContactsManager *)contactsManager
{
OWSAssert(contactShare);
OWSAssertDebug(contactShare);
return ([self hasSendTextButton:contactShare contactsManager:contactsManager] ||
[self hasInviteButton:contactShare contactsManager:contactsManager] ||
@ -110,7 +110,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)createContents
{
OWSAssert([OWSContactShareButtonsView hasAnyButton:self.contactShare contactsManager:self.contactsManager]);
OWSAssertDebug([OWSContactShareButtonsView hasAnyButton:self.contactShare contactsManager:self.contactsManager]);
self.layoutMargins = UIEdgeInsetsZero;
self.backgroundColor = Theme.conversationButtonBackgroundColor;

View File

@ -139,7 +139,7 @@ NS_ASSUME_NONNULL_BEGIN
UIImage *disclosureImage =
[UIImage imageNamed:(CurrentAppContext().isRTL ? @"small_chevron_left" : @"small_chevron_right")];
OWSAssert(disclosureImage);
OWSAssertDebug(disclosureImage);
UIImageView *disclosureImageView = [UIImageView new];
disclosureImageView.image = [disclosureImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
disclosureImageView.tintColor = textColor;

View File

@ -87,7 +87,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)createContentsWithConversationStyle:(ConversationStyle *)conversationStyle
{
OWSAssert(conversationStyle);
OWSAssertDebug(conversationStyle);
self.axis = UILayoutConstraintAxisHorizontal;
self.alignment = UIStackViewAlignmentCenter;
@ -97,9 +97,9 @@ NS_ASSUME_NONNULL_BEGIN
// attachment_file
UIImage *image = [UIImage imageNamed:@"generic-attachment"];
OWSAssert(image);
OWSAssert(image.size.width == self.iconWidth);
OWSAssert(image.size.height == self.iconHeight);
OWSAssertDebug(image);
OWSAssertDebug(image.size.width == self.iconWidth);
OWSAssertDebug(image.size.height == self.iconHeight);
UIImageView *imageView = [UIImageView new];
imageView.image = image;
[self addArrangedSubview:imageView];
@ -150,7 +150,7 @@ NS_ASSUME_NONNULL_BEGIN
NSError *error;
unsigned long long fileSize =
[[NSFileManager defaultManager] attributesOfItemAtPath:[self.attachmentStream filePath] error:&error].fileSize;
OWSAssert(!error);
OWSAssertDebug(!error);
NSString *bottomText = [OWSFormat formatFileSize:fileSize];
UILabel *bottomLabel = [UILabel new];
self.bottomLabel = bottomLabel;

View File

@ -74,7 +74,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (void)commontInit
{
// Ensure only called once.
OWSAssert(!self.bodyTextView);
OWSAssertDebug(!self.bodyTextView);
_viewConstraints = [NSMutableArray new];
@ -119,7 +119,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (UIFont *)textMessageFont
{
OWSAssert(DisplayableText.kMaxJumbomojiCount == 5);
OWSAssertDebug(DisplayableText.kMaxJumbomojiCount == 5);
CGFloat basePointSize = UIFont.ows_dynamicTypeBodyFont.pointSize;
switch (self.displayableBodyText.jumbomojiCount) {
@ -151,7 +151,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (BOOL)hasBodyText
{
// This should always be valid for the appropriate cell types.
OWSAssert(self.viewItem);
OWSAssertDebug(self.viewItem);
return self.viewItem.hasBodyText;
}
@ -159,7 +159,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (nullable DisplayableText *)displayableBodyText
{
// This should always be valid for the appropriate cell types.
OWSAssert(self.viewItem.displayableBodyText);
OWSAssertDebug(self.viewItem.displayableBodyText);
return self.viewItem.displayableBodyText;
}
@ -167,7 +167,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (nullable TSAttachmentStream *)attachmentStream
{
// This should always be valid for the appropriate cell types.
OWSAssert(self.viewItem.attachmentStream);
OWSAssertDebug(self.viewItem.attachmentStream);
return self.viewItem.attachmentStream;
}
@ -175,14 +175,14 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (nullable TSAttachmentPointer *)attachmentPointer
{
// This should always be valid for the appropriate cell types.
OWSAssert(self.viewItem.attachmentPointer);
OWSAssertDebug(self.viewItem.attachmentPointer);
return self.viewItem.attachmentPointer;
}
- (TSMessage *)message
{
OWSAssert([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
OWSAssertDebug([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
return (TSMessage *)self.viewItem.interaction;
}
@ -190,7 +190,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (CGSize)mediaSize
{
// This should always be valid for the appropriate cell types.
OWSAssert(self.viewItem.mediaSize.width > 0 && self.viewItem.mediaSize.height > 0);
OWSAssertDebug(self.viewItem.mediaSize.width > 0 && self.viewItem.mediaSize.height > 0);
return self.viewItem.mediaSize;
}
@ -198,7 +198,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (BOOL)isQuotedReply
{
// This should always be valid for the appropriate cell types.
OWSAssert(self.viewItem);
OWSAssertDebug(self.viewItem);
return self.viewItem.isQuotedReply;
}
@ -206,7 +206,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (BOOL)hasQuotedText
{
// This should always be valid for the appropriate cell types.
OWSAssert(self.viewItem);
OWSAssertDebug(self.viewItem);
return self.viewItem.hasQuotedText;
}
@ -247,10 +247,10 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (void)configureViews
{
OWSAssert(self.conversationStyle);
OWSAssert(self.viewItem);
OWSAssert(self.viewItem.interaction);
OWSAssert([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
OWSAssertDebug(self.conversationStyle);
OWSAssertDebug(self.viewItem);
OWSAssertDebug(self.viewItem.interaction);
OWSAssertDebug([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
NSValue *_Nullable quotedMessageSize = [self quotedMessageSize];
NSValue *_Nullable bodyMediaSize = [self bodyMediaSize];
@ -291,7 +291,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
self.quotedMessageView = quotedMessageView;
[quotedMessageView createContents];
[self.stackView addArrangedSubview:quotedMessageView];
OWSAssert(quotedMessageSize);
OWSAssertDebug(quotedMessageSize);
[self.viewConstraints addObject:[quotedMessageView autoSetDimension:ALDimensionHeight
toSize:quotedMessageSize.CGSizeValue.height]];
}
@ -303,19 +303,19 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
case OWSMessageCellType_OversizeTextMessage:
break;
case OWSMessageCellType_StillImage:
OWSAssert(self.viewItem.attachmentStream);
OWSAssertDebug(self.viewItem.attachmentStream);
bodyMediaView = [self loadViewForStillImage];
break;
case OWSMessageCellType_AnimatedImage:
OWSAssert(self.viewItem.attachmentStream);
OWSAssertDebug(self.viewItem.attachmentStream);
bodyMediaView = [self loadViewForAnimatedImage];
break;
case OWSMessageCellType_Video:
OWSAssert(self.viewItem.attachmentStream);
OWSAssertDebug(self.viewItem.attachmentStream);
bodyMediaView = [self loadViewForVideo];
break;
case OWSMessageCellType_Audio:
OWSAssert(self.viewItem.attachmentStream);
OWSAssertDebug(self.viewItem.attachmentStream);
bodyMediaView = [self loadViewForAudio];
break;
case OWSMessageCellType_GenericAttachment:
@ -330,8 +330,8 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
}
if (bodyMediaView) {
OWSAssert(self.loadCellContentBlock);
OWSAssert(self.unloadCellContentBlock);
OWSAssertDebug(self.loadCellContentBlock);
OWSAssertDebug(self.unloadCellContentBlock);
bodyMediaView.clipsToBounds = YES;
@ -360,7 +360,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
[self.bubbleView addPartnerView:strokeView];
[self.viewConstraints addObjectsFromArray:[strokeView ows_autoPinToSuperviewEdges]];
} else {
OWSAssert(self.cellType == OWSMessageCellType_ContactShare);
OWSAssertDebug(self.cellType == OWSMessageCellType_ContactShare);
if (self.contactShareHasSpacerTop) {
UIView *spacerView = [UIView containerView];
@ -389,7 +389,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
[self configureBodyTextView];
[textViews addObject:self.bodyTextView];
OWSAssert(bodyTextSize);
OWSAssertDebug(bodyTextSize);
[self.viewConstraints addObjectsFromArray:@[
[self.bodyTextView autoSetDimension:ALDimensionHeight toSize:bodyTextSize.CGSizeValue.height],
]];
@ -407,7 +407,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
if (self.viewItem.shouldHideFooter) {
// Do nothing.
} else if (shouldFooterOverlayMedia) {
OWSAssert(bodyMediaView);
OWSAssertDebug(bodyMediaView);
CGFloat maxGradientHeight = 40.f;
CAGradientLayer *gradientLayer = [CAGradientLayer new];
@ -455,7 +455,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
[self autoSetDimension:ALDimensionWidth toSize:bubbleSize.width],
]];
if (bodyMediaView) {
OWSAssert(bodyMediaSize);
OWSAssertDebug(bodyMediaSize);
[self.viewConstraints
addObject:[bodyMediaView autoSetDimension:ALDimensionHeight toSize:bodyMediaSize.CGSizeValue.height]];
}
@ -477,13 +477,13 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
return;
}
OWSAssert(self.viewItem.contactShare);
OWSAssertDebug(self.viewItem.contactShare);
OWSContactShareButtonsView *buttonsView =
[[OWSContactShareButtonsView alloc] initWithContactShare:self.viewItem.contactShare delegate:self];
NSValue *_Nullable actionButtonsSize = [self actionButtonsSize];
OWSAssert(actionButtonsSize);
OWSAssertDebug(actionButtonsSize);
[self.viewConstraints addObjectsFromArray:@[
[buttonsView autoSetDimension:ALDimensionHeight toSize:actionButtonsSize.CGSizeValue.height],
]];
@ -515,7 +515,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
[CATransaction begin];
[CATransaction setDisableActions:YES];
OWSAssert(buttonsView.backgroundColor);
OWSAssertDebug(buttonsView.backgroundColor);
shadowView.fillColor = buttonsView.backgroundColor;
shadowView.layer.shadowColor = Theme.boldColor.CGColor;
shadowView.layer.shadowOpacity = 0.12f;
@ -590,7 +590,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (UIColor *)bubbleColor
{
OWSAssert([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
OWSAssertDebug([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
TSMessage *message = (TSMessage *)self.viewItem.interaction;
return [self.conversationStyle bubbleColorWithMessage:message];
@ -658,10 +658,10 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
cacheKey:(NSString *)cacheKey
shouldSkipCache:(BOOL)shouldSkipCache
{
OWSAssert(self.attachmentStream);
OWSAssert(mediaView);
OWSAssert(cacheKey);
OWSAssert(self.cellMediaCache);
OWSAssertDebug(self.attachmentStream);
OWSAssertDebug(mediaView);
OWSAssertDebug(cacheKey);
OWSAssertDebug(self.cellMediaCache);
if (self.viewItem.didCellMediaFailToLoad) {
return nil;
@ -721,7 +721,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (void)configureBodyTextView
{
OWSAssert(self.hasBodyText);
OWSAssertDebug(self.hasBodyText);
BOOL shouldIgnoreEvents = NO;
if (self.viewItem.interaction.interactionType == OWSInteractionType_OutgoingMessage) {
@ -765,8 +765,8 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (void)configureSenderNameLabel
{
OWSAssert(self.senderNameLabel);
OWSAssert(self.shouldShowSenderName);
OWSAssertDebug(self.senderNameLabel);
OWSAssertDebug(self.shouldShowSenderName);
self.senderNameLabel.textColor = self.bodyTextColor;
self.senderNameLabel.font = OWSMessageBubbleView.senderNameFont;
@ -824,8 +824,8 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (UIView *)loadViewForStillImage
{
OWSAssert(self.attachmentStream);
OWSAssert([self.attachmentStream isImage]);
OWSAssertDebug(self.attachmentStream);
OWSAssertDebug([self.attachmentStream isImage]);
UIImageView *stillImageView = [UIImageView new];
// We need to specify a contentMode since the size of the image
@ -844,7 +844,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
if (!strongSelf) {
return;
}
OWSCAssert(strongSelf.bodyMediaView == stillImageView);
OWSCAssertDebug(strongSelf.bodyMediaView == stillImageView);
if (stillImageView.image) {
return;
}
@ -855,7 +855,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
BOOL shouldSkipCache =
[OWSFileSystem fileSizeOfPath:strongSelf.attachmentStream.filePath].unsignedIntegerValue < kMaxCachableSize;
stillImageView.image = [strongSelf tryToLoadCellMedia:^{
OWSCAssert([strongSelf.attachmentStream isImage]);
OWSCAssertDebug([strongSelf.attachmentStream isImage]);
return strongSelf.attachmentStream.image;
}
mediaView:stillImageView
@ -867,7 +867,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
if (!strongSelf) {
return;
}
OWSCAssert(strongSelf.bodyMediaView == stillImageView);
OWSCAssertDebug(strongSelf.bodyMediaView == stillImageView);
stillImageView.image = nil;
};
@ -876,8 +876,8 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (UIView *)loadViewForAnimatedImage
{
OWSAssert(self.attachmentStream);
OWSAssert([self.attachmentStream isAnimated]);
OWSAssertDebug(self.attachmentStream);
OWSAssertDebug([self.attachmentStream isAnimated]);
YYAnimatedImageView *animatedImageView = [[YYAnimatedImageView alloc] init];
// We need to specify a contentMode since the size of the image
@ -892,12 +892,12 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
if (!strongSelf) {
return;
}
OWSCAssert(strongSelf.bodyMediaView == animatedImageView);
OWSCAssertDebug(strongSelf.bodyMediaView == animatedImageView);
if (animatedImageView.image) {
return;
}
animatedImageView.image = [strongSelf tryToLoadCellMedia:^{
OWSCAssert([strongSelf.attachmentStream isAnimated]);
OWSCAssertDebug([strongSelf.attachmentStream isAnimated]);
NSString *_Nullable filePath = [strongSelf.attachmentStream filePath];
YYImage *_Nullable animatedImage = nil;
@ -915,7 +915,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
if (!strongSelf) {
return;
}
OWSCAssert(strongSelf.bodyMediaView == animatedImageView);
OWSCAssertDebug(strongSelf.bodyMediaView == animatedImageView);
animatedImageView.image = nil;
};
@ -924,8 +924,8 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (UIView *)loadViewForAudio
{
OWSAssert(self.attachmentStream);
OWSAssert([self.attachmentStream isAudio]);
OWSAssertDebug(self.attachmentStream);
OWSAssertDebug([self.attachmentStream isAudio]);
OWSAudioMessageView *audioMessageView = [[OWSAudioMessageView alloc] initWithAttachment:self.attachmentStream
isIncoming:self.isIncoming
@ -947,8 +947,8 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (UIView *)loadViewForVideo
{
OWSAssert(self.attachmentStream);
OWSAssert([self.attachmentStream isVideo]);
OWSAssertDebug(self.attachmentStream);
OWSAssertDebug([self.attachmentStream isVideo]);
UIImageView *stillImageView = [UIImageView new];
// We need to specify a contentMode since the size of the image
@ -973,12 +973,12 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
if (!strongSelf) {
return;
}
OWSCAssert(strongSelf.bodyMediaView == stillImageView);
OWSCAssertDebug(strongSelf.bodyMediaView == stillImageView);
if (stillImageView.image) {
return;
}
stillImageView.image = [strongSelf tryToLoadCellMedia:^{
OWSCAssert([strongSelf.attachmentStream isVideo]);
OWSCAssertDebug([strongSelf.attachmentStream isVideo]);
return strongSelf.attachmentStream.image;
}
@ -991,7 +991,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
if (!strongSelf) {
return;
}
OWSCAssert(strongSelf.bodyMediaView == stillImageView);
OWSCAssertDebug(strongSelf.bodyMediaView == stillImageView);
stillImageView.image = nil;
};
@ -1000,7 +1000,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (UIView *)loadViewForGenericAttachment
{
OWSAssert(self.viewItem.attachmentStream);
OWSAssertDebug(self.viewItem.attachmentStream);
OWSGenericAttachmentView *attachmentView =
[[OWSGenericAttachmentView alloc] initWithAttachment:self.attachmentStream isIncoming:self.isIncoming];
[attachmentView createContentsWithConversationStyle:self.conversationStyle];
@ -1018,7 +1018,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (UIView *)loadViewForDownloadingAttachment
{
OWSAssert(self.attachmentPointer);
OWSAssertDebug(self.attachmentPointer);
AttachmentPointerView *downloadView =
[[AttachmentPointerView alloc] initWithAttachmentPointer:self.attachmentPointer
@ -1041,7 +1041,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (UIView *)loadViewForContactShare
{
OWSAssert(self.viewItem.contactShare);
OWSAssertDebug(self.viewItem.contactShare);
OWSContactShareView *contactShareView = [[OWSContactShareView alloc] initWithContactShare:self.viewItem.contactShare
isIncoming:self.isIncoming
@ -1067,7 +1067,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (void)addAttachmentUploadViewIfNecessaryWithAttachmentStateCallback:
(nullable AttachmentStateBlock)attachmentStateCallback
{
OWSAssert(self.attachmentStream);
OWSAssertDebug(self.attachmentStream);
if (!attachmentStateCallback) {
attachmentStateCallback = ^(BOOL isAttachmentReady) {
@ -1087,7 +1087,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (void)showAttachmentErrorViewWithMediaView:(UIView *)mediaView
{
OWSAssert(mediaView);
OWSAssertDebug(mediaView);
// TODO: We could do a better job of indicating that the media could not be loaded.
UIView *errorView = [UIView new];
@ -1102,8 +1102,8 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
// Size of "message body" text, not quoted reply text.
- (nullable NSValue *)bodyTextSize
{
OWSAssert(self.conversationStyle);
OWSAssert(self.conversationStyle.maxMessageWidth > 0);
OWSAssertDebug(self.conversationStyle);
OWSAssertDebug(self.conversationStyle.maxMessageWidth > 0);
if (!self.hasBodyText) {
return nil;
@ -1121,8 +1121,8 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (nullable NSValue *)bodyMediaSize
{
OWSAssert(self.conversationStyle);
OWSAssert(self.conversationStyle.maxMessageWidth > 0);
OWSAssertDebug(self.conversationStyle);
OWSAssertDebug(self.conversationStyle.maxMessageWidth > 0);
CGFloat maxMessageWidth = self.conversationStyle.maxMessageWidth;
if (!self.hasFullWidthMediaView) {
@ -1140,8 +1140,8 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
case OWSMessageCellType_StillImage:
case OWSMessageCellType_AnimatedImage:
case OWSMessageCellType_Video: {
OWSAssert(self.mediaSize.width > 0);
OWSAssert(self.mediaSize.height > 0);
OWSAssertDebug(self.mediaSize.width > 0);
OWSAssertDebug(self.mediaSize.height > 0);
// TODO: Adjust this behavior.
@ -1178,7 +1178,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
result = CGSizeMake(maxMessageWidth, OWSAudioMessageView.bubbleHeight);
break;
case OWSMessageCellType_GenericAttachment: {
OWSAssert(self.viewItem.attachmentStream);
OWSAssertDebug(self.viewItem.attachmentStream);
OWSGenericAttachmentView *attachmentView =
[[OWSGenericAttachmentView alloc] initWithAttachment:self.attachmentStream isIncoming:self.isIncoming];
[attachmentView createContentsWithConversationStyle:self.conversationStyle];
@ -1189,13 +1189,13 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
result = CGSizeMake(MIN(200, maxMessageWidth), [AttachmentPointerView measureHeight]);
break;
case OWSMessageCellType_ContactShare:
OWSAssert(self.viewItem.contactShare);
OWSAssertDebug(self.viewItem.contactShare);
result = CGSizeMake(maxMessageWidth, [OWSContactShareView bubbleHeight]);
break;
}
OWSAssert(result.width <= maxMessageWidth);
OWSAssertDebug(result.width <= maxMessageWidth);
result.width = MIN(result.width, maxMessageWidth);
return [NSValue valueWithCGSize:CGSizeCeil(result)];
@ -1203,10 +1203,10 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (nullable NSValue *)quotedMessageSize
{
OWSAssert(self.conversationStyle);
OWSAssert(self.conversationStyle.maxMessageWidth > 0);
OWSAssert(self.viewItem);
OWSAssert([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
OWSAssertDebug(self.conversationStyle);
OWSAssertDebug(self.conversationStyle.maxMessageWidth > 0);
OWSAssertDebug(self.viewItem);
OWSAssertDebug([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
if (!self.isQuotedReply) {
return nil;
@ -1227,8 +1227,8 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (nullable NSValue *)senderNameSize
{
OWSAssert(self.conversationStyle);
OWSAssert(self.conversationStyle.maxMessageWidth > 0);
OWSAssertDebug(self.conversationStyle);
OWSAssertDebug(self.conversationStyle.maxMessageWidth > 0);
if (!self.shouldShowSenderName) {
return nil;
@ -1245,11 +1245,11 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (nullable NSValue *)actionButtonsSize
{
OWSAssert(self.conversationStyle);
OWSAssert(self.conversationStyle.maxMessageWidth > 0);
OWSAssertDebug(self.conversationStyle);
OWSAssertDebug(self.conversationStyle.maxMessageWidth > 0);
if (self.cellType == OWSMessageCellType_ContactShare) {
OWSAssert(self.viewItem.contactShare);
OWSAssertDebug(self.viewItem.contactShare);
if ([OWSContactShareButtonsView hasAnyButton:self.viewItem.contactShare]) {
CGSize buttonsSize = CGSizeCeil(
@ -1262,10 +1262,10 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (CGSize)measureSize
{
OWSAssert(self.conversationStyle);
OWSAssert(self.conversationStyle.viewWidth > 0);
OWSAssert(self.viewItem);
OWSAssert([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
OWSAssertDebug(self.conversationStyle);
OWSAssertDebug(self.conversationStyle.viewWidth > 0);
OWSAssertDebug(self.viewItem);
OWSAssertDebug([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
CGSize cellSize = CGSizeZero;
@ -1338,7 +1338,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
// Make sure the bubble is always wide enough to complete it's bubble shape.
cellSize.width = MAX(cellSize.width, self.bubbleView.minWidth);
OWSAssert(cellSize.width > 0 && cellSize.height > 0);
OWSAssertDebug(cellSize.width > 0 && cellSize.height > 0);
if (self.hasTapForMore) {
cellSize.height += self.tapForMoreHeight + self.textViewVSpacing;
@ -1352,7 +1352,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
cellSize = CGSizeCeil(cellSize);
OWSAssert(cellSize.width <= self.conversationStyle.maxMessageWidth);
OWSAssertDebug(cellSize.width <= self.conversationStyle.maxMessageWidth);
cellSize.width = MIN(cellSize.width, self.conversationStyle.maxMessageWidth);
return cellSize;
@ -1360,10 +1360,10 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (CGSize)sizeForTextViewGroup:(NSArray<NSValue *> *)textViewSizes
{
OWSAssert(textViewSizes);
OWSAssert(textViewSizes.count > 0);
OWSAssert(self.conversationStyle);
OWSAssert(self.conversationStyle.maxMessageWidth > 0);
OWSAssertDebug(textViewSizes);
OWSAssertDebug(textViewSizes.count > 0);
OWSAssertDebug(self.conversationStyle);
OWSAssertDebug(self.conversationStyle.maxMessageWidth > 0);
CGSize result = CGSizeZero;
for (NSValue *size in textViewSizes) {
@ -1391,7 +1391,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (UIColor *)bodyTextColor
{
OWSAssert([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
OWSAssertDebug([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
TSMessage *message = (TSMessage *)self.viewItem.interaction;
return [self.conversationStyle bubbleTextColorWithMessage:message];
@ -1476,7 +1476,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (void)handleTapGesture:(UITapGestureRecognizer *)sender
{
OWSAssert(self.delegate);
OWSAssertDebug(self.delegate);
if (sender.state != UIGestureRecognizerStateRecognized) {
OWSLogVerbose(@"Ignoring tap on message: %@", self.viewItem.interaction.debugDescription);
@ -1522,7 +1522,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (void)handleMediaTapGesture
{
OWSAssert(self.delegate);
OWSAssertDebug(self.delegate);
TSAttachmentStream *_Nullable attachmentStream = self.viewItem.attachmentStream;
@ -1532,42 +1532,42 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
case OWSMessageCellType_OversizeTextMessage:
break;
case OWSMessageCellType_StillImage:
OWSAssert(self.bodyMediaView);
OWSAssert(attachmentStream);
OWSAssertDebug(self.bodyMediaView);
OWSAssertDebug(attachmentStream);
[self.delegate didTapImageViewItem:self.viewItem
attachmentStream:attachmentStream
imageView:self.bodyMediaView];
break;
case OWSMessageCellType_AnimatedImage:
OWSAssert(self.bodyMediaView);
OWSAssert(attachmentStream);
OWSAssertDebug(self.bodyMediaView);
OWSAssertDebug(attachmentStream);
[self.delegate didTapImageViewItem:self.viewItem
attachmentStream:attachmentStream
imageView:self.bodyMediaView];
break;
case OWSMessageCellType_Audio:
OWSAssert(attachmentStream);
OWSAssertDebug(attachmentStream);
[self.delegate didTapAudioViewItem:self.viewItem attachmentStream:attachmentStream];
return;
case OWSMessageCellType_Video:
OWSAssert(self.bodyMediaView);
OWSAssert(attachmentStream);
OWSAssertDebug(self.bodyMediaView);
OWSAssertDebug(attachmentStream);
[self.delegate didTapVideoViewItem:self.viewItem
attachmentStream:attachmentStream
imageView:self.bodyMediaView];
return;
case OWSMessageCellType_GenericAttachment:
OWSAssert(attachmentStream);
OWSAssertDebug(attachmentStream);
[AttachmentSharing showShareUIForAttachment:attachmentStream];
break;
case OWSMessageCellType_DownloadingAttachment: {
TSAttachmentPointer *_Nullable attachmentPointer = self.viewItem.attachmentPointer;
OWSAssert(attachmentPointer);
OWSAssertDebug(attachmentPointer);
if (attachmentPointer.state == TSAttachmentPointerStateFailed) {
[self.delegate didTapFailedIncomingAttachment:self.viewItem attachmentPointer:attachmentPointer];
@ -1628,7 +1628,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (void)didTapSendMessageToContactShare:(ContactShareViewModel *)contactShare
{
OWSAssertIsOnMainThread();
OWSAssert(contactShare);
OWSAssertDebug(contactShare);
[self.delegate didTapSendMessageToContactShare:contactShare];
}
@ -1636,7 +1636,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (void)didTapSendInviteToContactShare:(ContactShareViewModel *)contactShare
{
OWSAssertIsOnMainThread();
OWSAssert(contactShare);
OWSAssertDebug(contactShare);
[self.delegate didTapSendInviteToContactShare:contactShare];
}
@ -1644,7 +1644,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes
- (void)didTapShowAddToContactUIForContactShare:(ContactShareViewModel *)contactShare
{
OWSAssertIsOnMainThread();
OWSAssert(contactShare);
OWSAssertDebug(contactShare);
[self.delegate didTapShowAddToContactUIForContactShare:contactShare];
}

View File

@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)commontInit
{
// Ensure only called once.
OWSAssert(!self.messageBubbleView);
OWSAssertDebug(!self.messageBubbleView);
self.layoutMargins = UIEdgeInsetsZero;
self.contentView.layoutMargins = UIEdgeInsetsZero;
@ -98,7 +98,7 @@ NS_ASSUME_NONNULL_BEGIN
- (TSMessage *)message
{
OWSAssert([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
OWSAssertDebug([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
return (TSMessage *)self.viewItem.interaction;
}
@ -126,11 +126,11 @@ NS_ASSUME_NONNULL_BEGIN
- (void)loadForDisplay
{
OWSAssert(self.conversationStyle);
OWSAssert(self.viewItem);
OWSAssert(self.viewItem.interaction);
OWSAssert([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
OWSAssert(self.messageBubbleView);
OWSAssertDebug(self.conversationStyle);
OWSAssertDebug(self.viewItem);
OWSAssertDebug(self.viewItem.interaction);
OWSAssertDebug([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
OWSAssertDebug(self.messageBubbleView);
self.messageBubbleView.viewItem = self.viewItem;
self.messageBubbleView.cellMediaCache = self.delegate.cellMediaCache;
@ -217,8 +217,8 @@ NS_ASSUME_NONNULL_BEGIN
- (UIImage *)sendFailureBadge
{
UIImage *image = [UIImage imageNamed:@"message_status_failed_large"];
OWSAssert(image);
OWSAssert(image.size.width == self.sendFailureBadgeSize && image.size.height == self.sendFailureBadgeSize);
OWSAssertDebug(image);
OWSAssertDebug(image.size.width == self.sendFailureBadgeSize && image.size.height == self.sendFailureBadgeSize);
return image;
}
@ -236,7 +236,7 @@ NS_ASSUME_NONNULL_BEGIN
// * If cell is not visible, eagerly unload view contents.
- (void)ensureMediaLoadState
{
OWSAssert(self.messageBubbleView);
OWSAssertDebug(self.messageBubbleView);
if (!self.isCellVisible) {
[self.messageBubbleView unloadContent];
@ -322,11 +322,11 @@ NS_ASSUME_NONNULL_BEGIN
- (CGSize)cellSize
{
OWSAssert(self.conversationStyle);
OWSAssert(self.conversationStyle.viewWidth > 0);
OWSAssert(self.viewItem);
OWSAssert([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
OWSAssert(self.messageBubbleView);
OWSAssertDebug(self.conversationStyle);
OWSAssertDebug(self.conversationStyle.viewWidth > 0);
OWSAssertDebug(self.viewItem);
OWSAssertDebug([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
OWSAssertDebug(self.messageBubbleView);
self.messageBubbleView.viewItem = self.viewItem;
self.messageBubbleView.cellMediaCache = self.delegate.cellMediaCache;
@ -334,7 +334,7 @@ NS_ASSUME_NONNULL_BEGIN
CGSize cellSize = messageBubbleSize;
OWSAssert(cellSize.width > 0 && cellSize.height > 0);
OWSAssertDebug(cellSize.width > 0 && cellSize.height > 0);
if (self.viewItem.hasCellHeader) {
cellSize.height +=
@ -392,7 +392,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)handleTapGesture:(UITapGestureRecognizer *)sender
{
OWSAssert(self.delegate);
OWSAssertDebug(self.delegate);
if (sender.state != UIGestureRecognizerStateRecognized) {
OWSLogVerbose(@"Ignoring tap on message: %@", self.viewItem.interaction.debugDescription);
@ -419,7 +419,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)handleLongPressGesture:(UILongPressGestureRecognizer *)sender
{
OWSAssert(self.delegate);
OWSAssertDebug(self.delegate);
if (sender.state != UIGestureRecognizerStateBegan) {
return;
@ -460,7 +460,7 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)isGestureInCellHeader:(UIGestureRecognizer *)sender
{
OWSAssert(self.viewItem);
OWSAssertDebug(self.viewItem);
if (!self.viewItem.hasCellHeader) {
return NO;

View File

@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)commontInit
{
// Ensure only called once.
OWSAssert(!self.timestampLabel);
OWSAssertDebug(!self.timestampLabel);
self.layoutMargins = UIEdgeInsetsZero;
@ -90,8 +90,8 @@ NS_ASSUME_NONNULL_BEGIN
conversationStyle:(ConversationStyle *)conversationStyle
isIncoming:(BOOL)isIncoming
{
OWSAssert(viewItem);
OWSAssert(conversationStyle);
OWSAssertDebug(viewItem);
OWSAssertDebug(conversationStyle);
[self configureLabelsWithConversationViewItem:viewItem];
@ -154,7 +154,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)showStatusIndicatorWithIcon:(UIImage *)icon textColor:(UIColor *)textColor
{
OWSAssert(icon.size.width <= self.maxImageWidth);
OWSAssertDebug(icon.size.width <= self.maxImageWidth);
self.statusIndicatorImageView.image = [icon imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
self.statusIndicatorImageView.tintColor = textColor;
[self.statusIndicatorImageView setContentHuggingHigh];
@ -188,7 +188,7 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)isFailedOutgoingMessage:(ConversationViewItem *)viewItem
{
OWSAssert(viewItem);
OWSAssertDebug(viewItem);
if (viewItem.interaction.interactionType != OWSInteractionType_OutgoingMessage) {
return NO;
@ -202,7 +202,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)configureLabelsWithConversationViewItem:(ConversationViewItem *)viewItem
{
OWSAssert(viewItem);
OWSAssertDebug(viewItem);
[self configureFonts];
@ -219,7 +219,7 @@ NS_ASSUME_NONNULL_BEGIN
- (CGSize)measureWithConversationViewItem:(ConversationViewItem *)viewItem
{
OWSAssert(viewItem);
OWSAssertDebug(viewItem);
[self configureLabelsWithConversationViewItem:viewItem];
@ -245,7 +245,7 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable NSString *)messageStatusTextForConversationViewItem:(ConversationViewItem *)viewItem
{
OWSAssert(viewItem);
OWSAssertDebug(viewItem);
if (viewItem.interaction.interactionType != OWSInteractionType_OutgoingMessage) {
return nil;
}

View File

@ -40,7 +40,7 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23;
- (void)commontInit
{
OWSAssert(!self.titleLabel);
OWSAssertDebug(!self.titleLabel);
self.layoutMargins = UIEdgeInsetsZero;
self.layoutConstraints = @[];
@ -75,9 +75,9 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23;
- (void)loadForDisplayWithViewItem:(ConversationViewItem *)viewItem
conversationStyle:(ConversationStyle *)conversationStyle
{
OWSAssert(viewItem);
OWSAssert(conversationStyle);
OWSAssert(viewItem.unreadIndicator || viewItem.shouldShowDate);
OWSAssertDebug(viewItem);
OWSAssertDebug(conversationStyle);
OWSAssertDebug(viewItem.unreadIndicator || viewItem.shouldShowDate);
self.titleLabel.textColor = Theme.primaryColor;
self.subtitleLabel.textColor = Theme.primaryColor;
@ -102,7 +102,7 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23;
- (CGFloat)strokeThicknessWithViewItem:(ConversationViewItem *)viewItem
{
OWSAssert(viewItem);
OWSAssertDebug(viewItem);
if (viewItem.unreadIndicator) {
return 4.f;
@ -113,7 +113,7 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23;
- (UIColor *)strokeColorWithViewItem:(ConversationViewItem *)viewItem
{
OWSAssert(viewItem);
OWSAssertDebug(viewItem);
if (viewItem.unreadIndicator) {
return Theme.secondaryColor;
@ -124,7 +124,7 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23;
- (void)configureLabelsWithViewItem:(ConversationViewItem *)viewItem
{
OWSAssert(viewItem);
OWSAssertDebug(viewItem);
NSDate *date = viewItem.interaction.dateForSorting;
NSString *dateString = [DateUtil formatDateForConversationDateBreaks:date].localizedUppercaseString;
@ -161,9 +161,9 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 23;
- (CGSize)measureWithConversationViewItem:(ConversationViewItem *)viewItem
conversationStyle:(ConversationStyle *)conversationStyle
{
OWSAssert(viewItem);
OWSAssert(conversationStyle);
OWSAssert(viewItem.unreadIndicator || viewItem.shouldShowDate);
OWSAssertDebug(viewItem);
OWSAssertDebug(conversationStyle);
OWSAssertDebug(viewItem.unreadIndicator || viewItem.shouldShowDate);
[self configureLabelsWithViewItem:viewItem];

View File

@ -89,8 +89,8 @@ const CGFloat kDisappearingMessageIconSize = 12.f;
if (self.initialDurationSeconds > 0) {
progress = CGFloatClamp(secondsLeft / self.initialDurationSeconds, 0.f, 1.f);
}
OWSAssert(progress >= 0.f);
OWSAssert(progress <= 1.f);
OWSAssertDebug(progress >= 0.f);
OWSAssertDebug(progress <= 1.f);
self.progress12 = (NSInteger)round(CGFloatClamp(progress, 0.f, 1.f) * 12);
}
@ -113,8 +113,8 @@ const CGFloat kDisappearingMessageIconSize = 12.f;
- (UIImage *)progressIcon
{
OWSAssert(self.progress12 >= 0);
OWSAssert(self.progress12 <= 12);
OWSAssertDebug(self.progress12 >= 0);
OWSAssertDebug(self.progress12 <= 12);
UIImage *_Nullable image;
switch (self.progress12) {
@ -159,9 +159,9 @@ const CGFloat kDisappearingMessageIconSize = 12.f;
image = [UIImage imageNamed:@"disappearing_message_60"];
break;
}
OWSAssert(image);
OWSAssert(image.size.width == kDisappearingMessageIconSize);
OWSAssert(image.size.height == kDisappearingMessageIconSize);
OWSAssertDebug(image);
OWSAssertDebug(image.size.width == kDisappearingMessageIconSize);
OWSAssertDebug(image.size.height == kDisappearingMessageIconSize);
return image;
}

View File

@ -46,7 +46,7 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3;
isOutgoing:(BOOL)isOutgoing
sharpCorners:(OWSDirectionalRectCorner)sharpCorners
{
OWSAssert(quotedMessage);
OWSAssertDebug(quotedMessage);
return [[OWSQuotedMessageView alloc] initWithQuotedMessage:quotedMessage
displayableQuotedText:displayableQuotedText
@ -59,7 +59,7 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3;
+ (OWSQuotedMessageView *)quotedMessageViewForPreview:(OWSQuotedReplyModel *)quotedMessage
conversationStyle:(ConversationStyle *)conversationStyle
{
OWSAssert(quotedMessage);
OWSAssertDebug(quotedMessage);
DisplayableText *_Nullable displayableQuotedText = nil;
if (quotedMessage.body.length > 0) {
@ -90,7 +90,7 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3;
return self;
}
OWSAssert(quotedMessage);
OWSAssertDebug(quotedMessage);
_quotedMessage = quotedMessage;
_displayableQuotedText = displayableQuotedText;
@ -156,7 +156,7 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3;
- (void)createContents
{
// Ensure only called once.
OWSAssert(self.subviews.count < 1);
OWSAssertDebug(self.subviews.count < 1);
self.userInteractionEnabled = YES;
self.layoutMargins = UIEdgeInsetsZero;
@ -302,8 +302,8 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3;
{
UIImage *glyphImage =
[[UIImage imageNamed:@"ic_broken_link"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
OWSAssert(glyphImage);
OWSAssert(CGSizeEqualToSize(
OWSAssertDebug(glyphImage);
OWSAssertDebug(CGSizeEqualToSize(
CGSizeMake(kRemotelySourcedContentGlyphLength, kRemotelySourcedContentGlyphLength), glyphImage.size));
UIImageView *glyphView = [[UIImageView alloc] initWithImage:glyphImage];
glyphView.tintColor = Theme.secondaryColor;
@ -362,7 +362,7 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3;
- (UIImageView *)imageViewForImage:(UIImage *)image
{
OWSAssert(image);
OWSAssertDebug(image);
UIImageView *imageView = [UIImageView new];
imageView.image = image;
@ -378,7 +378,7 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3;
- (UILabel *)configureQuotedTextLabel
{
OWSAssert(self.quotedTextLabel);
OWSAssertDebug(self.quotedTextLabel);
UIColor *textColor = self.quotedTextColor;
SUPPRESS_DEADSTORE_WARNING(textColor);
@ -419,7 +419,7 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3;
- (UILabel *)configureQuoteContentSourceLabel
{
OWSAssert(self.quoteContentSourceLabel);
OWSAssertDebug(self.quoteContentSourceLabel);
self.quoteContentSourceLabel.font = UIFont.ows_dynamicTypeFootnoteFont;
self.quoteContentSourceLabel.textColor = Theme.primaryColor;
@ -479,7 +479,7 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3;
- (UILabel *)configureQuotedAuthorLabel
{
OWSAssert(self.quotedAuthorLabel);
OWSAssertDebug(self.quotedAuthorLabel);
NSString *_Nullable localNumber = [TSAccountManager localNumber];
NSString *quotedAuthorText;

View File

@ -73,7 +73,7 @@ typedef void (^SystemMessageActionBlock)(void);
- (void)commontInit
{
OWSAssert(!self.iconView);
OWSAssertDebug(!self.iconView);
self.layoutMargins = UIEdgeInsetsZero;
self.contentView.layoutMargins = UIEdgeInsetsZero;
@ -163,8 +163,8 @@ typedef void (^SystemMessageActionBlock)(void);
- (void)loadForDisplay
{
OWSAssert(self.conversationStyle);
OWSAssert(self.viewItem);
OWSAssertDebug(self.conversationStyle);
OWSAssertDebug(self.viewItem);
self.cellBackgroundView.backgroundColor = [Theme backgroundColor];
@ -288,7 +288,7 @@ typedef void (^SystemMessageActionBlock)(void);
break;
}
case TSInfoMessageVerificationStateChange:
OWSAssert([interaction isKindOfClass:[OWSVerificationStateChangeMessage class]]);
OWSAssertDebug([interaction isKindOfClass:[OWSVerificationStateChangeMessage class]]);
if ([interaction isKindOfClass:[OWSVerificationStateChangeMessage class]]) {
OWSVerificationStateChangeMessage *message = (OWSVerificationStateChangeMessage *)interaction;
BOOL isVerified = message.verificationState == OWSVerificationStateVerified;
@ -305,16 +305,16 @@ typedef void (^SystemMessageActionBlock)(void);
OWSFailDebug(@"Unknown interaction type: %@", [interaction class]);
return nil;
}
OWSAssert(result);
OWSAssertDebug(result);
return result;
}
- (void)applyTitleForInteraction:(TSInteraction *)interaction
label:(UILabel *)label
{
OWSAssert(interaction);
OWSAssert(label);
OWSAssert(self.viewItem.systemMessageText.length > 0);
OWSAssertDebug(interaction);
OWSAssertDebug(label);
OWSAssertDebug(self.viewItem.systemMessageText.length > 0);
[self configureFonts];
@ -343,8 +343,8 @@ typedef void (^SystemMessageActionBlock)(void);
- (CGSize)titleSize
{
OWSAssert(self.conversationStyle);
OWSAssert(self.viewItem);
OWSAssertDebug(self.conversationStyle);
OWSAssertDebug(self.viewItem);
CGFloat maxTitleWidth = (CGFloat)floor(self.conversationStyle.fullWidthContentWidth);
return [self.titleLabel sizeThatFits:CGSizeMake(maxTitleWidth, CGFLOAT_MAX)];
@ -352,8 +352,8 @@ typedef void (^SystemMessageActionBlock)(void);
- (CGSize)cellSize
{
OWSAssert(self.conversationStyle);
OWSAssert(self.viewItem);
OWSAssertDebug(self.conversationStyle);
OWSAssertDebug(self.viewItem);
TSInteraction *interaction = self.viewItem.interaction;
@ -389,7 +389,7 @@ typedef void (^SystemMessageActionBlock)(void);
- (nullable SystemMessageAction *)actionForInteraction:(TSInteraction *)interaction
{
OWSAssertIsOnMainThread();
OWSAssert(interaction);
OWSAssertDebug(interaction);
if ([interaction isKindOfClass:[TSErrorMessage class]]) {
return [self actionForErrorMessage:(TSErrorMessage *)interaction];
@ -405,7 +405,7 @@ typedef void (^SystemMessageActionBlock)(void);
- (nullable SystemMessageAction *)actionForErrorMessage:(TSErrorMessage *)message
{
OWSAssert(message);
OWSAssertDebug(message);
__weak OWSSystemMessageCell *weakSelf = self;
switch (message.errorType) {
@ -453,7 +453,7 @@ typedef void (^SystemMessageActionBlock)(void);
- (nullable SystemMessageAction *)actionForInfoMessage:(TSInfoMessage *)message
{
OWSAssert(message);
OWSAssertDebug(message);
__weak OWSSystemMessageCell *weakSelf = self;
switch (message.messageType) {
@ -501,7 +501,7 @@ typedef void (^SystemMessageActionBlock)(void);
- (nullable SystemMessageAction *)actionForCall:(TSCall *)call
{
OWSAssert(call);
OWSAssertDebug(call);
__weak OWSSystemMessageCell *weakSelf = self;
switch (call.callType) {
@ -531,14 +531,14 @@ typedef void (^SystemMessageActionBlock)(void);
- (void)handleLongPressGesture:(UILongPressGestureRecognizer *)longPress
{
OWSAssert(self.delegate);
OWSAssertDebug(self.delegate);
if ([self isGestureInCellHeader:longPress]) {
return;
}
TSInteraction *interaction = self.viewItem.interaction;
OWSAssert(interaction);
OWSAssertDebug(interaction);
if (longPress.state == UIGestureRecognizerStateBegan) {
[self.delegate conversationCell:self didLongpressSystemMessageViewItem:self.viewItem];
@ -547,7 +547,7 @@ typedef void (^SystemMessageActionBlock)(void);
- (BOOL)isGestureInCellHeader:(UIGestureRecognizer *)sender
{
OWSAssert(self.viewItem);
OWSAssertDebug(self.viewItem);
if (!self.viewItem.hasCellHeader) {
return NO;

View File

@ -97,7 +97,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)ensurePlaceholderConstraints
{
OWSAssert(self.placeholderView);
OWSAssertDebug(self.placeholderView);
if (self.placeholderConstraints) {
[NSLayoutConstraint deactivateConstraints:self.placeholderConstraints];
@ -176,7 +176,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)textViewDidChange:(UITextView *)textView
{
OWSAssert(self.textViewToolbarDelegate);
OWSAssertDebug(self.textViewToolbarDelegate);
[self updatePlaceholderVisibility];

View File

@ -134,7 +134,7 @@ const CGFloat kMaxTextViewHeight = 98;
[self.sendButton addTarget:self action:@selector(sendButtonPressed) forControlEvents:UIControlEventTouchUpInside];
UIImage *voiceMemoIcon = [UIImage imageNamed:@"voice-memo-button"];
OWSAssert(voiceMemoIcon);
OWSAssertDebug(voiceMemoIcon);
_voiceMemoButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.voiceMemoButton setImage:[voiceMemoIcon imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
forState:UIControlStateNormal];
@ -174,22 +174,22 @@ const CGFloat kMaxTextViewHeight = 98;
- (void)setInputTextViewDelegate:(id<ConversationInputTextViewDelegate>)value
{
OWSAssert(self.inputTextView);
OWSAssert(value);
OWSAssertDebug(self.inputTextView);
OWSAssertDebug(value);
self.inputTextView.inputTextViewDelegate = value;
}
- (NSString *)messageText
{
OWSAssert(self.inputTextView);
OWSAssertDebug(self.inputTextView);
return self.inputTextView.trimmedText;
}
- (void)setMessageText:(NSString *_Nullable)value animated:(BOOL)isAnimated
{
OWSAssert(self.inputTextView);
OWSAssertDebug(self.inputTextView);
self.inputTextView.text = value;
@ -237,7 +237,7 @@ const CGFloat kMaxTextViewHeight = 98;
if (self.quotedMessagePreview) {
[self clearQuotedMessagePreview];
}
OWSAssert(self.quotedMessagePreview == nil);
OWSAssertDebug(self.quotedMessagePreview == nil);
_quotedReply = quotedReply;
@ -400,7 +400,7 @@ const CGFloat kMaxTextViewHeight = 98;
[self updateVoiceMemo];
UIImage *icon = [UIImage imageNamed:@"voice-memo-button"];
OWSAssert(icon);
OWSAssertDebug(icon);
UIImageView *imageView =
[[UIImageView alloc] initWithImage:[icon imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];
imageView.tintColor = [UIColor ows_destructiveRedColor];
@ -465,7 +465,7 @@ const CGFloat kMaxTextViewHeight = 98;
[redCircleView autoAlignAxis:ALAxisVertical toSameAxisOfView:self.voiceMemoButton];
UIImage *whiteIcon = [UIImage imageNamed:@"voice-message-large-white"];
OWSAssert(whiteIcon);
OWSAssertDebug(whiteIcon);
UIImageView *whiteIconView = [[UIImageView alloc] initWithImage:whiteIcon];
[redCircleView addSubview:whiteIconView];
[whiteIconView autoCenterInSuperview];
@ -581,14 +581,14 @@ const CGFloat kMaxTextViewHeight = 98;
- (void)sendButtonPressed
{
OWSAssert(self.inputToolbarDelegate);
OWSAssertDebug(self.inputToolbarDelegate);
[self.inputToolbarDelegate sendButtonPressed];
}
- (void)attachmentButtonPressed
{
OWSAssert(self.inputToolbarDelegate);
OWSAssertDebug(self.inputToolbarDelegate);
[self.inputToolbarDelegate attachmentButtonPressed];
}
@ -597,7 +597,7 @@ const CGFloat kMaxTextViewHeight = 98;
- (void)textViewDidChange:(UITextView *)textView
{
OWSAssert(self.inputToolbarDelegate);
OWSAssertDebug(self.inputToolbarDelegate);
[self ensureShouldShowVoiceMemoButtonAnimated:YES];
[self updateHeightWithTextView:textView];
}
@ -610,7 +610,7 @@ const CGFloat kMaxTextViewHeight = 98;
if (newHeight != self.textViewHeight) {
self.textViewHeight = newHeight;
OWSAssert(self.textViewHeightConstraint);
OWSAssertDebug(self.textViewHeightConstraint);
self.textViewHeightConstraint.constant = newHeight;
[self invalidateIntrinsicContentSize];
}

View File

@ -360,7 +360,7 @@ typedef enum : NSUInteger {
- (BOOL)isGroupConversation
{
OWSAssert(self.thread);
OWSAssertDebug(self.thread);
return self.thread.isGroupThread;
}
@ -377,7 +377,7 @@ typedef enum : NSUInteger {
OWSAssertIsOnMainThread();
NSString *recipientId = notification.userInfo[kNSNotificationKey_ProfileRecipientId];
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
if (recipientId.length > 0 && [self.thread.recipientIdentifiers containsObject:recipientId]) {
if ([self.thread isKindOfClass:[TSContactThread class]]) {
// update title with profile name
@ -441,7 +441,7 @@ typedef enum : NSUInteger {
action:(ConversationViewAction)action
focusMessageId:(nullable NSString *)focusMessageId
{
OWSAssert(thread);
OWSAssertDebug(thread);
OWSLogInfo(@"configureForThread.");
@ -553,7 +553,7 @@ typedef enum : NSUInteger {
- (void)createContents
{
OWSAssert(self.conversationStyle);
OWSAssertDebug(self.conversationStyle);
_layout = [[ConversationViewLayout alloc] initWithConversationStyle:self.conversationStyle];
self.conversationStyle.viewWidth = self.view.width;
@ -729,8 +729,8 @@ typedef enum : NSUInteger {
- (NSIndexPath *_Nullable)indexPathOfMessageOnOpen
{
OWSAssert(self.focusMessageIdOnOpen);
OWSAssert(self.dynamicInteractions.focusMessagePosition);
OWSAssertDebug(self.focusMessageIdOnOpen);
OWSAssertDebug(self.dynamicInteractions.focusMessagePosition);
if (!self.dynamicInteractions.focusMessagePosition) {
// This might happen if the focus message has disappeared
@ -901,8 +901,8 @@ typedef enum : NSUInteger {
- (void)createBannerWithTitle:(NSString *)title bannerColor:(UIColor *)bannerColor tapSelector:(SEL)tapSelector
{
OWSAssert(title.length > 0);
OWSAssert(bannerColor);
OWSAssertDebug(title.length > 0);
OWSAssertDebug(bannerColor);
UIView *bannerView = [UIView containerView];
bannerView.backgroundColor = bannerColor;
@ -1035,14 +1035,14 @@ typedef enum : NSUInteger {
NSArray<NSString *> *noLongerVerifiedRecipientIds = [self noLongerVerifiedRecipientIds];
for (NSString *recipientId in noLongerVerifiedRecipientIds) {
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
OWSRecipientIdentity *_Nullable recipientIdentity =
[[OWSIdentityManager sharedManager] recipientIdentityForRecipientId:recipientId];
OWSAssert(recipientIdentity);
OWSAssertDebug(recipientIdentity);
NSData *identityKey = recipientIdentity.identityKey;
OWSAssert(identityKey.length > 0);
OWSAssertDebug(identityKey.length > 0);
if (identityKey.length < 1) {
continue;
}
@ -1056,7 +1056,7 @@ typedef enum : NSUInteger {
- (void)showUnblockContactUI:(nullable BlockActionCompletionBlock)completionBlock
{
OWSAssert([self.thread isKindOfClass:[TSContactThread class]]);
OWSAssertDebug([self.thread isKindOfClass:[TSContactThread class]]);
self.userHasScrolled = NO;
@ -1087,8 +1087,8 @@ typedef enum : NSUInteger {
- (int)blockedGroupMemberCount
{
OWSAssert(self.isGroupConversation);
OWSAssert([self.thread isKindOfClass:[TSGroupThread class]]);
OWSAssertDebug(self.isGroupConversation);
OWSAssertDebug([self.thread isKindOfClass:[TSGroupThread class]]);
TSGroupThread *groupThread = (TSGroupThread *)self.thread;
int blockedMemberCount = 0;
@ -1233,7 +1233,7 @@ typedef enum : NSUInteger {
name = [[NSAttributedString alloc] initWithString:self.thread.name];
}
} else {
OWSAssert(self.thread.contactIdentifier);
OWSAssertDebug(self.thread.contactIdentifier);
name =
[self.contactsManager attributedContactOrProfileNameForPhoneIdentifier:self.thread.contactIdentifier
primaryFont:self.headerView.titlePrimaryFont
@ -1515,7 +1515,7 @@ typedef enum : NSUInteger {
- (void)callWithVideo:(BOOL)isVideo
{
OWSAssert([self.thread isKindOfClass:[TSContactThread class]]);
OWSAssertDebug([self.thread isKindOfClass:[TSContactThread class]]);
if (![self canCall]) {
OWSLogWarn(@"Tried to initiate a call but thread is not callable.");
@ -1724,10 +1724,10 @@ typedef enum : NSUInteger {
// If this is the first time we're configuring the range length,
// try to take into account the position of the unread indicator
// and the "focus message".
OWSAssert(self.dynamicInteractions);
OWSAssertDebug(self.dynamicInteractions);
if (self.focusMessageIdOnOpen) {
OWSAssert(self.dynamicInteractions.focusMessagePosition);
OWSAssertDebug(self.dynamicInteractions.focusMessagePosition);
if (self.dynamicInteractions.focusMessagePosition) {
OWSLogVerbose(@"ensuring load of focus message: %@", self.dynamicInteractions.focusMessagePosition);
rangeLength = MAX(rangeLength, 1 + self.dynamicInteractions.focusMessagePosition.unsignedIntegerValue);
@ -1740,8 +1740,8 @@ typedef enum : NSUInteger {
// If there is an unread indicator, increase the initial load window
// to include it.
OWSAssert(unreadIndicatorPosition > 0);
OWSAssert(unreadIndicatorPosition <= kYapDatabaseRangeMaxLength);
OWSAssertDebug(unreadIndicatorPosition > 0);
OWSAssertDebug(unreadIndicatorPosition <= kYapDatabaseRangeMaxLength);
// We'd like to include at least N seen messages,
// to give the user the context of where they left off the conversation.
@ -1919,7 +1919,7 @@ typedef enum : NSUInteger {
- (void)handleCallTap:(TSCall *)call
{
OWSAssert(call);
OWSAssertDebug(call);
if (![self.thread isKindOfClass:[TSContactThread class]]) {
OWSFailDebug(@"unexpected thread: %@", self.thread);
@ -2061,7 +2061,7 @@ typedef enum : NSUInteger {
- (NSAttributedString *)attributedContactOrProfileNameForPhoneIdentifier:(NSString *)recipientId
{
OWSAssertIsOnMainThread();
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
return [self.contactsManager attributedContactOrProfileNameForPhoneIdentifier:recipientId];
}
@ -2162,9 +2162,9 @@ typedef enum : NSUInteger {
imageView:(UIView *)imageView
{
OWSAssertIsOnMainThread();
OWSAssert(viewItem);
OWSAssert(attachmentStream);
OWSAssert(imageView);
OWSAssertDebug(viewItem);
OWSAssertDebug(attachmentStream);
OWSAssertDebug(imageView);
[self dismissKeyBoard];
@ -2193,8 +2193,8 @@ typedef enum : NSUInteger {
imageView:(UIImageView *)imageView
{
OWSAssertIsOnMainThread();
OWSAssert(viewItem);
OWSAssert(attachmentStream);
OWSAssertDebug(viewItem);
OWSAssertDebug(attachmentStream);
[self dismissKeyBoard];
// In case we were presenting edit menu, we need to become first responder before presenting another VC
@ -2220,8 +2220,8 @@ typedef enum : NSUInteger {
- (void)didTapAudioViewItem:(ConversationViewItem *)viewItem attachmentStream:(TSAttachmentStream *)attachmentStream
{
OWSAssertIsOnMainThread();
OWSAssert(viewItem);
OWSAssert(attachmentStream);
OWSAssertDebug(viewItem);
OWSAssertDebug(attachmentStream);
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:[attachmentStream.mediaURL path]]) {
@ -2249,8 +2249,8 @@ typedef enum : NSUInteger {
- (void)didTapTruncatedTextMessage:(ConversationViewItem *)conversationItem
{
OWSAssertIsOnMainThread();
OWSAssert(conversationItem);
OWSAssert([conversationItem.interaction isKindOfClass:[TSMessage class]]);
OWSAssertDebug(conversationItem);
OWSAssertDebug([conversationItem.interaction isKindOfClass:[TSMessage class]]);
LongTextViewController *view = [[LongTextViewController alloc] initWithViewItem:conversationItem];
[self.navigationController pushViewController:view animated:YES];
@ -2259,9 +2259,9 @@ typedef enum : NSUInteger {
- (void)didTapContactShareViewItem:(ConversationViewItem *)conversationItem
{
OWSAssertIsOnMainThread();
OWSAssert(conversationItem);
OWSAssert(conversationItem.contactShare);
OWSAssert([conversationItem.interaction isKindOfClass:[TSMessage class]]);
OWSAssertDebug(conversationItem);
OWSAssertDebug(conversationItem.contactShare);
OWSAssertDebug([conversationItem.interaction isKindOfClass:[TSMessage class]]);
ContactViewController *view = [[ContactViewController alloc] initWithContactShare:conversationItem.contactShare];
[self.navigationController pushViewController:view animated:YES];
@ -2270,7 +2270,7 @@ typedef enum : NSUInteger {
- (void)didTapSendMessageToContactShare:(ContactShareViewModel *)contactShare
{
OWSAssertIsOnMainThread();
OWSAssert(contactShare);
OWSAssertDebug(contactShare);
[self.contactShareViewHelper sendMessageWithContactShare:contactShare fromViewController:self];
}
@ -2278,7 +2278,7 @@ typedef enum : NSUInteger {
- (void)didTapSendInviteToContactShare:(ContactShareViewModel *)contactShare
{
OWSAssertIsOnMainThread();
OWSAssert(contactShare);
OWSAssertDebug(contactShare);
[self.contactShareViewHelper showInviteContactWithContactShare:contactShare fromViewController:self];
}
@ -2286,7 +2286,7 @@ typedef enum : NSUInteger {
- (void)didTapShowAddToContactUIForContactShare:(ContactShareViewModel *)contactShare
{
OWSAssertIsOnMainThread();
OWSAssert(contactShare);
OWSAssertDebug(contactShare);
[self.contactShareViewHelper showAddToContactsWithContactShare:contactShare fromViewController:self];
}
@ -2295,8 +2295,8 @@ typedef enum : NSUInteger {
attachmentPointer:(TSAttachmentPointer *)attachmentPointer
{
OWSAssertIsOnMainThread();
OWSAssert(viewItem);
OWSAssert(attachmentPointer);
OWSAssertDebug(viewItem);
OWSAssertDebug(attachmentPointer);
// Restart failed downloads
TSMessage *message = (TSMessage *)viewItem.interaction;
@ -2306,7 +2306,7 @@ typedef enum : NSUInteger {
- (void)didTapFailedOutgoingMessage:(TSOutgoingMessage *)message
{
OWSAssertIsOnMainThread();
OWSAssert(message);
OWSAssertDebug(message);
[self handleUnsentMessageTap:message];
}
@ -2316,8 +2316,8 @@ typedef enum : NSUInteger {
failedThumbnailDownloadAttachmentPointer:(TSAttachmentPointer *)attachmentPointer
{
OWSAssertIsOnMainThread();
OWSAssert(viewItem);
OWSAssert(attachmentPointer);
OWSAssertDebug(viewItem);
OWSAssertDebug(attachmentPointer);
TSMessage *message = (TSMessage *)viewItem.interaction;
if (![message isKindOfClass:[TSMessage class]]) {
@ -2352,10 +2352,10 @@ typedef enum : NSUInteger {
- (void)didTapConversationItem:(ConversationViewItem *)viewItem quotedReply:(OWSQuotedReplyModel *)quotedReply
{
OWSAssertIsOnMainThread();
OWSAssert(viewItem);
OWSAssert(quotedReply);
OWSAssert(quotedReply.timestamp > 0);
OWSAssert(quotedReply.authorId.length > 0);
OWSAssertDebug(viewItem);
OWSAssertDebug(quotedReply);
OWSAssertDebug(quotedReply.timestamp > 0);
OWSAssertDebug(quotedReply.authorId.length > 0);
// We try to find the index of the item within the current thread's
// interactions that includes the "quoted interaction".
@ -2465,8 +2465,8 @@ typedef enum : NSUInteger {
- (nullable NSNumber *)findGroupIndexOfThreadInteraction:(TSInteraction *)interaction
transaction:(YapDatabaseReadTransaction *)transaction
{
OWSAssert(interaction);
OWSAssert(transaction);
OWSAssertDebug(interaction);
OWSAssertDebug(transaction);
YapDatabaseAutoViewTransaction *_Nullable extension = [transaction extension:TSMessageDatabaseViewExtensionName];
if (!extension) {
@ -2487,8 +2487,8 @@ typedef enum : NSUInteger {
- (void)showDetailViewForViewItem:(ConversationViewItem *)conversationItem
{
OWSAssertIsOnMainThread();
OWSAssert(conversationItem);
OWSAssert([conversationItem.interaction isKindOfClass:[TSMessage class]]);
OWSAssertDebug(conversationItem);
OWSAssertDebug([conversationItem.interaction isKindOfClass:[TSMessage class]]);
TSMessage *message = (TSMessage *)conversationItem.interaction;
MessageDetailViewController *view =
@ -2575,7 +2575,7 @@ typedef enum : NSUInteger {
NSIndexPath *_Nullable indexPathOfUnreadIndicator = [self indexPathOfUnreadMessagesIndicator];
if (indexPathOfUnreadIndicator) {
ConversationViewItem *oldIndicatorItem = [self viewItemForIndex:indexPathOfUnreadIndicator.row];
OWSAssert(oldIndicatorItem);
OWSAssertDebug(oldIndicatorItem);
// TODO ideally this would be happening within the *same* transaction that caused the unreadMessageIndicator
// to be cleared.
@ -2689,7 +2689,7 @@ typedef enum : NSUInteger {
if (self.viewItems.count > 0) {
ConversationViewItem *lastViewItem = [self.viewItems lastObject];
OWSAssert(lastViewItem);
OWSAssertDebug(lastViewItem);
if (lastViewItem.interaction.timestampForSorting > self.lastVisibleTimestamp) {
shouldShowScrollDownButton = YES;
@ -2747,7 +2747,7 @@ typedef enum : NSUInteger {
menuController.delegate = self;
UIImage *takeMediaImage = [UIImage imageNamed:@"actionsheet_camera_black"];
OWSAssert(takeMediaImage);
OWSAssertDebug(takeMediaImage);
[menuController addOptionWithTitle:NSLocalizedString(
@"MEDIA_FROM_LIBRARY_BUTTON", @"media picker option to choose from library")
image:takeMediaImage
@ -2777,7 +2777,7 @@ typedef enum : NSUInteger {
- (void)gifPickerDidSelectWithAttachment:(SignalAttachment *)attachment
{
OWSAssert(attachment);
OWSAssertDebug(attachment);
[self tryToSendAttachmentIfApproved:attachment];
@ -2788,7 +2788,7 @@ typedef enum : NSUInteger {
- (void)messageWasSent:(TSOutgoingMessage *)message
{
OWSAssertIsOnMainThread();
OWSAssert(message);
OWSAssertDebug(message);
[self updateLastVisibleTimestamp:message.timestampForSorting];
self.lastMessageSentDate = [NSDate new];
@ -2859,8 +2859,8 @@ typedef enum : NSUInteger {
@"ATTACHMENT_DEFAULT_FILENAME", @"Generic filename for an attachment with no known name");
}
OWSAssert(type);
OWSAssert(filename);
OWSAssertDebug(type);
OWSAssertDebug(filename);
DataSource *_Nullable dataSource = [DataSourcePath dataSourceWithURL:url shouldDeleteOnDeallocation:NO];
if (!dataSource) {
OWSFailDebug(@"attachment data was unexpectedly empty for picked document");
@ -3100,9 +3100,9 @@ typedef enum : NSUInteger {
{
OWSAssertIsOnMainThread();
// TODO: Should we assume non-nil or should we check for non-nil?
OWSAssert(attachment != nil);
OWSAssert(![attachment hasError]);
OWSAssert([attachment mimeType].length > 0);
OWSAssertDebug(attachment != nil);
OWSAssertDebug(![attachment hasError]);
OWSAssertDebug([attachment mimeType].length > 0);
OWSLogVerbose(@"Sending attachment. Size in bytes: %lu, contentType: %@",
(unsigned long)[attachment dataLength],
@ -3125,7 +3125,7 @@ typedef enum : NSUInteger {
- (void)sendContactShare:(ContactShareViewModel *)contactShare
{
OWSAssertIsOnMainThread();
OWSAssert(contactShare);
OWSAssertDebug(contactShare);
OWSLogVerbose(@"Sending contact share.");
@ -3169,7 +3169,7 @@ typedef enum : NSUInteger {
compressionResult.attachmentPromise.then(^(SignalAttachment *attachment) {
OWSAssertIsOnMainThread();
OWSAssert([attachment isKindOfClass:[SignalAttachment class]]);
OWSAssertDebug([attachment isKindOfClass:[SignalAttachment class]]);
if (modalActivityIndicator.wasCancelled) {
return;
@ -3242,7 +3242,7 @@ typedef enum : NSUInteger {
OWSLogVerbose(@"");
NSArray *notifications = notification.userInfo[OWSUIDatabaseConnectionNotificationsKey];
OWSAssert([notifications isKindOfClass:[NSArray class]]);
OWSAssertDebug([notifications isKindOfClass:[NSArray class]]);
[self updateBackButtonUnreadCount];
[self updateNavigationBarSubtitleLabel];
@ -3313,7 +3313,7 @@ typedef enum : NSUInteger {
} else if (rowChange.indexPath && rowChange.originalIndex < self.viewItems.count) {
// Do nothing, this is a pseudo-update generated due to
// setCellDrawingDependencyOffsets.
OWSAssert(rowChange.changes == YapDatabaseViewChangedDependency);
OWSAssertDebug(rowChange.changes == YapDatabaseViewChangedDependency);
} else {
hasMalformedRowChange = YES;
}
@ -3378,7 +3378,7 @@ typedef enum : NSUInteger {
(unsigned long)rowChange.finalIndex);
[self.collectionView deleteItemsAtIndexPaths:@[ rowChange.indexPath ]];
YapCollectionKey *collectionKey = rowChange.collectionKey;
OWSAssert(collectionKey.key.length > 0);
OWSAssertDebug(collectionKey.key.length > 0);
break;
}
case YapDatabaseViewChangeInsert: {
@ -3513,7 +3513,7 @@ typedef enum : NSUInteger {
- (BOOL)shouldAnimateRowUpdates:(NSArray<YapDatabaseViewRowChange *> *)rowChanges
oldViewItemCount:(NSUInteger)oldViewItemCount
{
OWSAssert(rowChanges);
OWSAssertDebug(rowChanges);
// If user sends a new outgoing message, don't animate the change.
BOOL isOnlyModifyingLastMessage = YES;
@ -3799,7 +3799,7 @@ typedef enum : NSUInteger {
[self takePictureOrVideo];
}];
UIImage *takeMediaImage = [UIImage imageNamed:@"actionsheet_camera_black"];
OWSAssert(takeMediaImage);
OWSAssertDebug(takeMediaImage);
[takeMediaAction setValue:takeMediaImage forKey:@"image"];
[actionSheetController addAction:takeMediaAction];
@ -3810,7 +3810,7 @@ typedef enum : NSUInteger {
[self chooseFromLibraryAsMedia];
}];
UIImage *chooseMediaImage = [UIImage imageNamed:@"actionsheet_camera_roll_black"];
OWSAssert(chooseMediaImage);
OWSAssertDebug(chooseMediaImage);
[chooseMediaAction setValue:chooseMediaImage forKey:@"image"];
[actionSheetController addAction:chooseMediaAction];
@ -3821,7 +3821,7 @@ typedef enum : NSUInteger {
[self showGifPicker];
}];
UIImage *gifImage = [UIImage imageNamed:@"actionsheet_gif_black"];
OWSAssert(gifImage);
OWSAssertDebug(gifImage);
[gifAction setValue:gifImage forKey:@"image"];
[actionSheetController addAction:gifAction];
@ -3833,7 +3833,7 @@ typedef enum : NSUInteger {
[self showAttachmentDocumentPickerMenu];
}];
UIImage *chooseDocumentImage = [UIImage imageNamed:@"actionsheet_document_black"];
OWSAssert(chooseDocumentImage);
OWSAssertDebug(chooseDocumentImage);
[chooseDocumentAction setValue:chooseDocumentImage forKey:@"image"];
[actionSheetController addAction:chooseDocumentAction];
@ -3846,7 +3846,7 @@ typedef enum : NSUInteger {
[self chooseContactForSending];
}];
UIImage *chooseContactImage = [UIImage imageNamed:@"actionsheet_contact"];
OWSAssert(takeMediaImage);
OWSAssertDebug(takeMediaImage);
[chooseContactAction setValue:chooseContactImage forKey:@"image"];
[actionSheetController addAction:chooseContactAction];
}
@ -3916,7 +3916,7 @@ typedef enum : NSUInteger {
- (void)updateLastVisibleTimestamp:(uint64_t)timestamp
{
OWSAssert(timestamp > 0);
OWSAssertDebug(timestamp > 0);
self.lastVisibleTimestamp = MAX(self.lastVisibleTimestamp, timestamp);
@ -4063,10 +4063,10 @@ typedef enum : NSUInteger {
}
_backButtonUnreadCount = unreadCount;
OWSAssert(_backButtonUnreadCountView != nil);
OWSAssertDebug(_backButtonUnreadCountView != nil);
_backButtonUnreadCountView.hidden = unreadCount <= 0;
OWSAssert(_backButtonUnreadCountLabel != nil);
OWSAssertDebug(_backButtonUnreadCountLabel != nil);
// Max out the unread count at 99+.
const NSUInteger kMaxUnreadCount = 99;
@ -4278,7 +4278,7 @@ typedef enum : NSUInteger {
- (void)showErrorAlertForAttachment:(SignalAttachment *_Nullable)attachment
{
OWSAssert(attachment == nil || [attachment hasError]);
OWSAssertDebug(attachment == nil || [attachment hasError]);
NSString *errorMessage
= (attachment ? [attachment localizedErrorDescription] : [SignalAttachment missingDataErrorMessage]);
@ -4363,8 +4363,8 @@ typedef enum : NSUInteger {
- (void)resendGroupUpdateForErrorMessage:(TSErrorMessage *)message
{
OWSAssertIsOnMainThread();
OWSAssert([_thread isKindOfClass:[TSGroupThread class]]);
OWSAssert(message);
OWSAssertDebug([_thread isKindOfClass:[TSGroupThread class]]);
OWSAssertDebug(message);
TSGroupThread *groupThread = (TSGroupThread *)self.thread;
TSGroupModel *groupModel = groupThread.groupModel;
@ -4385,7 +4385,7 @@ typedef enum : NSUInteger {
- (void)groupWasUpdated:(TSGroupModel *)groupModel
{
OWSAssert(groupModel);
OWSAssertDebug(groupModel);
NSMutableSet *groupMemberIds = [NSMutableSet setWithArray:groupModel.groupMemberIds];
[groupMemberIds addObject:[TSAccountManager localNumber]];
@ -4620,7 +4620,7 @@ typedef enum : NSUInteger {
// bottom of content"; if the mapping's "window" size grows, it will grow
// _upward_.
CGFloat viewTopToContentBottom = 0;
OWSAssert([self.collectionView.collectionViewLayout isKindOfClass:[ConversationViewLayout class]]);
OWSAssertDebug([self.collectionView.collectionViewLayout isKindOfClass:[ConversationViewLayout class]]);
ConversationViewLayout *conversationViewLayout
= (ConversationViewLayout *)self.collectionView.collectionViewLayout;
// To avoid laying out the collection view during initial view
@ -4712,7 +4712,7 @@ typedef enum : NSUInteger {
- (nullable NSIndexPath *)firstIndexPathAtViewHorizonTimestamp
{
OWSAssert(self.shouldObserveDBModifications);
OWSAssertDebug(self.shouldObserveDBModifications);
if (!self.viewHorizonTimestamp) {
return nil;
@ -4728,10 +4728,10 @@ typedef enum : NSUInteger {
// If we converge on an item _before_ this cutoff, there was no interaction that fit our criteria.
NSUInteger left = 0, right = self.viewItems.count - 1;
while (left != right) {
OWSAssert(left < right);
OWSAssertDebug(left < right);
NSUInteger mid = (left + right) / 2;
OWSAssert(left <= mid);
OWSAssert(mid < right);
OWSAssertDebug(left <= mid);
OWSAssertDebug(mid < right);
ConversationViewItem *viewItem = self.viewItems[mid];
if (viewItem.interaction.timestamp >= viewHorizonTimestamp) {
right = mid;
@ -4740,7 +4740,7 @@ typedef enum : NSUInteger {
left = mid + 1;
}
}
OWSAssert(left == right);
OWSAssertDebug(left == right);
ConversationViewItem *viewItem = self.viewItems[left];
if (viewItem.interaction.timestamp >= viewHorizonTimestamp) {
OWSLogInfo(@"firstIndexPathAtViewHorizonTimestamp: %zd / %zd", left, self.viewItems.count);
@ -4884,7 +4884,7 @@ typedef enum : NSUInteger {
__block BOOL hasError = NO;
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
YapDatabaseViewTransaction *viewTransaction = [transaction ext:TSMessageDatabaseViewExtensionName];
OWSAssert(viewTransaction);
OWSAssertDebug(viewTransaction);
for (NSUInteger row = 0; row < count; row++) {
TSInteraction *interaction =
[viewTransaction objectAtRow:row inSection:0 withMappings:self.messageMappings];
@ -4913,7 +4913,7 @@ typedef enum : NSUInteger {
conversationStyle:self.conversationStyle];
}
[viewItems addObject:viewItem];
OWSAssert(!viewItemCache[interaction.uniqueId]);
OWSAssertDebug(!viewItemCache[interaction.uniqueId]);
viewItemCache[interaction.uniqueId] = viewItem;
}
}];
@ -4950,7 +4950,7 @@ typedef enum : NSUInteger {
}
uint64_t viewItemTimestamp = viewItem.interaction.timestampForSorting;
OWSAssert(viewItemTimestamp > 0);
OWSAssertDebug(viewItemTimestamp > 0);
BOOL shouldShowDate = NO;
if (previousViewItemTimestamp == 0) {
@ -5063,14 +5063,14 @@ typedef enum : NSUInteger {
TSIncomingMessage *incomingMessage = (TSIncomingMessage *)viewItem.interaction;
NSString *incomingSenderId = incomingMessage.authorId;
OWSAssert(incomingSenderId.length > 0);
OWSAssertDebug(incomingSenderId.length > 0);
BOOL isDisappearingMessage = incomingMessage.isExpiringMessage;
NSString *_Nullable nextIncomingSenderId = nil;
if (nextViewItem && nextViewItem.interaction.interactionType == interactionType) {
TSIncomingMessage *nextIncomingMessage = (TSIncomingMessage *)nextViewItem.interaction;
nextIncomingSenderId = nextIncomingMessage.authorId;
OWSAssert(nextIncomingSenderId.length > 0);
OWSAssertDebug(nextIncomingSenderId.length > 0);
}
if (nextViewItem && nextViewItem.interaction.interactionType == interactionType) {
@ -5115,7 +5115,7 @@ typedef enum : NSUInteger {
TSIncomingMessage *previousIncomingMessage = (TSIncomingMessage *)previousViewItem.interaction;
NSString *previousIncomingSenderId = previousIncomingMessage.authorId;
OWSAssert(previousIncomingSenderId.length > 0);
OWSAssertDebug(previousIncomingSenderId.length > 0);
shouldShowSenderName
= (![NSObject isNullableObject:previousIncomingSenderId equalTo:incomingSenderId]
@ -5163,7 +5163,7 @@ typedef enum : NSUInteger {
- (void)reloadInteractionForViewItem:(ConversationViewItem *)viewItem
{
OWSAssertIsOnMainThread();
OWSAssert(viewItem);
OWSAssertDebug(viewItem);
// This should never happen, but don't crash in production if we have a bug.
if (!viewItem) {
@ -5225,7 +5225,7 @@ typedef enum : NSUInteger {
willDisplayCell:(UICollectionViewCell *)cell
forItemAtIndexPath:(NSIndexPath *)indexPath
{
OWSAssert([cell isKindOfClass:[ConversationViewCell class]]);
OWSAssertDebug([cell isKindOfClass:[ConversationViewCell class]]);
ConversationViewCell *conversationViewCell = (ConversationViewCell *)cell;
conversationViewCell.isCellVisible = YES;
@ -5235,7 +5235,7 @@ typedef enum : NSUInteger {
didEndDisplayingCell:(nonnull UICollectionViewCell *)cell
forItemAtIndexPath:(nonnull NSIndexPath *)indexPath
{
OWSAssert([cell isKindOfClass:[ConversationViewCell class]]);
OWSAssertDebug([cell isKindOfClass:[ConversationViewCell class]]);
ConversationViewCell *conversationViewCell = (ConversationViewCell *)cell;
conversationViewCell.isCellVisible = NO;
@ -5257,7 +5257,7 @@ typedef enum : NSUInteger {
- (void)contactsPicker:(ContactsPicker *)contactsPicker didSelectContact:(Contact *)contact
{
OWSAssert(contact);
OWSAssertDebug(contact);
CNContact *_Nullable cnContact = [self.contactsManager cnContactWithId:contact.cnContactId];
if (!cnContact) {
@ -5294,7 +5294,7 @@ typedef enum : NSUInteger {
[[ContactShareApprovalViewController alloc] initWithContactShare:contactShare
contactsManager:self.contactsManager
delegate:self];
OWSAssert(contactsPicker.navigationController);
OWSAssertDebug(contactsPicker.navigationController);
[contactsPicker.navigationController pushViewController:approveContactShare animated:YES];
}

View File

@ -81,9 +81,9 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
transaction:(YapDatabaseReadTransaction *)transaction
conversationStyle:(ConversationStyle *)conversationStyle
{
OWSAssert(interaction);
OWSAssert(transaction);
OWSAssert(conversationStyle);
OWSAssertDebug(interaction);
OWSAssertDebug(transaction);
OWSAssertDebug(conversationStyle);
self = [super init];
@ -102,7 +102,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
- (void)replaceInteraction:(TSInteraction *)interaction transaction:(YapDatabaseReadTransaction *)transaction
{
OWSAssert(interaction);
OWSAssertDebug(interaction);
_interaction = interaction;
@ -220,7 +220,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
- (CGSize)cellSize
{
OWSAssertIsOnMainThread();
OWSAssert(self.conversationStyle);
OWSAssertDebug(self.conversationStyle);
if (!self.cachedCellSize) {
ConversationViewCell *_Nullable measurementCell = [self measurementCell];
@ -236,7 +236,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
- (nullable ConversationViewCell *)measurementCell
{
OWSAssertIsOnMainThread();
OWSAssert(self.interaction);
OWSAssertDebug(self.interaction);
// For performance reasons, we cache one instance of each kind of
// cell and uses these cells for measurement.
@ -267,7 +267,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
break;
}
OWSAssert(measurementCell);
OWSAssertDebug(measurementCell);
measurementCellCache[cellCacheKey] = measurementCell;
}
@ -276,7 +276,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
- (CGFloat)vSpacingWithPreviousLayoutItem:(ConversationViewItem *)previousLayoutItem
{
OWSAssert(previousLayoutItem);
OWSAssertDebug(previousLayoutItem);
if (self.hasCellHeader) {
return OWSMessageHeaderViewDateHeaderVMargin;
@ -302,9 +302,9 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
indexPath:(NSIndexPath *)indexPath
{
OWSAssertIsOnMainThread();
OWSAssert(collectionView);
OWSAssert(indexPath);
OWSAssert(self.interaction);
OWSAssertDebug(collectionView);
OWSAssertDebug(indexPath);
OWSAssertDebug(self.interaction);
switch (self.interaction.interactionType) {
case OWSInteractionType_Unknown:
@ -361,8 +361,8 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
- (DisplayableText *)displayableBodyTextForText:(NSString *)text interactionId:(NSString *)interactionId
{
OWSAssert(text);
OWSAssert(interactionId.length > 0);
OWSAssertDebug(text);
OWSAssertDebug(interactionId.length > 0);
NSString *displayableTextCacheKey = [@"body-" stringByAppendingString:interactionId];
@ -375,8 +375,8 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
- (DisplayableText *)displayableBodyTextForOversizeTextAttachment:(TSAttachmentStream *)attachmentStream
interactionId:(NSString *)interactionId
{
OWSAssert(attachmentStream);
OWSAssert(interactionId.length > 0);
OWSAssertDebug(attachmentStream);
OWSAssertDebug(interactionId.length > 0);
NSString *displayableTextCacheKey = [@"oversize-body-" stringByAppendingString:interactionId];
@ -391,8 +391,8 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
- (DisplayableText *)displayableQuotedTextForText:(NSString *)text interactionId:(NSString *)interactionId
{
OWSAssert(text);
OWSAssert(interactionId.length > 0);
OWSAssertDebug(text);
OWSAssertDebug(interactionId.length > 0);
NSString *displayableTextCacheKey = [@"quoted-" stringByAppendingString:interactionId];
@ -405,7 +405,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
- (DisplayableText *)displayableTextForCacheKey:(NSString *)displayableTextCacheKey
textBlock:(NSString * (^_Nonnull)(void))textBlock
{
OWSAssert(displayableTextCacheKey.length > 0);
OWSAssertDebug(displayableTextCacheKey.length > 0);
DisplayableText *_Nullable displayableText = [[self displayableTextCache] objectForKey:displayableTextCacheKey];
if (!displayableText) {
@ -421,7 +421,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
- (nullable TSAttachment *)firstAttachmentIfAnyOfMessage:(TSMessage *)message
transaction:(YapDatabaseReadTransaction *)transaction
{
OWSAssert(transaction);
OWSAssertDebug(transaction);
if (message.attachmentIds.count == 0) {
return nil;
@ -436,8 +436,8 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
- (void)ensureViewState:(YapDatabaseReadTransaction *)transaction
{
OWSAssertIsOnMainThread();
OWSAssert(transaction);
OWSAssert(!self.hasViewState);
OWSAssertDebug(transaction);
OWSAssertDebug(!self.hasViewState);
switch (self.interaction.interactionType) {
case OWSInteractionType_Unknown:
@ -447,7 +447,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
case OWSInteractionType_Info:
case OWSInteractionType_Call:
self.systemMessageText = [self systemMessageTextWithTransaction:transaction];
OWSAssert(self.systemMessageText.length > 0);
OWSAssertDebug(self.systemMessageText.length > 0);
return;
case OWSInteractionType_IncomingMessage:
case OWSInteractionType_OutgoingMessage:
@ -457,7 +457,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
return;
}
OWSAssert([self.interaction isKindOfClass:[TSOutgoingMessage class]] ||
OWSAssertDebug([self.interaction isKindOfClass:[TSOutgoingMessage class]] ||
[self.interaction isKindOfClass:[TSIncomingMessage class]]);
self.hasViewState = YES;
@ -541,11 +541,11 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
// If we haven't already assigned an attachment type at this point, message.body isn't a caption,
// it's a stand-alone text message.
if (self.messageCellType == OWSMessageCellType_Unknown) {
OWSAssert(message.attachmentIds.count == 0);
OWSAssertDebug(message.attachmentIds.count == 0);
self.messageCellType = OWSMessageCellType_TextMessage;
}
self.displayableBodyText = [self displayableBodyTextForText:message.body interactionId:message.uniqueId];
OWSAssert(self.displayableBodyText);
OWSAssertDebug(self.displayableBodyText);
}
if (self.messageCellType == OWSMessageCellType_Unknown) {
@ -569,7 +569,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
- (NSString *)systemMessageTextWithTransaction:(YapDatabaseReadTransaction *)transaction
{
OWSAssert(transaction);
OWSAssertDebug(transaction);
switch (self.interaction.interactionType) {
case OWSInteractionType_Error: {
@ -638,11 +638,11 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
- (nullable DisplayableText *)displayableBodyText
{
OWSAssertIsOnMainThread();
OWSAssert(self.hasViewState);
OWSAssertDebug(self.hasViewState);
OWSAssert(_displayableBodyText);
OWSAssert(_displayableBodyText.displayText);
OWSAssert(_displayableBodyText.fullText);
OWSAssertDebug(_displayableBodyText);
OWSAssertDebug(_displayableBodyText.displayText);
OWSAssertDebug(_displayableBodyText.fullText);
return _displayableBodyText;
}
@ -650,7 +650,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
- (nullable TSAttachmentStream *)attachmentStream
{
OWSAssertIsOnMainThread();
OWSAssert(self.hasViewState);
OWSAssertDebug(self.hasViewState);
return _attachmentStream;
}
@ -658,7 +658,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
- (nullable TSAttachmentPointer *)attachmentPointer
{
OWSAssertIsOnMainThread();
OWSAssert(self.hasViewState);
OWSAssertDebug(self.hasViewState);
return _attachmentPointer;
}
@ -666,7 +666,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
- (CGSize)mediaSize
{
OWSAssertIsOnMainThread();
OWSAssert(self.hasViewState);
OWSAssertDebug(self.hasViewState);
return _mediaSize;
}
@ -674,11 +674,11 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
- (nullable DisplayableText *)displayableQuotedText
{
OWSAssertIsOnMainThread();
OWSAssert(self.hasViewState);
OWSAssertDebug(self.hasViewState);
OWSAssert(_displayableQuotedText);
OWSAssert(_displayableQuotedText.displayText);
OWSAssert(_displayableQuotedText.fullText);
OWSAssertDebug(_displayableQuotedText);
OWSAssertDebug(_displayableQuotedText.displayText);
OWSAssertDebug(_displayableQuotedText.fullText);
return _displayableQuotedText;
}
@ -693,7 +693,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
case OWSMessageCellType_Audio:
case OWSMessageCellType_Video:
case OWSMessageCellType_GenericAttachment: {
OWSAssert(self.displayableBodyText);
OWSAssertDebug(self.displayableBodyText);
[UIPasteboard.generalPasteboard setString:self.displayableBodyText.fullText];
break;
}
@ -758,7 +758,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
case OWSMessageCellType_Audio:
case OWSMessageCellType_Video:
case OWSMessageCellType_GenericAttachment: {
OWSAssert(self.displayableBodyText);
OWSAssertDebug(self.displayableBodyText);
[AttachmentSharing showShareUIForText:self.displayableBodyText.fullText];
break;
}

View File

@ -115,7 +115,7 @@ NS_ASSUME_NONNULL_BEGIN
CGSize layoutSize = CGSizeCeil([layoutItem cellSize]);
// Ensure cell fits within view.
OWSAssert(layoutSize.width <= viewWidth);
OWSAssertDebug(layoutSize.width <= viewWidth);
layoutSize.width = MIN(viewWidth, layoutSize.width);
// All cells are "full width" and are responsible for aligning their own content.

View File

@ -61,10 +61,10 @@ NS_ASSUME_NONNULL_BEGIN
OWSLogInfo(@"backupTestFile.");
NSData *_Nullable data = [Randomness generateRandomBytes:32];
OWSAssert(data);
OWSAssertDebug(data);
NSString *filePath = [OWSFileSystem temporaryFilePathWithFileExtension:@"pdf"];
BOOL success = [data writeToFile:filePath atomically:YES];
OWSAssert(success);
OWSAssertDebug(success);
[OWSBackupAPI checkCloudKitAccessWithCompletion:^(BOOL hasAccess) {
if (hasAccess) {
@ -133,7 +133,7 @@ NS_ASSUME_NONNULL_BEGIN
interactionCount++;
NSData *_Nullable data =
[NSKeyedArchiver archivedDataWithRootObject:interaction];
OWSAssert(data);
OWSAssertDebug(data);
interactionSizeTotal += data.length;
}];
[transaction enumerateKeysAndObjectsInCollection:[TSAttachment collection]
@ -142,7 +142,7 @@ NS_ASSUME_NONNULL_BEGIN
attachmentCount++;
NSData *_Nullable data =
[NSKeyedArchiver archivedDataWithRootObject:attachment];
OWSAssert(data);
OWSAssertDebug(data);
attachmentSizeTotal += data.length;
}];
}];

View File

@ -1153,7 +1153,7 @@ NS_ASSUME_NONNULL_BEGIN
contactHandler:
(nullable void (^)(CNContact *_Nonnull contact, NSUInteger idx, BOOL *_Nonnull stop))contactHandler
{
OWSAssert(count > 0);
OWSAssertDebug(count > 0);
NSUInteger remainder = count;
const NSUInteger kMaxBatchSize = 20;
@ -1175,8 +1175,8 @@ NS_ASSUME_NONNULL_BEGIN
CNContact *_Nonnull contact, NSUInteger idx, BOOL *_Nonnull stop))contactHandler
batchCompletionHandler:(nullable void (^)(void))batchCompletionHandler
{
OWSAssert(count > 0);
OWSAssert(batchCompletionHandler);
OWSAssertDebug(count > 0);
OWSAssertDebug(batchCompletionHandler);
OWSLogDebug(@"createRandomContactsBatch: %zu", count);
@ -1215,7 +1215,7 @@ NS_ASSUME_NONNULL_BEGIN
const NSUInteger kPercentWithAvatar = 50;
const NSUInteger kMinimumAvatarDiameter = 200;
const NSUInteger kMaximumAvatarDiameter = 800;
OWSAssert(kMaximumAvatarDiameter >= kMinimumAvatarDiameter);
OWSAssertDebug(kMaximumAvatarDiameter >= kMinimumAvatarDiameter);
if (arc4random_uniform(100) < kPercentWithAvatar) {
NSUInteger avatarDiameter
= arc4random_uniform(kMaximumAvatarDiameter - kMinimumAvatarDiameter)
@ -1252,7 +1252,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)deleteContactsWithFilter:(BOOL (^_Nonnull)(CNContact *contact))filterBlock
{
OWSAssert(filterBlock);
OWSAssertDebug(filterBlock);
CNAuthorizationStatus status = [CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts];
if (status == CNAuthorizationStatusDenied || status == CNAuthorizationStatusRestricted) {

File diff suppressed because it is too large Load Diff

View File

@ -36,8 +36,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)prepare:(ActionSuccessBlock)success failure:(ActionFailureBlock)failure
{
OWSAssert(success);
OWSAssert(failure);
OWSAssertDebug(success);
OWSAssertDebug(failure);
OWSAbstractMethod();
@ -62,8 +62,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)performNTimes:(NSUInteger)countParam success:(ActionSuccessBlock)success failure:(ActionFailureBlock)failure
{
OWSAssert(success);
OWSAssert(failure);
OWSAssertDebug(success);
OWSAssertDebug(failure);
OWSLogInfo(@"%@ performNTimes: %zd", self.label, countParam);
[DDLog flushLog];
@ -81,10 +81,10 @@ NS_ASSUME_NONNULL_BEGIN
NSUInteger index = count;
DebugUIMessagesSingleAction *action = [self nextActionToPerform];
OWSAssert([action isKindOfClass:[DebugUIMessagesSingleAction class]]);
OWSAssertDebug([action isKindOfClass:[DebugUIMessagesSingleAction class]]);
if (action.staggeredActionBlock) {
OWSAssert(!action.unstaggeredActionBlock);
OWSAssertDebug(!action.unstaggeredActionBlock);
action.staggeredActionBlock(index,
transaction,
^{
@ -98,7 +98,7 @@ NS_ASSUME_NONNULL_BEGIN
break;
} else {
OWSAssert(action.unstaggeredActionBlock);
OWSAssertDebug(action.unstaggeredActionBlock);
// TODO: We could check result for failure.
action.unstaggeredActionBlock(index, transaction);
@ -129,8 +129,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (DebugUIMessagesAction *)actionWithLabel:(NSString *)label
staggeredActionBlock:(StaggeredActionBlock)staggeredActionBlock
{
OWSAssert(label.length > 0);
OWSAssert(staggeredActionBlock);
OWSAssertDebug(label.length > 0);
OWSAssertDebug(staggeredActionBlock);
DebugUIMessagesSingleAction *instance = [DebugUIMessagesSingleAction new];
instance.label = label;
@ -141,8 +141,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (DebugUIMessagesAction *)actionWithLabel:(NSString *)label
unstaggeredActionBlock:(UnstaggeredActionBlock)unstaggeredActionBlock
{
OWSAssert(label.length > 0);
OWSAssert(unstaggeredActionBlock);
OWSAssertDebug(label.length > 0);
OWSAssertDebug(unstaggeredActionBlock);
DebugUIMessagesSingleAction *instance = [DebugUIMessagesSingleAction new];
instance.label = label;
@ -154,9 +154,9 @@ NS_ASSUME_NONNULL_BEGIN
staggeredActionBlock:(StaggeredActionBlock)staggeredActionBlock
prepareBlock:(ActionPrepareBlock)prepareBlock
{
OWSAssert(label.length > 0);
OWSAssert(staggeredActionBlock);
OWSAssert(prepareBlock);
OWSAssertDebug(label.length > 0);
OWSAssertDebug(staggeredActionBlock);
OWSAssertDebug(prepareBlock);
DebugUIMessagesSingleAction *instance = [DebugUIMessagesSingleAction new];
instance.label = label;
@ -169,9 +169,9 @@ NS_ASSUME_NONNULL_BEGIN
unstaggeredActionBlock:(UnstaggeredActionBlock)unstaggeredActionBlock
prepareBlock:(ActionPrepareBlock)prepareBlock
{
OWSAssert(label.length > 0);
OWSAssert(unstaggeredActionBlock);
OWSAssert(prepareBlock);
OWSAssertDebug(label.length > 0);
OWSAssertDebug(unstaggeredActionBlock);
OWSAssertDebug(prepareBlock);
DebugUIMessagesSingleAction *instance = [DebugUIMessagesSingleAction new];
instance.label = label;
@ -182,8 +182,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)prepare:(ActionSuccessBlock)success failure:(ActionFailureBlock)failure
{
OWSAssert(success);
OWSAssert(failure);
OWSAssertDebug(success);
OWSAssertDebug(failure);
if (self.prepareBlock) {
self.prepareBlock(success, failure);
@ -210,17 +210,17 @@ NS_ASSUME_NONNULL_BEGIN
- (DebugUIMessagesSingleAction *)nextActionToPerform
{
OWSAssert(self.subactions.count > 0);
OWSAssertDebug(self.subactions.count > 0);
switch (self.subactionMode) {
case SubactionMode_Random: {
DebugUIMessagesAction *subaction = self.subactions[arc4random_uniform((uint32_t)self.subactions.count)];
OWSAssert(subaction);
OWSAssertDebug(subaction);
return subaction.nextActionToPerform;
}
case SubactionMode_Ordered: {
DebugUIMessagesAction *subaction = self.subactions[self.subactionIndex];
OWSAssert(subaction);
OWSAssertDebug(subaction);
self.subactionIndex = (self.subactionIndex + 1) % self.subactions.count;
return subaction.nextActionToPerform;
}
@ -229,8 +229,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)prepare:(ActionSuccessBlock)success failure:(ActionFailureBlock)failure
{
OWSAssert(success);
OWSAssert(failure);
OWSAssertDebug(success);
OWSAssertDebug(failure);
[DebugUIMessagesGroupAction prepareSubactions:[self.subactions mutableCopy] success:success failure:failure];
}
@ -239,8 +239,8 @@ NS_ASSUME_NONNULL_BEGIN
success:(ActionSuccessBlock)success
failure:(ActionFailureBlock)failure
{
OWSAssert(success);
OWSAssert(failure);
OWSAssertDebug(success);
OWSAssertDebug(failure);
if (unpreparedSubactions.count < 1) {
return success();
@ -260,8 +260,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (DebugUIMessagesAction *)randomGroupActionWithLabel:(NSString *)label
subactions:(NSArray<DebugUIMessagesAction *> *)subactions
{
OWSAssert(label.length > 0);
OWSAssert(subactions.count > 0);
OWSAssertDebug(label.length > 0);
OWSAssertDebug(subactions.count > 0);
DebugUIMessagesGroupAction *instance = [DebugUIMessagesGroupAction new];
instance.label = label;
@ -273,8 +273,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (DebugUIMessagesAction *)allGroupActionWithLabel:(NSString *)label
subactions:(NSArray<DebugUIMessagesAction *> *)subactions
{
OWSAssert(label.length > 0);
OWSAssert(subactions.count > 0);
OWSAssertDebug(label.length > 0);
OWSAssertDebug(subactions.count > 0);
DebugUIMessagesGroupAction *instance = [DebugUIMessagesGroupAction new];
instance.label = label;

View File

@ -21,8 +21,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (DebugUIMessagesAssetLoader *)fakeAssetLoaderWithUrl:(NSString *)fileUrl mimeType:(NSString *)mimeType
{
OWSAssert(fileUrl.length > 0);
OWSAssert(mimeType.length > 0);
OWSAssertDebug(fileUrl.length > 0);
OWSAssertDebug(mimeType.length > 0);
DebugUIMessagesAssetLoader *instance = [DebugUIMessagesAssetLoader new];
instance.mimeType = mimeType;
@ -36,10 +36,10 @@ NS_ASSUME_NONNULL_BEGIN
- (void)ensureURLAssetLoaded:(NSString *)fileUrl success:(ActionSuccessBlock)success failure:(ActionFailureBlock)failure
{
OWSAssert(success);
OWSAssert(failure);
OWSAssert(self.filename.length > 0);
OWSAssert(self.mimeType.length > 0);
OWSAssertDebug(success);
OWSAssertDebug(failure);
OWSAssertDebug(self.filename.length > 0);
OWSAssertDebug(self.mimeType.length > 0);
if (self.filePath) {
success();
@ -59,14 +59,14 @@ NS_ASSUME_NONNULL_BEGIN
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFHTTPSessionManager *sessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:configuration];
sessionManager.responseSerializer = [AFHTTPResponseSerializer serializer];
OWSAssert(sessionManager.responseSerializer);
OWSAssertDebug(sessionManager.responseSerializer);
[sessionManager GET:fileUrl
parameters:nil
progress:nil
success:^(NSURLSessionDataTask *task, NSData *_Nullable responseObject) {
if ([responseObject writeToFile:filePath atomically:YES]) {
self.filePath = filePath;
OWSAssert([NSFileManager.defaultManager fileExistsAtPath:filePath]);
OWSAssertDebug([NSFileManager.defaultManager fileExistsAtPath:filePath]);
success();
} else {
OWSFailDebug(@"Error write url response [%@]: %@", fileUrl, filePath);
@ -86,11 +86,11 @@ NS_ASSUME_NONNULL_BEGIN
textColor:(UIColor *)textColor
label:(NSString *)label
{
OWSAssert(imageSize.width > 0);
OWSAssert(imageSize.height > 0);
OWSAssert(backgroundColor);
OWSAssert(textColor);
OWSAssert(label.length > 0);
OWSAssertDebug(imageSize.width > 0);
OWSAssertDebug(imageSize.height > 0);
OWSAssertDebug(backgroundColor);
OWSAssertDebug(textColor);
OWSAssertDebug(label.length > 0);
DebugUIMessagesAssetLoader *instance = [DebugUIMessagesAssetLoader new];
instance.mimeType = OWSMimeTypeImagePng;
@ -114,14 +114,14 @@ NS_ASSUME_NONNULL_BEGIN
success:(ActionSuccessBlock)success
failure:(ActionFailureBlock)failure
{
OWSAssert(success);
OWSAssert(failure);
OWSAssert(self.filename.length > 0);
OWSAssert(self.mimeType.length > 0);
OWSAssert(imageSize.width > 0 && imageSize.height > 0);
OWSAssert(backgroundColor);
OWSAssert(textColor);
OWSAssert(label.length > 0);
OWSAssertDebug(success);
OWSAssertDebug(failure);
OWSAssertDebug(self.filename.length > 0);
OWSAssertDebug(self.mimeType.length > 0);
OWSAssertDebug(imageSize.width > 0 && imageSize.height > 0);
OWSAssertDebug(backgroundColor);
OWSAssertDebug(textColor);
OWSAssertDebug(label.length > 0);
if (self.filePath) {
success();
@ -135,7 +135,7 @@ NS_ASSUME_NONNULL_BEGIN
NSData *pngData = UIImagePNGRepresentation(image);
[pngData writeToFile:filePath atomically:YES];
self.filePath = filePath;
OWSAssert([NSFileManager.defaultManager fileExistsAtPath:filePath]);
OWSAssertDebug([NSFileManager.defaultManager fileExistsAtPath:filePath]);
success();
}
}
@ -145,10 +145,10 @@ NS_ASSUME_NONNULL_BEGIN
textColor:(UIColor *)textColor
label:(NSString *)label
{
OWSAssert(imageSize.width > 0 && imageSize.height > 0);
OWSAssert(backgroundColor);
OWSAssert(textColor);
OWSAssert(label.length > 0);
OWSAssertDebug(imageSize.width > 0 && imageSize.height > 0);
OWSAssertDebug(backgroundColor);
OWSAssertDebug(textColor);
OWSAssertDebug(label.length > 0);
@autoreleasepool {
CGRect frame = CGRectZero;
@ -183,13 +183,13 @@ NS_ASSUME_NONNULL_BEGIN
+ (DebugUIMessagesAssetLoader *)fakeRandomAssetLoaderWithLength:(NSUInteger)dataLength mimeType:(NSString *)mimeType
{
OWSAssert(dataLength > 0);
OWSAssert(mimeType.length > 0);
OWSAssertDebug(dataLength > 0);
OWSAssertDebug(mimeType.length > 0);
DebugUIMessagesAssetLoader *instance = [DebugUIMessagesAssetLoader new];
instance.mimeType = mimeType;
NSString *fileExtension = [MIMETypeUtil fileExtensionForMIMEType:mimeType];
OWSAssert(fileExtension.length > 0);
OWSAssertDebug(fileExtension.length > 0);
instance.filename = [@"attachment" stringByAppendingPathExtension:fileExtension];
__weak DebugUIMessagesAssetLoader *weakSelf = instance;
instance.prepareBlock = ^(ActionSuccessBlock success, ActionFailureBlock failure) {
@ -202,12 +202,12 @@ NS_ASSUME_NONNULL_BEGIN
success:(ActionSuccessBlock)success
failure:(ActionFailureBlock)failure
{
OWSAssert(dataLength > 0);
OWSAssert(dataLength < INT_MAX);
OWSAssert(success);
OWSAssert(failure);
OWSAssert(self.filename.length > 0);
OWSAssert(self.mimeType.length > 0);
OWSAssertDebug(dataLength > 0);
OWSAssertDebug(dataLength < INT_MAX);
OWSAssertDebug(success);
OWSAssertDebug(failure);
OWSAssertDebug(self.filename.length > 0);
OWSAssertDebug(self.mimeType.length > 0);
if (self.filePath) {
success();
@ -216,14 +216,14 @@ NS_ASSUME_NONNULL_BEGIN
@autoreleasepool {
NSString *fileExtension = [MIMETypeUtil fileExtensionForMIMEType:self.mimeType];
OWSAssert(fileExtension.length > 0);
OWSAssertDebug(fileExtension.length > 0);
NSData *data = [Randomness generateRandomBytes:(int)dataLength];
OWSAssert(data);
OWSAssertDebug(data);
NSString *filePath = [OWSFileSystem temporaryFilePathWithFileExtension:fileExtension];
BOOL didWrite = [data writeToFile:filePath atomically:YES];
OWSAssert(didWrite);
OWSAssertDebug(didWrite);
self.filePath = filePath;
OWSAssert([NSFileManager.defaultManager fileExistsAtPath:filePath]);
OWSAssertDebug([NSFileManager.defaultManager fileExistsAtPath:filePath]);
}
success();
@ -233,12 +233,12 @@ NS_ASSUME_NONNULL_BEGIN
+ (DebugUIMessagesAssetLoader *)fakeMissingAssetLoaderWithMimeType:(NSString *)mimeType
{
OWSAssert(mimeType.length > 0);
OWSAssertDebug(mimeType.length > 0);
DebugUIMessagesAssetLoader *instance = [DebugUIMessagesAssetLoader new];
instance.mimeType = mimeType;
NSString *fileExtension = [MIMETypeUtil fileExtensionForMIMEType:mimeType];
OWSAssert(fileExtension.length > 0);
OWSAssertDebug(fileExtension.length > 0);
instance.filename = [@"attachment" stringByAppendingPathExtension:fileExtension];
__weak DebugUIMessagesAssetLoader *weakSelf = instance;
instance.prepareBlock = ^(ActionSuccessBlock success, ActionFailureBlock failure) {
@ -249,10 +249,10 @@ NS_ASSUME_NONNULL_BEGIN
- (void)ensureMissingAssetLoaded:(ActionSuccessBlock)success failure:(ActionFailureBlock)failure
{
OWSAssert(success);
OWSAssert(failure);
OWSAssert(self.filename.length > 0);
OWSAssert(self.mimeType.length > 0);
OWSAssertDebug(success);
OWSAssertDebug(failure);
OWSAssertDebug(self.filename.length > 0);
OWSAssertDebug(self.mimeType.length > 0);
if (self.filePath) {
success();
@ -260,12 +260,12 @@ NS_ASSUME_NONNULL_BEGIN
}
NSString *fileExtension = [MIMETypeUtil fileExtensionForMIMEType:self.mimeType];
OWSAssert(fileExtension.length > 0);
OWSAssertDebug(fileExtension.length > 0);
NSString *filePath = [OWSFileSystem temporaryFilePathWithFileExtension:fileExtension];
BOOL didCreate = [NSFileManager.defaultManager createFileAtPath:filePath contents:nil attributes:nil];
OWSAssert(didCreate);
OWSAssertDebug(didCreate);
self.filePath = filePath;
OWSAssert([NSFileManager.defaultManager fileExistsAtPath:filePath]);
OWSAssertDebug([NSFileManager.defaultManager fileExistsAtPath:filePath]);
success();
}
@ -286,10 +286,10 @@ NS_ASSUME_NONNULL_BEGIN
- (void)ensureOversizeTextAssetLoaded:(ActionSuccessBlock)success failure:(ActionFailureBlock)failure
{
OWSAssert(success);
OWSAssert(failure);
OWSAssert(self.filename.length > 0);
OWSAssert(self.mimeType.length > 0);
OWSAssertDebug(success);
OWSAssertDebug(failure);
OWSAssertDebug(self.filename.length > 0);
OWSAssertDebug(self.mimeType.length > 0);
if (self.filePath) {
success();
@ -314,11 +314,11 @@ NS_ASSUME_NONNULL_BEGIN
NSString *fileExtension = @"txt";
NSString *filePath = [OWSFileSystem temporaryFilePathWithFileExtension:fileExtension];
NSData *data = [message dataUsingEncoding:NSUTF8StringEncoding];
OWSAssert(data);
OWSAssertDebug(data);
BOOL didWrite = [data writeToFile:filePath atomically:YES];
OWSAssert(didWrite);
OWSAssertDebug(didWrite);
self.filePath = filePath;
OWSAssert([NSFileManager.defaultManager fileExistsAtPath:filePath]);
OWSAssertDebug([NSFileManager.defaultManager fileExistsAtPath:filePath]);
success();
}
@ -341,10 +341,10 @@ NS_ASSUME_NONNULL_BEGIN
success:(ActionSuccessBlock)success
failure:(ActionFailureBlock)failure
{
OWSAssert(success);
OWSAssert(failure);
OWSAssert(self.filename.length > 0);
OWSAssert(self.mimeType.length > 0);
OWSAssertDebug(success);
OWSAssertDebug(failure);
OWSAssertDebug(self.filename.length > 0);
OWSAssertDebug(self.mimeType.length > 0);
if (self.filePath) {
success();
@ -354,11 +354,11 @@ NS_ASSUME_NONNULL_BEGIN
NSString *fileExtension = @"txt";
NSString *filePath = [OWSFileSystem temporaryFilePathWithFileExtension:fileExtension];
NSData *data = [text dataUsingEncoding:NSUTF8StringEncoding];
OWSAssert(data);
OWSAssertDebug(data);
BOOL didWrite = [data writeToFile:filePath atomically:YES];
OWSAssert(didWrite);
OWSAssertDebug(didWrite);
self.filePath = filePath;
OWSAssert([NSFileManager.defaultManager fileExistsAtPath:filePath]);
OWSAssertDebug([NSFileManager.defaultManager fileExistsAtPath:filePath]);
success();
}

View File

@ -179,7 +179,7 @@ NS_ASSUME_NONNULL_BEGIN
countryMetadata = [OWSCountryMetadata countryMetadataForCountryCode:countryCode];
}
OWSAssert(countryMetadata);
OWSAssertDebug(countryMetadata);
OWSSignalService.sharedInstance.manualCensorshipCircumventionCountryCode = countryCode;
OWSSignalService.sharedInstance.isCensorshipCircumventionManuallyActivated = isEnabled;
}

View File

@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
const char xorByte = currentKeyBytes[i] ^ 0xff;
[flippedKey appendBytes:&xorByte length:1];
}
OWSAssert(flippedKey.length == currentKey.length);
OWSAssertDebug(flippedKey.length == currentKey.length);
[identityManager saveRemoteIdentity:flippedKey recipientId:recipientId];
}],
[OWSTableItem itemWithTitle:@"Delete all sessions"

View File

@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable OWSTableSection *)sectionForThread:(nullable TSThread *)thread
{
OWSAssert(thread);
OWSAssertDebug(thread);
NSMutableArray<OWSTableItem *> *items = [NSMutableArray new];
@ -453,8 +453,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)ensureGroupOfDataBuilder:(SSKProtoDataMessageBuilder *)dataBuilder thread:(TSThread *)thread
{
OWSAssert(dataBuilder);
OWSAssert(thread);
OWSAssertDebug(dataBuilder);
OWSAssertDebug(thread);
if (![thread isKindOfClass:[TSGroupThread class]]) {
return;
@ -469,7 +469,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)sendStressMessage:(TSOutgoingMessage *)message
{
OWSAssert(message);
OWSAssertDebug(message);
OWSMessageSender *messageSender = [Environment current].messageSender;
[messageSender enqueueMessage:message
@ -484,8 +484,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)sendStressMessage:(TSThread *)thread
block:(DynamicOutgoingMessageBlock)block
{
OWSAssert(thread);
OWSAssert(block);
OWSAssertDebug(thread);
OWSAssertDebug(block);
OWSDynamicOutgoingMessage *message =
[[OWSDynamicOutgoingMessage alloc] initWithPlainTextDataBlock:block thread:thread];
@ -495,8 +495,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)sendStressMessage:(TSThread *)thread timestamp:(uint64_t)timestamp block:(DynamicOutgoingMessageBlock)block
{
OWSAssert(thread);
OWSAssert(block);
OWSAssertDebug(thread);
OWSAssertDebug(block);
OWSDynamicOutgoingMessage *message =
[[OWSDynamicOutgoingMessage alloc] initWithPlainTextDataBlock:block timestamp:timestamp thread:thread];
@ -518,7 +518,7 @@ NS_ASSUME_NONNULL_BEGIN
groupId:[Randomness generateRandomBytes:16]];
thread = [TSGroupThread getOrCreateThreadWithGroupModel:groupModel transaction:transaction];
}];
OWSAssert(thread);
OWSAssertDebug(thread);
[SignalApp.sharedApp presentConversationForThread:thread animated:YES];
}

View File

@ -53,8 +53,8 @@ NS_ASSUME_NONNULL_BEGIN
viewController:(DebugUITableViewController *)viewController
thread:(nullable TSThread *)thread
{
OWSAssert(page);
OWSAssert(viewController);
OWSAssertDebug(page);
OWSAssertDebug(viewController);
__weak DebugUITableViewController *weakSelf = viewController;
return [OWSTableItem disclosureItemWithText:page.name
@ -65,8 +65,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)presentDebugUIForThread:(TSThread *)thread fromViewController:(UIViewController *)fromViewController
{
OWSAssert(thread);
OWSAssert(fromViewController);
OWSAssertDebug(thread);
OWSAssertDebug(fromViewController);
DebugUITableViewController *viewController = [DebugUITableViewController new];
@ -122,7 +122,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)presentDebugUIFromViewController:(UIViewController *)fromViewController
{
OWSAssert(fromViewController);
OWSAssertDebug(fromViewController);
DebugUITableViewController *viewController = [DebugUITableViewController new];

View File

@ -59,7 +59,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)commontInit
{
OWSAssert(!self.avatarView);
OWSAssertDebug(!self.avatarView);
self.backgroundColor = Theme.backgroundColor;
@ -190,9 +190,9 @@ NS_ASSUME_NONNULL_BEGIN
overrideDate:(nullable NSDate *)overrideDate
{
OWSAssertIsOnMainThread();
OWSAssert(thread);
OWSAssert(contactsManager);
OWSAssert(blockedPhoneNumberSet);
OWSAssertDebug(thread);
OWSAssertDebug(contactsManager);
OWSAssertDebug(blockedPhoneNumberSet);
[OWSTableItem configureCell:self];
@ -254,7 +254,7 @@ NS_ASSUME_NONNULL_BEGIN
CGFloat minMargin = CeilEven(unreadBadgeHeight * .5f);
// Spec check. Should be 12pts (6pt on each side) when using default font size.
OWSAssert(UIFont.ows_dynamicTypeBodyFont.pointSize != 17 || minMargin == 12);
OWSAssertDebug(UIFont.ows_dynamicTypeBodyFont.pointSize != 17 || minMargin == 12);
[self.viewConstraints addObjectsFromArray:@[
[self.unreadBadge autoMatchDimension:ALDimensionWidth
@ -344,7 +344,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSAttributedString *)attributedSnippetForThread:(ThreadViewModel *)thread
blockedPhoneNumberSet:(NSSet<NSString *> *)blockedPhoneNumberSet
{
OWSAssert(thread);
OWSAssertDebug(thread);
BOOL isBlocked = NO;
if (!thread.isGroupThread) {

View File

@ -252,8 +252,8 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
- (void)applyTheme
{
OWSAssertIsOnMainThread();
OWSAssert(self.tableView);
OWSAssert(self.searchBar);
OWSAssertDebug(self.tableView);
OWSAssertDebug(self.searchBar);
self.view.backgroundColor = Theme.backgroundColor;
self.tableView.backgroundColor = Theme.backgroundColor;
@ -406,7 +406,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
[searchBar sizeToFit];
// Setting tableHeader calls numberOfSections, which must happen after updateMappings has been called at least once.
OWSAssert(self.tableView.tableHeaderView == nil);
OWSAssertDebug(self.tableView.tableHeaderView == nil);
self.tableView.tableHeaderView = self.searchBar;
// Hide search bar by default. User can pull down to search.
self.tableView.contentOffset = CGPointMake(0, CGRectGetHeight(searchBar.frame));
@ -579,10 +579,10 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
BOOL isShowingSearchResults = !self.searchResultsController.view.hidden;
if (isShowingSearchResults) {
OWSAssert(self.searchBar.text.ows_stripped.length > 0);
OWSAssertDebug(self.searchBar.text.ows_stripped.length > 0);
[self scrollSearchBarToTopAnimated:NO];
} else if (self.lastThread) {
OWSAssert(self.searchBar.text.ows_stripped.length == 0);
OWSAssertDebug(self.searchBar.text.ows_stripped.length == 0);
// When returning to home view, try to ensure that the "last" thread is still
// visible. The threads often change ordering while in conversation view due
@ -795,7 +795,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
- (ThreadViewModel *)threadViewModelForIndexPath:(NSIndexPath *)indexPath
{
TSThread *threadRecord = [self threadForIndexPath:indexPath];
OWSAssert(threadRecord);
OWSAssertDebug(threadRecord);
ThreadViewModel *_Nullable cachedThreadViewModel = [self.threadViewModelCache objectForKey:threadRecord.uniqueId];
if (cachedThreadViewModel) {
@ -832,7 +832,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
- (UITableViewCell *)tableView:(UITableView *)tableView cellForConversationAtIndexPath:(NSIndexPath *)indexPath
{
HomeViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:HomeViewCell.cellReuseIdentifier];
OWSAssert(cell);
OWSAssertDebug(cell);
ThreadViewModel *thread = [self threadViewModelForIndexPath:indexPath];
[cell configureWithThread:thread
@ -845,7 +845,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
- (UITableViewCell *)cellForArchivedConversationsRow:(UITableView *)tableView
{
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:kArchivedConversationsReuseIdentifier];
OWSAssert(cell);
OWSAssertDebug(cell);
[OWSTableItem configureCell:cell];
for (UIView *subview in cell.contentView.subviews) {
@ -853,7 +853,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
}
UIImage *disclosureImage = [UIImage imageNamed:(CurrentAppContext().isRTL ? @"NavBarBack" : @"NavBarBackRTL")];
OWSAssert(disclosureImage);
OWSAssertDebug(disclosureImage);
UIImageView *disclosureImageView = [UIImageView new];
disclosureImageView.image = [disclosureImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
disclosureImageView.tintColor = [UIColor colorWithRGBHex:0xd1d1d6];
@ -1010,7 +1010,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
self.searchBar.text = nil;
[self.searchBar resignFirstResponder];
OWSAssert(!self.searchBar.isFirstResponder);
OWSAssertDebug(!self.searchBar.isFirstResponder);
[self updateSearchResultsVisibility];
@ -1050,7 +1050,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
[self.searchBar resignFirstResponder];
OWSAssert(!self.searchBar.isFirstResponder);
OWSAssertDebug(!self.searchBar.isFirstResponder);
}
#pragma mark - ConversationSearchViewDelegate
@ -1058,7 +1058,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
- (void)conversationSearchViewWillBeginDragging
{
[self.searchBar resignFirstResponder];
OWSAssert(!self.searchBar.isFirstResponder);
OWSAssertDebug(!self.searchBar.isFirstResponder);
}
#pragma mark - HomeFeedTableViewCellDelegate
@ -1193,20 +1193,20 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
- (YapDatabaseViewMappings *)threadMappings
{
OWSAssert(_threadMappings != nil);
OWSAssertDebug(_threadMappings != nil);
return _threadMappings;
}
- (void)showInboxGrouping
{
OWSAssert(self.homeViewMode == HomeViewMode_Archive);
OWSAssertDebug(self.homeViewMode == HomeViewMode_Archive);
[self.navigationController popToRootViewControllerAnimated:YES];
}
- (void)showArchivedConversations
{
OWSAssert(self.homeViewMode == HomeViewMode_Inbox);
OWSAssertDebug(self.homeViewMode == HomeViewMode_Inbox);
// When showing archived conversations, we want to use a conventional "back" button
// to return to the "inbox" home view.
@ -1351,7 +1351,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
for (YapDatabaseViewRowChange *rowChange in rowChanges) {
NSString *key = rowChange.collectionKey.key;
OWSAssert(key);
OWSAssertDebug(key);
[self.threadViewModelCache removeObjectForKey:key];
switch (rowChange.type) {
@ -1447,7 +1447,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
@"EMPTY_INBOX_NEW_USER_TEXT", @"Body text a new user sees when viewing an empty inbox");
}
} else {
OWSAssert(self.homeViewMode == HomeViewMode_Archive);
OWSAssertDebug(self.homeViewMode == HomeViewMode_Archive);
firstLine = NSLocalizedString(
@"EMPTY_ARCHIVE_TITLE", @"Header text an existing user sees when viewing an empty archive");
secondLine = NSLocalizedString(

View File

@ -136,7 +136,7 @@ NS_ASSUME_NONNULL_BEGIN
{
CGSize viewSize = self.scrollView.bounds.size;
UIImage *image = self.image;
OWSAssert(image);
OWSAssertDebug(image);
if (image.size.width == 0 || image.size.height == 0) {
OWSFailDebug(@"Invalid image dimensions. %@", NSStringFromCGSize(image.size));
@ -200,7 +200,7 @@ NS_ASSUME_NONNULL_BEGIN
self.mediaView = imageView;
}
OWSAssert(self.mediaView);
OWSAssertDebug(self.mediaView);
// We add these gestures to mediaView rather than
// the root view so that interacting with the video player
@ -355,15 +355,15 @@ NS_ASSUME_NONNULL_BEGIN
- (void)didPressPlayBarButton:(id)sender
{
OWSAssert(self.isVideo);
OWSAssert(self.videoPlayer);
OWSAssertDebug(self.isVideo);
OWSAssertDebug(self.videoPlayer);
[self playVideo];
}
- (void)didPressPauseBarButton:(id)sender
{
OWSAssert(self.isVideo);
OWSAssert(self.videoPlayer);
OWSAssertDebug(self.isVideo);
OWSAssertDebug(self.videoPlayer);
[self pauseVideo];
}
@ -376,7 +376,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)centerMediaViewConstraints
{
OWSAssert(self.scrollView);
OWSAssertDebug(self.scrollView);
CGSize scrollViewSize = self.scrollView.bounds.size;
CGSize imageViewSize = self.mediaView.frame.size;
@ -411,7 +411,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)playVideo
{
OWSAssert(self.videoPlayer);
OWSAssertDebug(self.videoPlayer);
self.playVideoButton.hidden = YES;
@ -422,8 +422,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)pauseVideo
{
OWSAssert(self.isVideo);
OWSAssert(self.videoPlayer);
OWSAssertDebug(self.isVideo);
OWSAssertDebug(self.videoPlayer);
[self.videoPlayer pause];
@ -439,8 +439,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)stopVideo
{
OWSAssert(self.isVideo);
OWSAssert(self.videoPlayer);
OWSAssertDebug(self.isVideo);
OWSAssertDebug(self.videoPlayer);
[self.videoPlayer stop];
@ -453,8 +453,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)videoPlayerDidPlayToCompletion:(OWSVideoPlayer *)videoPlayer
{
OWSAssert(self.isVideo);
OWSAssert(self.videoPlayer);
OWSAssertDebug(self.isVideo);
OWSAssertDebug(self.videoPlayer);
OWSLogVerbose(@"");
[self stopVideo];
@ -464,13 +464,13 @@ NS_ASSUME_NONNULL_BEGIN
- (void)playerProgressBarDidStartScrubbing:(PlayerProgressBar *)playerProgressBar
{
OWSAssert(self.videoPlayer);
OWSAssertDebug(self.videoPlayer);
[self.videoPlayer pause];
}
- (void)playerProgressBar:(PlayerProgressBar *)playerProgressBar scrubbedToTime:(CMTime)time
{
OWSAssert(self.videoPlayer);
OWSAssertDebug(self.videoPlayer);
[self.videoPlayer seekToTime:time];
}
@ -478,7 +478,7 @@ NS_ASSUME_NONNULL_BEGIN
didFinishScrubbingAtTime:(CMTime)time
shouldResumePlayback:(BOOL)shouldResumePlayback
{
OWSAssert(self.videoPlayer);
OWSAssertDebug(self.videoPlayer);
[self.videoPlayer seekToTime:time];
if (shouldResumePlayback) {

View File

@ -86,7 +86,7 @@ NS_ASSUME_NONNULL_BEGIN
action:@selector(dismissPressed)];
// TODO: We should use separate RTL and LTR flavors of this asset.
UIImage *newGroupImage = [UIImage imageNamed:@"btnGroup--white"];
OWSAssert(newGroupImage);
OWSAssertDebug(newGroupImage);
UIBarButtonItem *newGroupButton = [[UIBarButtonItem alloc] initWithImage:newGroupImage
style:UIBarButtonItemStylePlain
target:self
@ -182,7 +182,7 @@ NS_ASSUME_NONNULL_BEGIN
[contents autoCenterInSuperview];
UIImage *heroImage = [UIImage imageNamed:@"uiEmptyContact"];
OWSAssert(heroImage);
OWSAssertDebug(heroImage);
UIImageView *heroImageView = [[UIImageView alloc] initWithImage:heroImage];
heroImageView.layer.minificationFilter = kCAFilterTrilinear;
heroImageView.layer.magnificationFilter = kCAFilterTrilinear;
@ -413,7 +413,7 @@ NS_ASSUME_NONNULL_BEGIN
customRowHeight:UITableViewAutomaticDimension]];
} else {
UITableViewCell *loadingCell = [OWSTableItem newCell];
OWSAssert(loadingCell.contentView);
OWSAssertDebug(loadingCell.contentView);
UIActivityIndicatorView *activityIndicatorView =
[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
@ -506,7 +506,7 @@ NS_ASSUME_NONNULL_BEGIN
// "invite via SMS..." cells.
NSArray<NSString *> *searchPhoneNumbers = [self parsePossibleSearchPhoneNumbers];
for (NSString *phoneNumber in searchPhoneNumbers) {
OWSAssert(phoneNumber.length > 0);
OWSAssertDebug(phoneNumber.length > 0);
if ([self.nonContactAccountSet containsObject:phoneNumber]) {
[phoneNumbersSection
@ -611,7 +611,7 @@ NS_ASSUME_NONNULL_BEGIN
for (Contact *contact in invitees) {
hasSearchResults = YES;
OWSAssert(contact.parsedPhoneNumbers.count > 0);
OWSAssertDebug(contact.parsedPhoneNumbers.count > 0);
// TODO: Should we invite all of their phone numbers?
PhoneNumber *phoneNumber = contact.parsedPhoneNumbers[0];
NSString *displayName = contact.fullName;
@ -737,7 +737,7 @@ NS_ASSUME_NONNULL_BEGIN
[[OWSInviteFlow alloc] initWithPresentingViewController:self
contactsManager:self.contactsViewHelper.contactsManager];
OWSAssert([phoneNumber length] > 0);
OWSAssertDebug([phoneNumber length] > 0);
NSString *confirmMessage = NSLocalizedString(@"SEND_SMS_CONFIRM_TITLE", @"");
if ([phoneNumber length] > 0) {
confirmMessage = [[NSLocalizedString(@"SEND_SMS_INVITE_TITLE", @"") stringByAppendingString:phoneNumber]
@ -815,14 +815,14 @@ NS_ASSUME_NONNULL_BEGIN
- (void)newConversationWithRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:recipientId];
[self newConversationWithThread:thread];
}
- (void)newConversationWithThread:(TSThread *)thread
{
OWSAssert(thread != nil);
OWSAssertDebug(thread != nil);
[SignalApp.sharedApp presentConversationForThread:thread action:ConversationViewActionCompose animated:NO];
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}
@ -858,7 +858,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)recipientIdWasSelected:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
[self newConversationWithRecipientId:recipientId];
}
@ -904,11 +904,11 @@ NS_ASSUME_NONNULL_BEGIN
dispatch_once(&onceToken, ^{
NSMutableDictionary *map = [NSMutableDictionary new];
for (NSString *countryCode in [PhoneNumberUtil countryCodesForSearchTerm:nil]) {
OWSAssert(countryCode.length > 0);
OWSAssertDebug(countryCode.length > 0);
NSString *callingCode = [PhoneNumberUtil callingCodeFromCountryCode:countryCode];
OWSAssert(callingCode.length > 0);
OWSAssert([callingCode hasPrefix:@"+"]);
OWSAssert(![callingCode isEqualToString:@"+0"]);
OWSAssertDebug(callingCode.length > 0);
OWSAssertDebug([callingCode hasPrefix:@"+"]);
OWSAssertDebug(![callingCode isEqualToString:@"+0"]);
map[callingCode] = countryCode;
}
@ -919,7 +919,7 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable NSString *)callingCodeForPossiblePhoneNumber:(NSString *)phoneNumber
{
OWSAssert([phoneNumber hasPrefix:@"+"]);
OWSAssertDebug([phoneNumber hasPrefix:@"+"]);
for (NSString *callingCode in [self callingCodesToCountryCodeMap].allKeys) {
if ([phoneNumber hasPrefix:callingCode]) {

View File

@ -227,7 +227,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
NewGroupViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
OWSCAssertDebug(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
BOOL isCurrentMember = [strongSelf.memberRecipientIds containsObject:recipientId];
@ -313,7 +313,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
NewGroupViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
OWSCAssertDebug(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
@ -404,7 +404,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
- (void)removeRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
[self.memberRecipientIds removeObject:recipientId];
[self updateTableContents];
@ -412,7 +412,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
- (void)addRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
[self.memberRecipientIds addObject:recipientId];
self.hasUnsavedChanges = YES;
@ -444,7 +444,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
thread = [TSGroupThread getOrCreateThreadWithGroupModel:model transaction:transaction];
}];
OWSAssert(thread);
OWSAssertDebug(thread);
[OWSProfileManager.sharedManager addThreadToProfileWhitelist:thread];
@ -606,7 +606,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
- (void)avatarDidChange:(UIImage *)image
{
OWSAssertIsOnMainThread();
OWSAssert(image);
OWSAssertDebug(image);
self.groupAvatar = image;
}
@ -630,7 +630,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
- (BOOL)isRecipientGroupMember:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
return [self.memberRecipientIds containsObject:recipientId];
}

View File

@ -96,7 +96,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)pinEntryView:(PinEntryView *)entryView submittedPinCode:(NSString *)pinCode
{
OWSAssert(self.entryView.hasValidPin);
OWSAssertDebug(self.entryView.hasValidPin);
[self tryToRegisterWithPinCode:pinCode];
}
@ -112,9 +112,9 @@ NS_ASSUME_NONNULL_BEGIN
- (void)tryToRegisterWithPinCode:(NSString *)pinCode
{
OWSAssert(self.entryView.hasValidPin);
OWSAssert(self.verificationCode.length > 0);
OWSAssert(pinCode.length > 0);
OWSAssertDebug(self.entryView.hasValidPin);
OWSAssertDebug(self.verificationCode.length > 0);
OWSAssertDebug(pinCode.length > 0);
OWSLogInfo(@"");

View File

@ -76,7 +76,7 @@ NS_ASSUME_NONNULL_BEGIN
break;
case OWS2FASettingsMode_SelectPIN:
case OWS2FASettingsMode_ConfirmPIN:
OWSAssert(![OWS2FAManager.sharedManager is2FAEnabled]);
OWSAssertDebug(![OWS2FAManager.sharedManager is2FAEnabled]);
break;
}
@ -301,18 +301,18 @@ NS_ASSUME_NONNULL_BEGIN
OWSFailDebug(@"status mode should not have a next button.");
return;
case OWS2FASettingsMode_SelectPIN: {
OWSAssert(self.hasValidPin);
OWSAssertDebug(self.hasValidPin);
OWS2FASettingsViewController *vc = [OWS2FASettingsViewController new];
vc.mode = OWS2FASettingsMode_ConfirmPIN;
vc.candidatePin = self.pinTextfield.text;
OWSAssert(self.root2FAViewController);
OWSAssertDebug(self.root2FAViewController);
vc.root2FAViewController = self.root2FAViewController;
[self.navigationController pushViewController:vc animated:YES];
break;
}
case OWS2FASettingsMode_ConfirmPIN: {
OWSAssert(self.hasValidPin);
OWSAssertDebug(self.hasValidPin);
if ([self.pinTextfield.text isEqualToString:self.candidatePin]) {
[self tryToEnable2FA];
@ -336,7 +336,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)showEnable2FAWorkUI
{
OWSAssert(![OWS2FAManager.sharedManager is2FAEnabled]);
OWSAssertDebug(![OWS2FAManager.sharedManager is2FAEnabled]);
OWSLogInfo(@"");
@ -378,7 +378,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)tryToEnable2FA
{
OWSAssert(self.candidatePin.length > 0);
OWSAssertDebug(self.candidatePin.length > 0);
OWSLogInfo(@"");
@ -414,8 +414,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)showCompleteUI
{
OWSAssert([OWS2FAManager.sharedManager is2FAEnabled]);
OWSAssert(self.root2FAViewController);
OWSAssertDebug([OWS2FAManager.sharedManager is2FAEnabled]);
OWSAssertDebug(self.root2FAViewController);
OWSLogInfo(@"");

View File

@ -444,7 +444,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
[[SignalsNavigationController alloc] initWithRootViewController:homeView];
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
appDelegate.window.rootViewController = navigationController;
OWSAssert([navigationController.topViewController isKindOfClass:[HomeViewController class]]);
OWSAssertDebug([navigationController.topViewController isKindOfClass:[HomeViewController class]]);
}
#pragma mark - UITextFieldDelegate
@ -542,8 +542,8 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
+ (void)presentForAppSettings:(UINavigationController *)navigationController
{
OWSAssert(navigationController);
OWSAssert([navigationController isKindOfClass:[OWSNavigationController class]]);
OWSAssertDebug(navigationController);
OWSAssertDebug([navigationController isKindOfClass:[OWSNavigationController class]]);
ProfileViewController *vc = [[ProfileViewController alloc] initWithMode:ProfileViewMode_AppSettings];
[navigationController pushViewController:vc animated:YES];
@ -551,8 +551,8 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
+ (void)presentForRegistration:(UINavigationController *)navigationController
{
OWSAssert(navigationController);
OWSAssert([navigationController isKindOfClass:[OWSNavigationController class]]);
OWSAssertDebug(navigationController);
OWSAssertDebug([navigationController isKindOfClass:[OWSNavigationController class]]);
ProfileViewController *vc = [[ProfileViewController alloc] initWithMode:ProfileViewMode_Registration];
[navigationController pushViewController:vc animated:YES];
@ -560,7 +560,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
+ (void)presentForUpgradeOrNag:(HomeViewController *)fromViewController
{
OWSAssert(fromViewController);
OWSAssertDebug(fromViewController);
ProfileViewController *vc = [[ProfileViewController alloc] initWithMode:ProfileViewMode_UpgradeOrNag];
OWSNavigationController *navigationController = [[OWSNavigationController alloc] initWithRootViewController:vc];
@ -578,7 +578,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
- (void)avatarDidChange:(UIImage *)image
{
OWSAssertIsOnMainThread();
OWSAssert(image);
OWSAssertDebug(image);
self.avatar = [image resizedImageToFillPixelSize:CGSizeMake(kOWSProfileManager_MaxAvatarDiameter,
kOWSProfileManager_MaxAvatarDiameter)];

View File

@ -251,7 +251,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSString *)phoneNumberText
{
OWSAssert([TSAccountManager localNumber] != nil);
OWSAssertDebug([TSAccountManager localNumber] != nil);
return [PhoneNumber bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:[TSAccountManager localNumber]];
}

View File

@ -53,7 +53,7 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
// Do any additional setup after loading the view.
[self populateDefaultCountryNameAndCode];
OWSAssert([self.navigationController isKindOfClass:[OWSNavigationController class]]);
OWSAssertDebug([self.navigationController isKindOfClass:[OWSNavigationController class]]);
[SignalApp.sharedApp setSignUpFlowNavigationController:(OWSNavigationController *)self.navigationController];
}
@ -302,7 +302,7 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
- (BOOL)tryToApplyPhoneNumberE164:(NSString *)phoneNumberE164
{
OWSAssert(phoneNumberE164);
OWSAssertDebug(phoneNumberE164);
if (phoneNumberE164.length < 1) {
OWSFailDebug(@"Could not resume re-registration; invalid phoneNumberE164.");
@ -368,9 +368,9 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
countryCode:(NSString *)countryCode
{
OWSAssertIsOnMainThread();
OWSAssert(countryName.length > 0);
OWSAssert(callingCode.length > 0);
OWSAssert(countryCode.length > 0);
OWSAssertDebug(countryName.length > 0);
OWSAssertDebug(callingCode.length > 0);
OWSAssertDebug(countryCode.length > 0);
_countryCode = countryCode;
_callingCode = callingCode;
@ -510,9 +510,9 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
countryName:(NSString *)countryName
callingCode:(NSString *)callingCode
{
OWSAssert(countryCode.length > 0);
OWSAssert(countryName.length > 0);
OWSAssert(callingCode.length > 0);
OWSAssertDebug(countryCode.length > 0);
OWSAssertDebug(countryName.length > 0);
OWSAssertDebug(callingCode.length > 0);
[self updateCountryWithName:countryName callingCode:callingCode countryCode:countryCode];
@ -562,8 +562,8 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
- (NSString *_Nullable)debugValueForKey:(NSString *)key
{
OWSCAssert([NSThread isMainThread]);
OWSCAssert(key.length > 0);
OWSCAssertDebug([NSThread isMainThread]);
OWSCAssertDebug(key.length > 0);
NSError *error;
NSString *value = [SAMKeychain passwordForService:kKeychainService_LastRegistered account:key error:&error];
@ -575,9 +575,9 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
- (void)setDebugValue:(NSString *)value forKey:(NSString *)key
{
OWSCAssert([NSThread isMainThread]);
OWSCAssert(key.length > 0);
OWSCAssert(value.length > 0);
OWSCAssertDebug([NSThread isMainThread]);
OWSCAssertDebug(key.length > 0);
OWSCAssertDebug(value.length > 0);
NSError *error;
[SAMKeychain setAccessibilityType:kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly];

View File

@ -48,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)phoneNumberWasSelected:(NSString *)phoneNumber
{
OWSAssert(phoneNumber.length > 0);
OWSAssertDebug(phoneNumber.length > 0);
__weak AddToGroupViewController *weakSelf = self;
@ -87,14 +87,14 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)canSignalAccountBeSelected:(SignalAccount *)signalAccount
{
OWSAssert(signalAccount);
OWSAssertDebug(signalAccount);
return ![self.addToGroupDelegate isRecipientGroupMember:signalAccount.recipientId];
}
- (void)signalAccountWasSelected:(SignalAccount *)signalAccount
{
OWSAssert(signalAccount);
OWSAssertDebug(signalAccount);
__weak AddToGroupViewController *weakSelf = self;
ContactsViewHelper *helper = self.contactsViewHelper;
@ -137,7 +137,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)addToGroup:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
[self.addToGroupDelegate recipientIdWasAdded:recipientId];
[self.navigationController popViewControllerAnimated:YES];
@ -160,7 +160,7 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable NSString *)accessoryMessageForSignalAccount:(SignalAccount *)signalAccount
{
OWSAssert(signalAccount);
OWSAssertDebug(signalAccount);
if ([self.addToGroupDelegate isRecipientGroupMember:signalAccount.recipientId]) {
return NSLocalizedString(@"NEW_GROUP_MEMBER_LABEL", @"An indicator that a user is a member of the new group.");

View File

@ -91,7 +91,7 @@ typedef void (^CustomLayoutBlock)(void);
+ (void)presentFromViewController:(UIViewController *)viewController recipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
OWSRecipientIdentity *_Nullable recipientIdentity =
[[OWSIdentityManager sharedManager] recipientIdentityForRecipientId:recipientId];
@ -140,7 +140,7 @@ typedef void (^CustomLayoutBlock)(void);
- (void)configureWithRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
self.recipientId = recipientId;
@ -149,7 +149,7 @@ typedef void (^CustomLayoutBlock)(void);
OWSRecipientIdentity *_Nullable recipientIdentity =
[[OWSIdentityManager sharedManager] recipientIdentityForRecipientId:recipientId];
OWSAssert(recipientIdentity);
OWSAssertDebug(recipientIdentity);
// By capturing the identity key when we enter these views, we prevent the edge case
// where the user verifies a key that we learned about while this view was open.
self.identityKey = recipientIdentity.identityKey;
@ -340,7 +340,7 @@ typedef void (^CustomLayoutBlock)(void);
- (void)updateVerificationStateLabel
{
OWSAssert(self.recipientId.length > 0);
OWSAssertDebug(self.recipientId.length > 0);
BOOL isVerified = [[OWSIdentityManager sharedManager] verificationStateForRecipientId:self.recipientId]
== OWSVerificationStateVerified;

View File

@ -36,7 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)configureWithRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
self.recipientId = recipientId;
self.accountManager = [TSAccountManager sharedInstance];
@ -46,7 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSRecipientIdentity *_Nullable recipientIdentity =
[[OWSIdentityManager sharedManager] recipientIdentityForRecipientId:recipientId];
OWSAssert(recipientIdentity);
OWSAssertDebug(recipientIdentity);
// By capturing the identity key when we enter these views, we prevent the edge case
// where the user verifies a key that we learned about while this view was open.
self.identityKey = recipientIdentity.identityKey;
@ -165,11 +165,11 @@ NS_ASSUME_NONNULL_BEGIN
contactName:(NSString *)contactName
tag:(NSString *)tag
{
OWSAssert(viewController);
OWSAssert(identityKey.length > 0);
OWSAssert(recipientId.length > 0);
OWSAssert(contactName.length > 0);
OWSAssert(tag.length > 0);
OWSAssertDebug(viewController);
OWSAssertDebug(identityKey.length > 0);
OWSAssertDebug(recipientId.length > 0);
OWSAssertDebug(contactName.length > 0);
OWSAssertDebug(tag.length > 0);
OWSLogInfo(@"%@ Successfully verified safety numbers.", tag);
@ -209,9 +209,9 @@ NS_ASSUME_NONNULL_BEGIN
cancelBlock:(void (^_Nonnull)(void))cancelBlock
tag:(NSString *)tag
{
OWSAssert(viewController);
OWSAssert(cancelBlock);
OWSAssert(tag.length > 0);
OWSAssertDebug(viewController);
OWSAssertDebug(cancelBlock);
OWSAssertDebug(tag.length > 0);
OWSLogInfo(@"%@ Failed to verify safety numbers.", tag);

View File

@ -69,7 +69,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)configureWithRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
_recipientId = recipientId;
}
@ -129,7 +129,7 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable NSString *)displayNameForContact:(Contact *)contact
{
OWSAssert(contact);
OWSAssertDebug(contact);
if (contact.fullName.length > 0) {
return contact.fullName;
@ -186,8 +186,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)presentContactViewControllerForContact:(Contact *)contact
{
OWSAssert(contact);
OWSAssert(self.recipientId);
OWSAssertDebug(contact);
OWSAssertDebug(self.recipientId);
if (!self.contactsManager.supportsContactEditing) {
OWSFailDebug(@"Contact editing not supported");

View File

@ -153,7 +153,7 @@ const CGFloat kIconViewLength = 24;
- (void)configureWithThread:(TSThread *)thread uiDatabaseConnection:(YapDatabaseConnection *)uiDatabaseConnection
{
OWSAssert(thread);
OWSAssertDebug(thread);
self.thread = thread;
self.uiDatabaseConnection = uiDatabaseConnection;
@ -170,7 +170,7 @@ const CGFloat kIconViewLength = 24;
- (void)updateEditButton
{
OWSAssert(self.thread);
OWSAssertDebug(self.thread);
if ([self.thread isKindOfClass:[TSContactThread class]] && self.contactsManager.supportsContactEditing
&& self.hasExistingContact) {
@ -184,7 +184,7 @@ const CGFloat kIconViewLength = 24;
- (BOOL)hasExistingContact
{
OWSAssert([self.thread isKindOfClass:[TSContactThread class]]);
OWSAssertDebug([self.thread isKindOfClass:[TSContactThread class]]);
TSContactThread *contactThread = (TSContactThread *)self.thread;
NSString *recipientId = contactThread.contactIdentifier;
return [self.contactsManager hasSignalAccountForRecipientId:recipientId];
@ -318,7 +318,7 @@ const CGFloat kIconViewLength = 24;
}
actionBlock:^{
OWSConversationSettingsViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
OWSCAssertDebug(strongSelf);
TSContactThread *contactThread = (TSContactThread *)strongSelf.thread;
NSString *recipientId = contactThread.contactIdentifier;
[strongSelf presentAddToContactViewControllerWithRecipientId:recipientId];
@ -371,7 +371,7 @@ const CGFloat kIconViewLength = 24;
itemWithCustomCellBlock:^{
UITableViewCell *cell = [OWSTableItem newCell];
OWSConversationSettingsViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
OWSCAssertDebug(strongSelf);
cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
@ -425,7 +425,7 @@ const CGFloat kIconViewLength = 24;
itemWithCustomCellBlock:^{
UITableViewCell *cell = [OWSTableItem newCell];
OWSConversationSettingsViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
OWSCAssertDebug(strongSelf);
cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
@ -517,7 +517,7 @@ const CGFloat kIconViewLength = 24;
[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
[OWSTableItem configureCell:cell];
OWSConversationSettingsViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
OWSCAssertDebug(strongSelf);
cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
@ -556,7 +556,7 @@ const CGFloat kIconViewLength = 24;
[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
[OWSTableItem configureCell:cell];
OWSConversationSettingsViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
OWSCAssertDebug(strongSelf);
cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
@ -631,7 +631,7 @@ const CGFloat kIconViewLength = 24;
@"table cell label in conversation settings")
iconName:@"table_ic_block"];
OWSConversationSettingsViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
OWSCAssertDebug(strongSelf);
cell.selectionStyle = UITableViewCellSelectionStyleNone;
UISwitch *blockUserSwitch = [UISwitch new];
@ -656,7 +656,7 @@ const CGFloat kIconViewLength = 24;
- (UITableViewCell *)disclosureCellWithName:(NSString *)name iconColor:(UIColor *)iconColor
{
OWSAssert(name.length > 0);
OWSAssertDebug(name.length > 0);
UIView *iconView = [UIView containerView];
[iconView autoSetDimensionsToSize:CGSizeMake(kIconViewLength, kIconViewLength)];
@ -674,14 +674,14 @@ const CGFloat kIconViewLength = 24;
- (UITableViewCell *)cellWithName:(NSString *)name iconName:(NSString *)iconName
{
OWSAssert(iconName.length > 0);
OWSAssertDebug(iconName.length > 0);
UIImageView *iconView = [self viewForIconWithName:iconName];
return [self cellWithName:name iconView:iconView];
}
- (UITableViewCell *)cellWithName:(NSString *)name iconView:(UIView *)iconView
{
OWSAssert(name.length > 0);
OWSAssertDebug(name.length > 0);
UITableViewCell *cell = [OWSTableItem newCell];
cell.preservesSuperviewLayoutMargins = YES;
@ -727,7 +727,7 @@ const CGFloat kIconViewLength = 24;
const NSUInteger kAvatarSize = 68;
UIImage *avatarImage =
[OWSAvatarBuilder buildImageForThread:self.thread diameter:kAvatarSize contactsManager:self.contactsManager];
OWSAssert(avatarImage);
OWSAssertDebug(avatarImage);
AvatarImageView *avatarView = [[AvatarImageView alloc] initWithImage:avatarImage];
_avatarView = avatarView;
@ -833,7 +833,7 @@ const CGFloat kIconViewLength = 24;
{
UIImage *icon = [UIImage imageNamed:iconName];
OWSAssert(icon);
OWSAssertDebug(icon);
UIImageView *iconView = [UIImageView new];
iconView.image = [icon imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
iconView.tintColor = [Theme secondaryColor];
@ -901,7 +901,7 @@ const CGFloat kIconViewLength = 24;
- (void)showVerificationView
{
NSString *recipientId = self.thread.contactIdentifier;
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
[FingerprintViewController presentFromViewController:self recipientId:recipientId];
}
@ -915,7 +915,7 @@ const CGFloat kIconViewLength = 24;
- (void)showUpdateGroupView:(UpdateGroupMode)mode
{
OWSAssert(self.conversationSettingsViewDelegate);
OWSAssertDebug(self.conversationSettingsViewDelegate);
UpdateGroupViewController *updateGroupViewController = [UpdateGroupViewController new];
updateGroupViewController.conversationSettingsViewDelegate = self.conversationSettingsViewDelegate;
@ -1015,7 +1015,7 @@ const CGFloat kIconViewLength = 24;
- (void)blockUserSwitchDidChange:(id)sender
{
OWSAssert(!self.isGroupThread);
OWSAssertDebug(!self.isGroupThread);
if (![sender isKindOfClass:[UISwitch class]]) {
OWSFailDebug(@"Unexpected sender for block user switch: %@", sender);
@ -1025,7 +1025,7 @@ const CGFloat kIconViewLength = 24;
BOOL isCurrentlyBlocked = [[_blockingManager blockedPhoneNumbers] containsObject:self.thread.contactIdentifier];
if (blockUserSwitch.isOn) {
OWSAssert(!isCurrentlyBlocked);
OWSAssertDebug(!isCurrentlyBlocked);
if (isCurrentlyBlocked) {
return;
}
@ -1038,7 +1038,7 @@ const CGFloat kIconViewLength = 24;
blockUserSwitch.on = isBlocked;
}];
} else {
OWSAssert(isCurrentlyBlocked);
OWSAssertDebug(isCurrentlyBlocked);
if (!isCurrentlyBlocked) {
return;
}
@ -1226,7 +1226,7 @@ const CGFloat kIconViewLength = 24;
// reference to it until we're dismissed.
self.mediaGalleryViewController = vc;
OWSAssert([self.navigationController isKindOfClass:[OWSNavigationController class]]);
OWSAssertDebug([self.navigationController isKindOfClass:[OWSNavigationController class]]);
[vc pushTileViewFromNavController:(OWSNavigationController *)self.navigationController];
}
#pragma mark - Notifications
@ -1243,7 +1243,7 @@ const CGFloat kIconViewLength = 24;
OWSAssertIsOnMainThread();
NSString *recipientId = notification.userInfo[kNSNotificationKey_ProfileRecipientId];
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
if (recipientId.length > 0 && [self.thread isKindOfClass:[TSContactThread class]] &&
[self.thread.contactIdentifier isEqualToString:recipientId]) {
@ -1276,7 +1276,7 @@ const CGFloat kIconViewLength = 24;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
ConversationConfigurationSyncOperation *operation =
[[ConversationConfigurationSyncOperation alloc] initWithThread:self.thread];
OWSAssert(operation.isReady);
OWSAssertDebug(operation.isReady);
[operation start];
});

View File

@ -87,9 +87,9 @@ NS_ASSUME_NONNULL_BEGIN
_thread = thread;
OWSAssert(self.thread);
OWSAssert(self.thread.groupModel);
OWSAssert(self.thread.groupModel.groupMemberIds);
OWSAssertDebug(self.thread);
OWSAssertDebug(self.thread.groupModel);
OWSAssertDebug(self.thread.groupModel.groupMemberIds);
self.memberRecipientIds = [NSSet setWithArray:self.thread.groupModel.groupMemberIds];
}
@ -98,7 +98,7 @@ NS_ASSUME_NONNULL_BEGIN
{
[super viewDidLoad];
OWSAssert([self.navigationController isKindOfClass:[OWSNavigationController class]]);
OWSAssertDebug([self.navigationController isKindOfClass:[OWSNavigationController class]]);
self.title = _thread.groupModel.groupName;
@ -112,7 +112,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)updateTableContents
{
OWSAssert(self.thread);
OWSAssertDebug(self.thread);
OWSTableContents *contents = [OWSTableContents new];
@ -156,8 +156,8 @@ NS_ASSUME_NONNULL_BEGIN
toSection:(OWSTableSection *)section
useVerifyAction:(BOOL)useVerifyAction
{
OWSAssert(recipientIds);
OWSAssert(section);
OWSAssertDebug(recipientIds);
OWSAssertDebug(section);
__weak ShowGroupMembersViewController *weakSelf = self;
ContactsViewHelper *helper = self.contactsViewHelper;
@ -172,7 +172,7 @@ NS_ASSUME_NONNULL_BEGIN
[section addItem:[OWSTableItem
itemWithCustomCellBlock:^{
ShowGroupMembersViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
OWSCAssertDebug(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
OWSVerificationState verificationState =
@ -270,7 +270,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)didSelectRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
ContactsViewHelper *helper = self.contactsViewHelper;
SignalAccount *_Nullable signalAccount = [helper fetchSignalAccountForRecipientId:recipientId];
@ -392,7 +392,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)showContactInfoViewForRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
[self.contactsViewHelper presentContactViewControllerForRecipientId:recipientId
fromViewController:self
@ -401,7 +401,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)showConversationViewForRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
[SignalApp.sharedApp presentConversationForRecipientId:recipientId
action:ConversationViewActionCompose
@ -417,7 +417,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)showSafetyNumberView:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
[FingerprintViewController presentFromViewController:self recipientId:recipientId];
}

View File

@ -97,9 +97,9 @@ NS_ASSUME_NONNULL_BEGIN
{
[super loadView];
OWSAssert(self.thread);
OWSAssert(self.thread.groupModel);
OWSAssert(self.thread.groupModel.groupMemberIds);
OWSAssertDebug(self.thread);
OWSAssertDebug(self.thread.groupModel);
OWSAssertDebug(self.thread.groupModel.groupMemberIds);
self.view.backgroundColor = Theme.backgroundColor;
@ -166,8 +166,8 @@ NS_ASSUME_NONNULL_BEGIN
- (UIView *)firstSectionHeader
{
OWSAssert(self.thread);
OWSAssert(self.thread.groupModel);
OWSAssertDebug(self.thread);
OWSAssertDebug(self.thread.groupModel);
UIView *firstSectionHeader = [UIView new];
firstSectionHeader.userInteractionEnabled = YES;
@ -232,7 +232,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)updateTableContents
{
OWSAssert(self.thread);
OWSAssertDebug(self.thread);
OWSTableContents *contents = [OWSTableContents new];
@ -262,7 +262,7 @@ NS_ASSUME_NONNULL_BEGIN
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
UpdateGroupViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
OWSCAssertDebug(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
BOOL isPreviousMember = [strongSelf.previousMemberRecipientIds containsObject:recipientId];
@ -323,7 +323,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)showUnblockAlertForSignalAccount:(SignalAccount *)signalAccount
{
OWSAssert(signalAccount);
OWSAssertDebug(signalAccount);
__weak UpdateGroupViewController *weakSelf = self;
[BlockListUIUtils showUnblockSignalAccountActionSheet:signalAccount
@ -339,7 +339,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)showUnblockAlertForRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
__weak UpdateGroupViewController *weakSelf = self;
[BlockListUIUtils showUnblockPhoneNumberActionSheet:recipientId
@ -355,7 +355,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)removeRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
[self.memberRecipientIds removeObject:recipientId];
[self updateTableContents];
@ -365,7 +365,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)updateGroup
{
OWSAssert(self.conversationSettingsViewDelegate);
OWSAssertDebug(self.conversationSettingsViewDelegate);
NSString *groupName = [self.groupNameTextField.text ows_stripped];
TSGroupModel *groupModel = [[TSGroupModel alloc] initWithTitle:groupName
@ -424,7 +424,7 @@ NS_ASSUME_NONNULL_BEGIN
@"The label for the 'save' button in action sheets.")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
OWSAssert(self.conversationSettingsViewDelegate);
OWSAssertDebug(self.conversationSettingsViewDelegate);
[self updateGroup];
@ -441,7 +441,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)updateGroupPressed
{
OWSAssert(self.conversationSettingsViewDelegate);
OWSAssertDebug(self.conversationSettingsViewDelegate);
[self updateGroup];
@ -491,7 +491,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)avatarDidChange:(UIImage *)image
{
OWSAssertIsOnMainThread();
OWSAssert(image);
OWSAssertDebug(image);
self.groupAvatar = image;
}
@ -517,7 +517,7 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)isRecipientGroupMember:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
return [self.memberRecipientIds containsObject:recipientId];
}

View File

@ -90,7 +90,7 @@
- (void)presentMissedCall:(SignalCall *)call callerName:(NSString *)callerName
{
TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:call.remotePhoneNumber];
OWSAssert(thread != nil);
OWSAssertDebug(thread != nil);
UILocalNotification *notification = [UILocalNotification new];
notification.category = PushManagerCategoriesMissedCall;
@ -128,7 +128,7 @@
- (void)presentMissedCallBecauseOfNewIdentity:(SignalCall *)call callerName:(NSString *)callerName
{
TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:call.remotePhoneNumber];
OWSAssert(thread != nil);
OWSAssertDebug(thread != nil);
UILocalNotification *notification = [UILocalNotification new];
// Use category which allows call back
@ -165,7 +165,7 @@
- (void)presentMissedCallBecauseOfNoLongerVerifiedIdentity:(SignalCall *)call callerName:(NSString *)callerName
{
TSContactThread *thread = [TSContactThread getOrCreateThreadWithContactId:call.remotePhoneNumber];
OWSAssert(thread != nil);
OWSAssertDebug(thread != nil);
UILocalNotification *notification = [UILocalNotification new];
// Use category which does not allow call back
@ -205,7 +205,7 @@
thread:(TSThread *)thread
transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(message);
OWSAssertDebug(message);
if (!thread) {
OWSFailDebug(@"unexpected notification not associated with a thread: %@.", [message class]);
@ -261,7 +261,7 @@
- (void)notifyUserForThreadlessErrorMessage:(TSErrorMessage *)message
transaction:(YapDatabaseReadWriteTransaction *)transaction;
{
OWSAssert(message);
OWSAssertDebug(message);
NSString *messageText = [message previewTextWithTransaction:transaction];
@ -297,9 +297,9 @@
contactsManager:(id<ContactsManagerProtocol>)contactsManager
transaction:(YapDatabaseReadTransaction *)transaction
{
OWSAssert(message);
OWSAssert(thread);
OWSAssert(contactsManager);
OWSAssertDebug(message);
OWSAssertDebug(thread);
OWSAssertDebug(contactsManager);
// While batch processing, some of the necessary changes have not been commited.
NSString *rawMessageText = [message previewTextWithTransaction:transaction];

View File

@ -75,9 +75,9 @@ NS_ASSUME_NONNULL_BEGIN
@synchronized(self)
{
if (!_callService) {
OWSAssert(self.accountManager);
OWSAssert(Environment.current.contactsManager);
OWSAssert(Environment.current.messageSender);
OWSAssertDebug(self.accountManager);
OWSAssertDebug(Environment.current.contactsManager);
OWSAssertDebug(Environment.current.messageSender);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didChangeCallLoggingPreference:) name:OWSPreferencesCallLoggingDidChangeNotification object:nil];
_callService = [[CallService alloc] initWithAccountManager:self.accountManager
@ -100,8 +100,8 @@ NS_ASSUME_NONNULL_BEGIN
@synchronized(self)
{
if (!_outboundCallInitiator) {
OWSAssert(Environment.current.contactsManager);
OWSAssert(Environment.current.contactsUpdater);
OWSAssertDebug(Environment.current.contactsManager);
OWSAssertDebug(Environment.current.contactsUpdater);
_outboundCallInitiator =
[[OutboundCallInitiator alloc] initWithContactsManager:Environment.current.contactsManager
contactsUpdater:Environment.current.contactsUpdater];
@ -171,7 +171,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)presentConversationForThreadId:(NSString *)threadId animated:(BOOL)isAnimated
{
OWSAssert(threadId.length > 0);
OWSAssertDebug(threadId.length > 0);
TSThread *thread = [TSThread fetchObjectWithUniqueID:threadId];
if (thread == nil) {

View File

@ -235,7 +235,7 @@ static NSString *const DATE_FORMAT_WEEKDAY = @"EEEE";
+ (NSString *)formatPastTimestampRelativeToNow:(uint64_t)pastTimestamp
{
OWSCAssert(pastTimestamp > 0);
OWSCAssertDebug(pastTimestamp > 0);
uint64_t nowTimestamp = [NSDate ows_millisecondTimeStamp];
BOOL isFutureTimestamp = pastTimestamp >= nowTimestamp;
@ -260,7 +260,7 @@ static NSString *const DATE_FORMAT_WEEKDAY = @"EEEE";
+ (NSString *)formatDateShort:(NSDate *)date
{
OWSAssertIsOnMainThread();
OWSAssert(date);
OWSAssertDebug(date);
NSDate *now = [NSDate date];
NSInteger dayDifference = [self daysFromFirstDate:date toSecondDate:now];
@ -283,7 +283,7 @@ static NSString *const DATE_FORMAT_WEEKDAY = @"EEEE";
+ (NSString *)formatDateForConversationDateBreaks:(NSDate *)date
{
OWSAssert(date);
OWSAssertDebug(date);
if (![self dateIsThisYear:date]) {
// last year formatter: Nov 11, 2017
@ -307,7 +307,7 @@ static NSString *const DATE_FORMAT_WEEKDAY = @"EEEE";
+ (NSString *)formatDateAsTime:(NSDate *)date
{
OWSAssert(date);
OWSAssertDebug(date);
NSString *dateTimeString = [[DateUtil timeFormatter] stringFromDate:date];
return dateTimeString.localizedUppercaseString;

View File

@ -6,7 +6,7 @@
@implementation NSArray (FunctionalUtil)
- (bool)any:(int (^)(id item))predicate {
OWSAssert(predicate != nil);
OWSAssertDebug(predicate != nil);
for (id e in self) {
if (predicate(e)) {
return true;
@ -15,7 +15,7 @@
return false;
}
- (bool)all:(int (^)(id item))predicate {
OWSAssert(predicate != nil);
OWSAssertDebug(predicate != nil);
for (id e in self) {
if (!predicate(e)) {
return false;
@ -24,7 +24,7 @@
return true;
}
- (id)firstMatchingElseNil:(int (^)(id item))predicate {
OWSAssert(predicate != nil);
OWSAssertDebug(predicate != nil);
for (id e in self) {
if (predicate(e)) {
return e;
@ -33,7 +33,7 @@
return nil;
}
- (NSArray *)map:(id (^)(id item))projection {
OWSAssert(projection != nil);
OWSAssertDebug(projection != nil);
NSMutableArray *r = [NSMutableArray arrayWithCapacity:self.count];
for (id e in self) {
@ -42,7 +42,7 @@
return r;
}
- (NSArray *)filter:(int (^)(id item))predicate {
OWSAssert(predicate != nil);
OWSAssertDebug(predicate != nil);
NSMutableArray *r = [NSMutableArray array];
for (id e in self) {
@ -74,19 +74,19 @@
return s;
}
- (NSDictionary *)keyedBy:(id (^)(id value))keySelector {
OWSAssert(keySelector != nil);
OWSAssertDebug(keySelector != nil);
NSMutableDictionary *result = [NSMutableDictionary dictionary];
for (id value in self) {
result[keySelector(value)] = value;
}
OWSAssert(result.count == self.count);
OWSAssertDebug(result.count == self.count);
return result;
}
- (NSDictionary *)groupBy:(id (^)(id value))keySelector {
OWSAssert(keySelector != nil);
OWSAssertDebug(keySelector != nil);
NSMutableDictionary *result = [NSMutableDictionary dictionary];

View File

@ -222,7 +222,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)doMultiDeviceUpdateWithProfileKey:(OWSAES256Key *)profileKey
{
OWSAssert(profileKey);
OWSAssertDebug(profileKey);
[MultiDeviceProfileKeyUpdateJob runWithProfileKey:profileKey
identityManager:OWSIdentityManager.sharedManager
@ -244,7 +244,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)runNowOrWhenMainAppIsActive:(AppActiveBlock)block
{
OWSAssert(block);
OWSAssertDebug(block);
DispatchMainThreadSafe(^{
if (self.isMainAppAndActive) {
@ -254,7 +254,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSBackgroundTask *_Nullable backgroundTask =
[OWSBackgroundTask backgroundTaskWithLabelStr:__PRETTY_FUNCTION__];
block();
OWSAssert(backgroundTask);
OWSAssertDebug(backgroundTask);
backgroundTask = nil;
return;
}
@ -266,7 +266,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)runAppActiveBlocks
{
OWSAssertIsOnMainThread();
OWSAssert(self.isMainAppAndActive);
OWSAssertDebug(self.isMainAppAndActive);
// App active blocks typically will be used to safely access the
// shared data container, so use a background task to protect this
@ -279,7 +279,7 @@ NS_ASSUME_NONNULL_BEGIN
block();
}
OWSAssert(backgroundTask);
OWSAssertDebug(backgroundTask);
backgroundTask = nil;
}

View File

@ -69,7 +69,7 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
OWSAssert(primaryStorage);
OWSAssertDebug(primaryStorage);
_dbConnection = primaryStorage.newDatabaseConnection;
@ -112,7 +112,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)tryToExportBackup
{
OWSAssertIsOnMainThread();
OWSAssert(!self.backupExportJob);
OWSAssertDebug(!self.backupExportJob);
if (!self.canBackupExport) {
// TODO: Offer a reason in the UI.
@ -144,7 +144,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setLastExportSuccessDate:(NSDate *)value
{
OWSAssert(value);
OWSAssertDebug(value);
[self.dbConnection setDate:value
forKey:OWSBackup_LastExportSuccessDateKey
@ -159,7 +159,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setLastExportFailureDate:(NSDate *)value
{
OWSAssert(value);
OWSAssertDebug(value);
[self.dbConnection setDate:value
forKey:OWSBackup_LastExportFailureDateKey
@ -312,7 +312,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)tryToImportBackup
{
OWSAssertIsOnMainThread();
OWSAssert(!self.backupImportJob);
OWSAssertDebug(!self.backupImportJob);
// In development, make sure there's no export or import in progress.
[self.backupExportJob cancel];
@ -540,9 +540,9 @@ NS_ASSUME_NONNULL_BEGIN
backupIO:(OWSBackupIO *)backupIO
completion:(OWSBackupBoolBlock)completion
{
OWSAssert(attachment);
OWSAssert(backupIO);
OWSAssert(completion);
OWSAssertDebug(attachment);
OWSAssertDebug(backupIO);
OWSAssertDebug(completion);
NSString *_Nullable attachmentFilePath = [attachment filePath];
if (attachmentFilePath.length < 1) {
@ -594,11 +594,11 @@ NS_ASSUME_NONNULL_BEGIN
encryptionKey:(NSData *)encryptionKey
completion:(OWSBackupBoolBlock)completion
{
OWSAssert(attachment);
OWSAssert(backupIO);
OWSAssert(encryptedFilePath.length > 0);
OWSAssert(encryptionKey.length > 0);
OWSAssert(completion);
OWSAssertDebug(attachment);
OWSAssertDebug(backupIO);
OWSAssertDebug(encryptedFilePath.length > 0);
OWSAssertDebug(encryptionKey.length > 0);
OWSAssertDebug(completion);
NSData *_Nullable data = [NSData dataWithContentsOfFile:encryptedFilePath];
if (!data) {

View File

@ -49,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
OWSAssert(encryptedItem);
OWSAssertDebug(encryptedItem);
self.encryptedItem = encryptedItem;
@ -99,7 +99,7 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
OWSAssert(backupIO);
OWSAssertDebug(backupIO);
self.exportItems = [NSMutableArray new];
self.backupIO = backupIO;
@ -113,7 +113,7 @@ NS_ASSUME_NONNULL_BEGIN
// this work, help with debugging issue, etc.
- (BOOL)writeObject:(TSYapDatabaseObject *)object entityType:(SignalIOSProtoBackupSnapshotBackupEntityType)entityType
{
OWSAssert(object);
OWSAssertDebug(object);
NSData *_Nullable data = [NSKeyedArchiver archivedDataWithRootObject:object];
if (!data) {
@ -227,9 +227,9 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
OWSAssert(backupIO);
OWSAssert(attachmentId.length > 0);
OWSAssert(attachmentFilePath.length > 0);
OWSAssertDebug(backupIO);
OWSAssertDebug(attachmentId.length > 0);
OWSAssertDebug(attachmentFilePath.length > 0);
self.backupIO = backupIO;
self.attachmentId = attachmentId;
@ -251,8 +251,8 @@ NS_ASSUME_NONNULL_BEGIN
// Returns YES on success.
- (BOOL)prepareForUpload
{
OWSAssert(self.attachmentId.length > 0);
OWSAssert(self.attachmentFilePath.length > 0);
OWSAssertDebug(self.attachmentId.length > 0);
OWSAssertDebug(self.attachmentFilePath.length > 0);
NSString *attachmentsDirPath = [TSAttachmentStream attachmentsFolder];
if (![self.attachmentFilePath hasPrefix:attachmentsDirPath]) {
@ -394,7 +394,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)configureExportWithCompletion:(OWSBackupJobBoolCompletion)completion
{
OWSAssert(completion);
OWSAssertDebug(completion);
OWSLogVerbose(@"");
@ -430,7 +430,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)fetchAllRecordsWithCompletion:(OWSBackupJobBoolCompletion)completion
{
OWSAssert(completion);
OWSAssertDebug(completion);
if (self.isComplete) {
return;
@ -461,7 +461,7 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)exportDatabase
{
OWSAssert(self.backupIO);
OWSAssertDebug(self.backupIO);
OWSLogVerbose(@"");
@ -543,7 +543,7 @@ NS_ASSUME_NONNULL_BEGIN
if (!filePath) {
OWSLogError(@"attachment is missing file.");
return NO;
OWSAssert(attachmentStream.uniqueId.length > 0);
OWSAssertDebug(attachmentStream.uniqueId.length > 0);
}
// OWSAttachmentExport is used to lazily write an encrypted copy of the
@ -618,7 +618,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)saveToCloudWithCompletion:(OWSBackupJobCompletion)completion
{
OWSAssert(completion);
OWSAssertDebug(completion);
OWSLogVerbose(@"");
@ -662,7 +662,7 @@ NS_ASSUME_NONNULL_BEGIN
// until the last (the manifest file).
- (void)saveNextFileToCloudWithCompletion:(OWSBackupJobCompletion)completion
{
OWSAssert(completion);
OWSAssertDebug(completion);
if (self.isComplete) {
return;
@ -689,7 +689,7 @@ NS_ASSUME_NONNULL_BEGIN
// This method returns YES IFF "work was done and there might be more work to do".
- (BOOL)saveNextDatabaseFileToCloudWithCompletion:(OWSBackupJobCompletion)completion
{
OWSAssert(completion);
OWSAssertDebug(completion);
__weak OWSBackupExportJob *weakSelf = self;
if (self.unsavedDatabaseItems.count < 1) {
@ -700,7 +700,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSBackupExportItem *item = self.unsavedDatabaseItems.firstObject;
[self.unsavedDatabaseItems removeObjectAtIndex:0];
OWSAssert(item.encryptedItem.filePath.length > 0);
OWSAssertDebug(item.encryptedItem.filePath.length > 0);
[OWSBackupAPI saveEphemeralDatabaseFileToCloudWithFileUrl:[NSURL fileURLWithPath:item.encryptedItem.filePath]
success:^(NSString *recordName) {
@ -725,7 +725,7 @@ NS_ASSUME_NONNULL_BEGIN
// This method returns YES IFF "work was done and there might be more work to do".
- (BOOL)saveNextAttachmentFileToCloudWithCompletion:(OWSBackupJobCompletion)completion
{
OWSAssert(completion);
OWSAssertDebug(completion);
__weak OWSBackupExportJob *weakSelf = self;
if (self.unsavedAttachmentExports.count < 1) {
@ -751,8 +751,8 @@ NS_ASSUME_NONNULL_BEGIN
NSString *lastRecordName = [OWSBackupAPI recordNameForPersistentFileWithFileId:attachmentExport.attachmentId];
OWSBackupFragment *_Nullable lastBackupFragment = [OWSBackupFragment fetchObjectWithUniqueID:lastRecordName];
if (lastBackupFragment && [self.lastValidRecordNames containsObject:lastRecordName]) {
OWSAssert(lastBackupFragment.encryptionKey.length > 0);
OWSAssert(lastBackupFragment.relativeFilePath.length > 0);
OWSAssertDebug(lastBackupFragment.encryptionKey.length > 0);
OWSAssertDebug(lastBackupFragment.relativeFilePath.length > 0);
// Recycle the metadata from the last backup's manifest.
OWSBackupEncryptedItem *encryptedItem = [OWSBackupEncryptedItem new];
@ -782,8 +782,8 @@ NS_ASSUME_NONNULL_BEGIN
[weakSelf saveNextFileToCloudWithCompletion:completion];
return YES;
}
OWSAssert(attachmentExport.relativeFilePath.length > 0);
OWSAssert(attachmentExport.encryptedItem);
OWSAssertDebug(attachmentExport.relativeFilePath.length > 0);
OWSAssertDebug(attachmentExport.encryptedItem);
}
[OWSBackupAPI savePersistentFileOnceToCloudWithFileId:attachmentExport.attachmentId
@ -850,7 +850,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)saveManifestFileToCloudWithCompletion:(OWSBackupJobCompletion)completion
{
OWSAssert(completion);
OWSAssertDebug(completion);
OWSBackupEncryptedItem *_Nullable encryptedItem = [self writeManifestFile];
if (!encryptedItem) {
@ -892,10 +892,10 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable OWSBackupEncryptedItem *)writeManifestFile
{
OWSAssert(self.savedDatabaseItems.count > 0);
OWSAssert(self.savedAttachmentItems);
OWSAssert(self.jobTempDirPath.length > 0);
OWSAssert(self.backupIO);
OWSAssertDebug(self.savedDatabaseItems.count > 0);
OWSAssertDebug(self.savedAttachmentItems);
OWSAssertDebug(self.jobTempDirPath.length > 0);
OWSAssertDebug(self.backupIO);
NSDictionary *json = @{
kOWSBackup_ManifestKey_DatabaseFiles : [self jsonForItems:self.savedDatabaseItems],
@ -919,17 +919,17 @@ NS_ASSUME_NONNULL_BEGIN
NSMutableArray *result = [NSMutableArray new];
for (OWSBackupExportItem *item in items) {
NSMutableDictionary<NSString *, id> *itemJson = [NSMutableDictionary new];
OWSAssert(item.recordName.length > 0);
OWSAssertDebug(item.recordName.length > 0);
itemJson[kOWSBackup_ManifestKey_RecordName] = item.recordName;
OWSAssert(item.encryptedItem.encryptionKey.length > 0);
OWSAssertDebug(item.encryptedItem.encryptionKey.length > 0);
itemJson[kOWSBackup_ManifestKey_EncryptionKey] = item.encryptedItem.encryptionKey.base64EncodedString;
if (item.attachmentExport) {
OWSAssert(item.attachmentExport.relativeFilePath.length > 0);
OWSAssertDebug(item.attachmentExport.relativeFilePath.length > 0);
itemJson[kOWSBackup_ManifestKey_RelativeFilePath] = item.attachmentExport.relativeFilePath;
}
if (item.attachmentExport.attachmentId) {
OWSAssert(item.attachmentExport.attachmentId.length > 0);
OWSAssertDebug(item.attachmentExport.attachmentId.length > 0);
itemJson[kOWSBackup_ManifestKey_AttachmentId] = item.attachmentExport.attachmentId;
}
if (item.uncompressedDataLength) {
@ -943,7 +943,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)cleanUpWithCompletion:(OWSBackupJobCompletion)completion
{
OWSAssert(completion);
OWSAssertDebug(completion);
if (self.isComplete) {
// Job was aborted.
@ -961,19 +961,19 @@ NS_ASSUME_NONNULL_BEGIN
// records not involved in this backup export.
NSMutableSet<NSString *> *activeRecordNames = [NSMutableSet new];
OWSAssert(self.savedDatabaseItems.count > 0);
OWSAssertDebug(self.savedDatabaseItems.count > 0);
for (OWSBackupExportItem *item in self.savedDatabaseItems) {
OWSAssert(item.recordName.length > 0);
OWSAssert(![activeRecordNames containsObject:item.recordName]);
OWSAssertDebug(item.recordName.length > 0);
OWSAssertDebug(![activeRecordNames containsObject:item.recordName]);
[activeRecordNames addObject:item.recordName];
}
for (OWSBackupExportItem *item in self.savedAttachmentItems) {
OWSAssert(item.recordName.length > 0);
OWSAssert(![activeRecordNames containsObject:item.recordName]);
OWSAssertDebug(item.recordName.length > 0);
OWSAssertDebug(![activeRecordNames containsObject:item.recordName]);
[activeRecordNames addObject:item.recordName];
}
OWSAssert(self.manifestItem.recordName.length > 0);
OWSAssert(![activeRecordNames containsObject:self.manifestItem.recordName]);
OWSAssertDebug(self.manifestItem.recordName.length > 0);
OWSAssertDebug(![activeRecordNames containsObject:self.manifestItem.recordName]);
[activeRecordNames addObject:self.manifestItem.recordName];
// Because we do "lazy attachment restores", we need to include the record names for all
@ -988,7 +988,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)cleanUpMetadataCacheWithActiveRecordNames:(NSSet<NSString *> *)activeRecordNames
{
OWSAssert(activeRecordNames.count > 0);
OWSAssertDebug(activeRecordNames.count > 0);
if (self.isComplete) {
// Job was aborted.
@ -1010,8 +1010,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)cleanUpCloudWithActiveRecordNames:(NSSet<NSString *> *)activeRecordNames
completion:(OWSBackupJobCompletion)completion
{
OWSAssert(activeRecordNames.count > 0);
OWSAssert(completion);
OWSAssertDebug(activeRecordNames.count > 0);
OWSAssertDebug(completion);
if (self.isComplete) {
// Job was aborted.
@ -1049,8 +1049,8 @@ NS_ASSUME_NONNULL_BEGIN
deletedCount:(NSUInteger)deletedCount
completion:(OWSBackupJobCompletion)completion
{
OWSAssert(obsoleteRecordNames);
OWSAssert(completion);
OWSAssertDebug(obsoleteRecordNames);
OWSAssertDebug(completion);
OWSLogVerbose(@"");

View File

@ -63,7 +63,7 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA
- (nullable OWSBackupEncryptedItem *)encryptFileAsTempFile:(NSString *)srcFilePath
{
OWSAssert(srcFilePath.length > 0);
OWSAssertDebug(srcFilePath.length > 0);
NSData *encryptionKey = [Randomness generateRandomBytes:(int)kOWSBackupKeyLength];
@ -72,8 +72,8 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA
- (nullable OWSBackupEncryptedItem *)encryptFileAsTempFile:(NSString *)srcFilePath encryptionKey:(NSData *)encryptionKey
{
OWSAssert(srcFilePath.length > 0);
OWSAssert(encryptionKey.length > 0);
OWSAssertDebug(srcFilePath.length > 0);
OWSAssertDebug(encryptionKey.length > 0);
@autoreleasepool {
@ -89,7 +89,7 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA
- (nullable OWSBackupEncryptedItem *)encryptDataAsTempFile:(NSData *)srcData
{
OWSAssert(srcData);
OWSAssertDebug(srcData);
NSData *encryptionKey = [Randomness generateRandomBytes:(int)kOWSBackupKeyLength];
@ -99,8 +99,8 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA
- (nullable OWSBackupEncryptedItem *)encryptDataAsTempFile:(NSData *)unencryptedData
encryptionKey:(NSData *)encryptionKey
{
OWSAssert(unencryptedData);
OWSAssert(encryptionKey.length > 0);
OWSAssertDebug(unencryptedData);
OWSAssertDebug(encryptionKey.length > 0);
@autoreleasepool {
@ -131,8 +131,8 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA
dstFilePath:(NSString *)dstFilePath
encryptionKey:(NSData *)encryptionKey
{
OWSAssert(srcFilePath.length > 0);
OWSAssert(encryptionKey.length > 0);
OWSAssertDebug(srcFilePath.length > 0);
OWSAssertDebug(encryptionKey.length > 0);
@autoreleasepool {
@ -157,8 +157,8 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA
- (nullable NSData *)decryptFileAsData:(NSString *)srcFilePath encryptionKey:(NSData *)encryptionKey
{
OWSAssert(srcFilePath.length > 0);
OWSAssert(encryptionKey.length > 0);
OWSAssertDebug(srcFilePath.length > 0);
OWSAssertDebug(encryptionKey.length > 0);
@autoreleasepool {
@ -180,8 +180,8 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA
- (nullable NSData *)decryptDataAsData:(NSData *)encryptedData encryptionKey:(NSData *)encryptionKey
{
OWSAssert(encryptedData);
OWSAssert(encryptionKey.length > 0);
OWSAssertDebug(encryptedData);
OWSAssertDebug(encryptionKey.length > 0);
@autoreleasepool {
@ -196,7 +196,7 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA
- (nullable NSData *)compressData:(NSData *)srcData
{
OWSAssert(srcData);
OWSAssertDebug(srcData);
@autoreleasepool {
@ -232,7 +232,7 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA
- (nullable NSData *)decompressData:(NSData *)srcData uncompressedDataLength:(NSUInteger)uncompressedDataLength
{
OWSAssert(srcData);
OWSAssertDebug(srcData);
@autoreleasepool {
@ -254,7 +254,7 @@ static const compression_algorithm SignalCompressionAlgorithm = COMPRESSION_LZMA
size_t dstLength = compression_decode_buffer(
dstBufferData.mutableBytes, dstBufferLength, srcData.bytes, srcLength, NULL, SignalCompressionAlgorithm);
NSData *decompressedData = [dstBufferData subdataWithRange:NSMakeRange(0, dstLength)];
OWSAssert(decompressedData.length == uncompressedDataLength);
OWSAssertDebug(decompressedData.length == uncompressedDataLength);
OWSLogVerbose(@"decompressed %zd -> %zd = %0.2f",
srcLength,
dstLength,

View File

@ -88,8 +88,8 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
if (self.isComplete) {
return;
}
OWSCAssert(manifest.databaseItems.count > 0);
OWSCAssert(manifest.attachmentsItems);
OWSCAssertDebug(manifest.databaseItems.count > 0);
OWSCAssertDebug(manifest.attachmentsItems);
strongSelf.databaseItems = manifest.databaseItems;
strongSelf.attachmentsItems = manifest.attachmentsItems;
[strongSelf downloadAndProcessImport];
@ -102,8 +102,8 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
- (void)downloadAndProcessImport
{
OWSAssert(self.databaseItems);
OWSAssert(self.attachmentsItems);
OWSAssertDebug(self.databaseItems);
OWSAssertDebug(self.attachmentsItems);
NSMutableArray<OWSBackupFragment *> *allItems = [NSMutableArray new];
[allItems addObjectsFromArray:self.databaseItems];
@ -187,8 +187,8 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
- (void)downloadFilesFromCloud:(NSMutableArray<OWSBackupFragment *> *)items
completion:(OWSBackupJobCompletion)completion
{
OWSAssert(items.count > 0);
OWSAssert(completion);
OWSAssertDebug(items.count > 0);
OWSAssertDebug(completion);
OWSLogVerbose(@"");
@ -199,8 +199,8 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
recordCount:(NSUInteger)recordCount
completion:(OWSBackupJobCompletion)completion
{
OWSAssert(items);
OWSAssert(completion);
OWSAssertDebug(items);
OWSAssertDebug(completion);
if (self.isComplete) {
// Job was aborted.
@ -300,7 +300,7 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
- (void)restoreDatabaseWithCompletion:(OWSBackupJobBoolCompletion)completion
{
OWSAssert(completion);
OWSAssertDebug(completion);
OWSLogVerbose(@"");
@ -458,7 +458,7 @@ NSString *const kOWSBackup_ImportDatabaseKeySpec = @"kOWSBackup_ImportDatabaseKe
- (void)ensureMigrationsWithCompletion:(OWSBackupJobBoolCompletion)completion
{
OWSAssert(completion);
OWSAssertDebug(completion);
OWSLogVerbose(@"");

View File

@ -52,8 +52,8 @@ NSString *const kOWSBackup_KeychainService = @"kOWSBackup_KeychainService";
return self;
}
OWSAssert(primaryStorage);
OWSAssert([OWSStorage isStorageReady]);
OWSAssertDebug(primaryStorage);
OWSAssertDebug([OWSStorage isStorageReady]);
self.delegate = delegate;
self.primaryStorage = primaryStorage;
@ -105,14 +105,14 @@ NSString *const kOWSBackup_KeychainService = @"kOWSBackup_KeychainService";
dispatch_async(dispatch_get_main_queue(), ^{
if (self.isComplete) {
OWSAssert(!self.hasSucceeded);
OWSAssertDebug(!self.hasSucceeded);
return;
}
self.isComplete = YES;
// There's a lot of asynchrony in these backup jobs;
// ensure we only end up finishing these jobs once.
OWSAssert(!self.hasSucceeded);
OWSAssertDebug(!self.hasSucceeded);
self.hasSucceeded = YES;
[self.delegate backupJobDidSucceed:self];
@ -129,7 +129,7 @@ NSString *const kOWSBackup_KeychainService = @"kOWSBackup_KeychainService";
OWSFailDebug(@"%@", error);
dispatch_async(dispatch_get_main_queue(), ^{
OWSAssert(!self.hasSucceeded);
OWSAssertDebug(!self.hasSucceeded);
if (self.isComplete) {
return;
}
@ -156,9 +156,9 @@ NSString *const kOWSBackup_KeychainService = @"kOWSBackup_KeychainService";
failure:(OWSBackupJobManifestFailure)failure
backupIO:(OWSBackupIO *)backupIO
{
OWSAssert(success);
OWSAssert(failure);
OWSAssert(backupIO);
OWSAssertDebug(success);
OWSAssertDebug(failure);
OWSAssertDebug(backupIO);
OWSLogVerbose(@"");
@ -189,10 +189,10 @@ NSString *const kOWSBackup_KeychainService = @"kOWSBackup_KeychainService";
failure:(dispatch_block_t)failure
backupIO:(OWSBackupIO *)backupIO
{
OWSAssert(manifestDataEncrypted.length > 0);
OWSAssert(success);
OWSAssert(failure);
OWSAssert(backupIO);
OWSAssertDebug(manifestDataEncrypted.length > 0);
OWSAssertDebug(success);
OWSAssertDebug(failure);
OWSAssertDebug(backupIO);
if (self.isComplete) {
return;
@ -237,8 +237,8 @@ NSString *const kOWSBackup_KeychainService = @"kOWSBackup_KeychainService";
- (nullable NSArray<OWSBackupFragment *> *)parseItems:(id)json key:(NSString *)key
{
OWSAssert(json);
OWSAssert(key.length);
OWSAssertDebug(json);
OWSAssertDebug(key.length);
if (![json isKindOfClass:[NSDictionary class]]) {
OWSFailDebug(@"manifest has invalid data.");

View File

@ -141,7 +141,7 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *);
success:(OrphanDataBlock)success
failure:(dispatch_block_t)failure
{
OWSAssert(databaseConnection);
OWSAssertDebug(databaseConnection);
if (remainingRetries < 1) {
OWSLogInfo(@"Aborting orphan data search.");
@ -173,7 +173,7 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *);
// abort if the app resigns active, in order to avoid 0xdead10cc crashes.
+ (nullable OWSOrphanData *)findOrphanDataSync:(YapDatabaseConnection *)databaseConnection
{
OWSAssert(databaseConnection);
OWSAssertDebug(databaseConnection);
__block BOOL shouldAbort = NO;
@ -469,7 +469,7 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *);
+ (void)auditAndCleanup:(BOOL)shouldRemoveOrphans databaseConnection:(YapDatabaseConnection *)databaseConnection
{
OWSAssertIsOnMainThread();
OWSAssert(databaseConnection);
OWSAssertDebug(databaseConnection);
if (!AppReadiness.isAppReady) {
OWSFailDebug(@"can't audit orphan data until app is ready.");
@ -543,8 +543,8 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *);
success:(dispatch_block_t)success
failure:(dispatch_block_t)failure
{
OWSAssert(databaseConnection);
OWSAssert(orphanData);
OWSAssertDebug(databaseConnection);
OWSAssertDebug(orphanData);
if (remainingRetries < 1) {
OWSLogInfo(@"Aborting orphan data audit.");
@ -582,8 +582,8 @@ typedef void (^OrphanDataBlock)(OWSOrphanData *);
databaseConnection:(YapDatabaseConnection *)databaseConnection
shouldRemoveOrphans:(BOOL)shouldRemoveOrphans
{
OWSAssert(databaseConnection);
OWSAssert(orphanData);
OWSAssertDebug(databaseConnection);
OWSAssertDebug(orphanData);
__block BOOL shouldAbort = NO;

View File

@ -118,10 +118,10 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setupWithRootWindow:(UIWindow *)rootWindow
{
OWSAssertIsOnMainThread();
OWSAssert(rootWindow);
OWSAssertDebug(rootWindow);
[self createScreenBlockingWindowWithRootWindow:rootWindow];
OWSAssert(self.screenBlockingWindow);
OWSAssertDebug(self.screenBlockingWindow);
}
- (void)startObserving
@ -149,7 +149,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)tryToActivateScreenLockBasedOnCountdown
{
OWSAssert(!self.appIsInBackground);
OWSAssertDebug(!self.appIsInBackground);
OWSAssertIsOnMainThread();
if (!AppReadiness.isAppReady) {
@ -177,9 +177,9 @@ NS_ASSUME_NONNULL_BEGIN
return;
}
NSTimeInterval countdownInterval = fabs([self.screenLockCountdownDate timeIntervalSinceNow]);
OWSAssert(countdownInterval >= 0);
OWSAssertDebug(countdownInterval >= 0);
NSTimeInterval screenLockTimeout = OWSScreenLock.sharedManager.screenLockTimeout;
OWSAssert(screenLockTimeout >= 0);
OWSAssertDebug(screenLockTimeout >= 0);
if (countdownInterval >= screenLockTimeout) {
self.isScreenLockLocked = YES;
@ -379,7 +379,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)createScreenBlockingWindowWithRootWindow:(UIWindow *)rootWindow
{
OWSAssertIsOnMainThread();
OWSAssert(rootWindow);
OWSAssertDebug(rootWindow);
UIWindow *window = [[UIWindow alloc] initWithFrame:rootWindow.bounds];
window.hidden = NO;

View File

@ -53,10 +53,10 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
success:(DebugLogUploadSuccess)success
failure:(DebugLogUploadFailure)failure
{
OWSAssert(fileUrl);
OWSAssert(mimeType.length > 0);
OWSAssert(success);
OWSAssert(failure);
OWSAssertDebug(fileUrl);
OWSAssertDebug(mimeType.length > 0);
OWSAssertDebug(success);
OWSAssertDebug(failure);
self.fileUrl = fileUrl;
self.mimeType = mimeType;
@ -145,9 +145,9 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
- (void)uploadFileWithUploadUrl:(NSString *)uploadUrl fields:(NSDictionary *)fields uploadKey:(NSString *)uploadKey
{
OWSAssert(uploadUrl.length > 0);
OWSAssert(fields);
OWSAssert(uploadKey.length > 0);
OWSAssertDebug(uploadUrl.length > 0);
OWSAssertDebug(fields);
OWSAssertDebug(uploadKey.length > 0);
__weak DebugLogUploader *weakSelf = self;
NSURLSessionConfiguration *sessionConf = NSURLSessionConfiguration.ephemeralSessionConfiguration;
@ -213,7 +213,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
- (void)failWithError:(NSError *)error
{
OWSAssert(error);
OWSAssertDebug(error);
OWSLogError(@"%@", error);
@ -229,7 +229,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
- (void)succeedWithUrl:(NSURL *)url
{
OWSAssert(url);
OWSAssertDebug(url);
OWSLogVerbose(@"%@", url);
@ -359,7 +359,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
+ (void)uploadLogsWithSuccess:(nullable UploadDebugLogsSuccess)success
{
OWSAssert(success);
OWSAssertDebug(success);
[[self sharedManager] uploadLogsWithSuccess:success
failure:^(NSString *localizedErrorMessage) {
@ -369,8 +369,8 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
- (void)uploadLogsWithSuccess:(nullable UploadDebugLogsSuccess)successParam failure:(UploadDebugLogsFailure)failureParam
{
OWSAssert(successParam);
OWSAssert(failureParam);
OWSAssertDebug(successParam);
OWSAssertDebug(failureParam);
// Ensure that we call the completions on the main thread.
UploadDebugLogsSuccess success = ^(NSURL *url) {
@ -489,7 +489,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
- (void)prepareRedirection:(NSURL *)url completion:(SubmitDebugLogsCompletion)completion
{
OWSAssert(completion);
OWSAssertDebug(completion);
UIPasteboard *pb = [UIPasteboard generalPasteboard];
[pb setString:url.absoluteString];

View File

@ -40,7 +40,7 @@
- (UIView *)rootViewInViewHierarchy:(UIView *)view
{
OWSAssert(view);
OWSAssertDebug(view);
UIResponder *responder = view;
UIView *lastView = nil;
while (responder) {

View File

@ -60,14 +60,14 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setConfigureShapeLayerBlock:(ConfigureShapeLayerBlock)configureShapeLayerBlock
{
OWSAssert(configureShapeLayerBlock);
OWSAssertDebug(configureShapeLayerBlock);
[self setConfigureShapeLayerBlocks:@[ configureShapeLayerBlock ]];
}
- (void)setConfigureShapeLayerBlocks:(NSArray<ConfigureShapeLayerBlock> *)configureShapeLayerBlocks
{
OWSAssert(configureShapeLayerBlocks.count > 0);
OWSAssertDebug(configureShapeLayerBlocks.count > 0);
_configureShapeLayerBlocks = configureShapeLayerBlocks;

View File

@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)configureWithDevice:(OWSDevice *)device
{
OWSAssert(device);
OWSAssertDebug(device);
[OWSTableItem configureCell:self];

View File

@ -56,19 +56,19 @@
- (ConversationViewItem *)viewItemWithAttachmentMimetype:(NSString *)mimeType filename:(NSString *)filename
{
OWSAssert(filename.length > 0);
OWSAssertDebug(filename.length > 0);
NSString *resourcePath = [[NSBundle bundleForClass:[self class]] resourcePath];
NSString *filePath = [resourcePath stringByAppendingPathComponent:filename];
OWSAssert([[NSFileManager defaultManager] fileExistsAtPath:filePath]);
OWSAssertDebug([[NSFileManager defaultManager] fileExistsAtPath:filePath]);
DataSource *dataSource = [DataSourcePath dataSourceWithFilePath:filePath shouldDeleteOnDeallocation:NO];
TSAttachmentStream *attachment = [[TSAttachmentStream alloc] initWithContentType:mimeType
byteCount:(UInt32)dataSource.dataLength
sourceFilename:nil];
BOOL success = [attachment writeDataSource:dataSource];
OWSAssert(success);
OWSAssertDebug(success);
[attachment save];
TSOutgoingMessage *message =
[TSOutgoingMessage outgoingMessageInThread:self.thread messageBody:nil attachmentId:attachment.uniqueId];

View File

@ -66,9 +66,9 @@ NS_ASSUME_NONNULL_BEGIN
databaseKeySpec:(NSData *_Nullable)databaseKeySpec
databaseBlock:(void (^_Nonnull)(YapDatabase *))databaseBlock
{
OWSAssert(databaseFilePath.length > 0);
OWSAssert(databasePassword.length > 0 || databaseKeySpec.length > 0);
OWSAssert(databaseBlock);
OWSAssertDebug(databaseFilePath.length > 0);
OWSAssertDebug(databasePassword.length > 0 || databaseKeySpec.length > 0);
OWSAssertDebug(databaseBlock);
OWSLogVerbose(@"openYapDatabase: %@", databaseFilePath);
[DDLog flushLog];
@ -102,17 +102,17 @@ NS_ASSUME_NONNULL_BEGIN
options.cipherUnencryptedHeaderLength = kSqliteHeaderLength;
}
OWSAssert(options.cipherDefaultkdfIterNumber == 0);
OWSAssert(options.kdfIterNumber == 0);
OWSAssert(options.cipherPageSize == 0);
OWSAssert(options.pragmaPageSize == 0);
OWSAssert(options.pragmaJournalSizeLimit == 0);
OWSAssertDebug(options.cipherDefaultkdfIterNumber == 0);
OWSAssertDebug(options.kdfIterNumber == 0);
OWSAssertDebug(options.cipherPageSize == 0);
OWSAssertDebug(options.pragmaPageSize == 0);
OWSAssertDebug(options.pragmaJournalSizeLimit == 0);
YapDatabase *database = [[YapDatabase alloc] initWithPath:databaseFilePath
serializer:nil
deserializer:[OWSStorage logOnFailureDeserializer]
options:options];
OWSAssert(database);
OWSAssertDebug(database);
weakDatabase = database;
snapshotQueue = database->snapshotQueue;
@ -163,7 +163,7 @@ NS_ASSUME_NONNULL_BEGIN
// Verify that the database is indeed closed.
YapDatabase *_Nullable strongDatabase = weakDatabase;
OWSAssert(!strongDatabase);
OWSAssertDebug(!strongDatabase);
}
- (void)createTestDatabase:(NSString *)databaseFilePath
@ -171,10 +171,10 @@ NS_ASSUME_NONNULL_BEGIN
databaseSalt:(NSData *_Nullable)databaseSalt
databaseKeySpec:(NSData *_Nullable)databaseKeySpec
{
OWSAssert(databaseFilePath.length > 0);
OWSAssert(databasePassword.length > 0 || databaseKeySpec.length > 0);
OWSAssertDebug(databaseFilePath.length > 0);
OWSAssertDebug(databasePassword.length > 0 || databaseKeySpec.length > 0);
OWSAssert(![[NSFileManager defaultManager] fileExistsAtPath:databaseFilePath]);
OWSAssertDebug(![[NSFileManager defaultManager] fileExistsAtPath:databaseFilePath]);
[self openYapDatabase:databaseFilePath
databasePassword:databasePassword
@ -189,12 +189,12 @@ NS_ASSUME_NONNULL_BEGIN
[dbConnection flushTransactionsWithCompletionQueue:dispatch_get_main_queue() completionBlock:nil];
}];
OWSAssert([[NSFileManager defaultManager] fileExistsAtPath:databaseFilePath]);
OWSAssertDebug([[NSFileManager defaultManager] fileExistsAtPath:databaseFilePath]);
NSError *_Nullable error = nil;
NSDictionary *fileAttributes =
[[NSFileManager defaultManager] attributesOfItemAtPath:databaseFilePath error:&error];
OWSAssert(fileAttributes && !error);
OWSAssertDebug(fileAttributes && !error);
OWSLogVerbose(@"test database file size: %@", fileAttributes[NSFileSize]);
}
@ -203,10 +203,10 @@ NS_ASSUME_NONNULL_BEGIN
databaseSalt:(NSData *_Nullable)databaseSalt
databaseKeySpec:(NSData *_Nullable)databaseKeySpec
{
OWSAssert(databaseFilePath.length > 0);
OWSAssert(databasePassword.length > 0 || databaseKeySpec.length > 0);
OWSAssertDebug(databaseFilePath.length > 0);
OWSAssertDebug(databasePassword.length > 0 || databaseKeySpec.length > 0);
OWSAssert([[NSFileManager defaultManager] fileExistsAtPath:databaseFilePath]);
OWSAssertDebug([[NSFileManager defaultManager] fileExistsAtPath:databaseFilePath]);
__block BOOL isValid = NO;
[self openYapDatabase:databaseFilePath
@ -219,7 +219,7 @@ NS_ASSUME_NONNULL_BEGIN
isValid = [@(YES) isEqual:value];
}];
OWSAssert([[NSFileManager defaultManager] fileExistsAtPath:databaseFilePath]);
OWSAssertDebug([[NSFileManager defaultManager] fileExistsAtPath:databaseFilePath]);
return isValid;
}
@ -245,7 +245,7 @@ NS_ASSUME_NONNULL_BEGIN
databaseSalt:(NSData *_Nullable)databaseSalt
databaseKeySpec:(NSData *_Nullable)databaseKeySpec
{
OWSAssert(databasePassword.length > 0 || databaseKeySpec.length > 0);
OWSAssertDebug(databasePassword.length > 0 || databaseKeySpec.length > 0);
NSString *databaseFilePath = [self createTempDatabaseFilePath];
@ -261,7 +261,7 @@ NS_ASSUME_NONNULL_BEGIN
databasePassword:databasePassword
databaseSalt:databaseSalt
databaseKeySpec:databaseKeySpec];
OWSAssert(isValid);
OWSAssertDebug(isValid);
return databaseFilePath;
}
@ -305,8 +305,8 @@ NS_ASSUME_NONNULL_BEGIN
__block NSData *_Nullable databaseSalt = nil;
__block NSData *_Nullable databaseKeySpec = nil;
YapRecordDatabaseSaltBlock recordSaltBlock = ^(NSData *saltData) {
OWSAssert(!databaseSalt);
OWSAssert(saltData);
OWSAssertDebug(!databaseSalt);
OWSAssertDebug(saltData);
databaseSalt = saltData;
databaseKeySpec = [YapDatabaseCryptoUtils deriveDatabaseKeySpecForPassword:databasePassword saltData:saltData];
@ -346,8 +346,8 @@ NS_ASSUME_NONNULL_BEGIN
__block NSData *_Nullable databaseKeySpec = nil;
YapRecordDatabaseSaltBlock recordSaltBlock = ^(NSData *saltData) {
OWSAssert(!databaseSalt);
OWSAssert(saltData);
OWSAssertDebug(!databaseSalt);
OWSAssertDebug(saltData);
databaseSalt = saltData;
databaseKeySpec = [YapDatabaseCryptoUtils deriveDatabaseKeySpecForPassword:databasePassword saltData:saltData];
@ -389,8 +389,8 @@ NS_ASSUME_NONNULL_BEGIN
__block NSData *_Nullable databaseKeySpec = nil;
YapRecordDatabaseSaltBlock recordSaltBlock = ^(NSData *saltData) {
OWSAssert(!databaseSalt);
OWSAssert(saltData);
OWSAssertDebug(!databaseSalt);
OWSAssertDebug(saltData);
// Simulate a failure to record the new salt, e.g. if KDF returns nil
return NO;
@ -438,8 +438,8 @@ NS_ASSUME_NONNULL_BEGIN
__block NSData *_Nullable databaseSalt = nil;
__block NSData *_Nullable databaseKeySpec = nil;
YapRecordDatabaseSaltBlock recordSaltBlock = ^(NSData *saltData) {
OWSAssert(!databaseSalt);
OWSAssert(saltData);
OWSAssertDebug(!databaseSalt);
OWSAssertDebug(saltData);
databaseSalt = saltData;
databaseKeySpec = [YapDatabaseCryptoUtils deriveDatabaseKeySpecForPassword:databasePassword saltData:saltData];
@ -485,7 +485,7 @@ NS_ASSUME_NONNULL_BEGIN
XCTAssertFalse([YapDatabaseCryptoUtils doesDatabaseNeedToBeConverted:databaseFilePath]);
YapRecordDatabaseSaltBlock recordSaltBlock = ^(NSData *saltData) {
OWSAssert(saltData);
OWSAssertDebug(saltData);
XCTFail(@"No conversion should be necessary");
return NO;
@ -518,7 +518,7 @@ NS_ASSUME_NONNULL_BEGIN
XCTAssertFalse([YapDatabaseCryptoUtils doesDatabaseNeedToBeConverted:databaseFilePath]);
YapRecordDatabaseSaltBlock recordSaltBlock = ^(NSData *saltData) {
OWSAssert(saltData);
OWSAssertDebug(saltData);
XCTFail(@"No conversion should be necessary");
return NO;
@ -549,7 +549,7 @@ NS_ASSUME_NONNULL_BEGIN
NSString *databaseFilePath = [self createTempDatabaseFilePath];
OWSAssert(![[NSFileManager defaultManager] fileExistsAtPath:databaseFilePath]);
OWSAssertDebug(![[NSFileManager defaultManager] fileExistsAtPath:databaseFilePath]);
NSData *keyData = [self randomDatabasePassword];
@ -706,7 +706,7 @@ NS_ASSUME_NONNULL_BEGIN
NSString *databaseFilePath = [self createTempDatabaseFilePath];
OWSAssert(![[NSFileManager defaultManager] fileExistsAtPath:databaseFilePath]);
OWSAssertDebug(![[NSFileManager defaultManager] fileExistsAtPath:databaseFilePath]);
NSData *keyData = [self randomDatabasePassword];
NSData *databaseSalt = [self randomDatabaseSalt];
@ -800,7 +800,7 @@ NS_ASSUME_NONNULL_BEGIN
NSString *databaseFilePath = [self createTempDatabaseFilePath];
OWSAssert(![[NSFileManager defaultManager] fileExistsAtPath:databaseFilePath]);
OWSAssertDebug(![[NSFileManager defaultManager] fileExistsAtPath:databaseFilePath]);
NSData *keyData = [self randomDatabasePassword];
NSData *databaseSalt = [self randomDatabaseSalt];
@ -927,12 +927,12 @@ NS_ASSUME_NONNULL_BEGIN
- (void)logHeaderOfDatabaseFile:(NSString *)databaseFilePath
label:(NSString *)label
{
OWSAssert(databaseFilePath.length > 0);
OWSAssert(label.length > 0);
OWSAssertDebug(databaseFilePath.length > 0);
OWSAssertDebug(label.length > 0);
NSData *headerData =
[YapDatabaseCryptoUtils readFirstNBytesOfDatabaseFile:databaseFilePath byteCount:kSqliteHeaderLength];
OWSAssert(headerData);
OWSAssertDebug(headerData);
NSMutableString *output = [NSMutableString new];
[output appendFormat:@"Hex: %@, ", headerData.hexadecimalString];
[output appendString:@"Ascii: "];
@ -991,7 +991,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)storeTestPasswordInKeychain:(NSData *)password
{
// legacy password length
OWSAssert(password.length == 30);
OWSAssertDebug(password.length == 30);
[OWSStorage storeKeyChainValue:password keychainKey:@"_OWSTestingPassword"];
}
@ -999,17 +999,17 @@ NS_ASSUME_NONNULL_BEGIN
{
NSError *error;
NSData *password = [OWSStorage tryToLoadKeyChainValue:@"_OWSTestingPassword" errorHandle:&error];
OWSAssert(password);
OWSAssert(!error);
OWSAssertDebug(password);
OWSAssertDebug(!error);
// legacy password length
OWSAssert(password.length == 30);
OWSAssertDebug(password.length == 30);
return password;
}
- (void)storeTestSaltInKeychain:(NSData *)salt
{
OWSAssert(salt.length == kSQLCipherSaltLength);
OWSAssertDebug(salt.length == kSQLCipherSaltLength);
[OWSStorage storeKeyChainValue:salt keychainKey:@"_OWSTestingSalt"];
}
@ -1017,15 +1017,15 @@ NS_ASSUME_NONNULL_BEGIN
{
NSError *error;
NSData *salt = [OWSStorage tryToLoadKeyChainValue:@"_OWSTestingSalt" errorHandle:&error];
OWSAssert(salt);
OWSAssert(!error);
OWSAssert(salt.length == kSQLCipherSaltLength);
OWSAssertDebug(salt);
OWSAssertDebug(!error);
OWSAssertDebug(salt.length == kSQLCipherSaltLength);
return salt;
}
- (void)storeTestKeySpecInKeychain:(NSData *)keySpec
{
OWSAssert(keySpec.length == kSQLCipherKeySpecLength);
OWSAssertDebug(keySpec.length == kSQLCipherKeySpecLength);
[OWSStorage storeKeyChainValue:keySpec keychainKey:@"_OWSTestingKeySpec"];
}
@ -1033,9 +1033,9 @@ NS_ASSUME_NONNULL_BEGIN
{
NSError *error;
NSData *keySpec = [OWSStorage tryToLoadKeyChainValue:@"_OWSTestingKeySpec" errorHandle:&error];
OWSAssert(keySpec);
OWSAssert(!error);
OWSAssert(keySpec.length == kSQLCipherKeySpecLength);
OWSAssertDebug(keySpec);
OWSAssertDebug(!error);
OWSAssertDebug(keySpec.length == kSQLCipherKeySpecLength);
return keySpec;
}

View File

@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
_hasBlockOffer = hasBlockOffer;
_hasAddToContactsOffer = hasAddToContactsOffer;
_hasAddToProfileWhitelistOffer = hasAddToProfileWhitelistOffer;
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
_recipientId = recipientId;
return self;

View File

@ -67,10 +67,10 @@
OWSTableSection *section = [OWSTableSection new];
for (NSString *countryCode in self.countryCodes) {
OWSAssert(countryCode.length > 0);
OWSAssert([PhoneNumberUtil countryNameFromCountryCode:countryCode].length > 0);
OWSAssert([PhoneNumberUtil callingCodeFromCountryCode:countryCode].length > 0);
OWSAssert(![[PhoneNumberUtil callingCodeFromCountryCode:countryCode] isEqualToString:@"+0"]);
OWSAssertDebug(countryCode.length > 0);
OWSAssertDebug([PhoneNumberUtil countryNameFromCountryCode:countryCode].length > 0);
OWSAssertDebug([PhoneNumberUtil callingCodeFromCountryCode:countryCode].length > 0);
OWSAssertDebug(![[PhoneNumberUtil callingCodeFromCountryCode:countryCode] isEqualToString:@"+0"]);
[section addItem:[OWSTableItem
itemWithCustomCellBlock:^{
@ -99,7 +99,7 @@
- (void)countryCodeWasSelected:(NSString *)countryCode
{
OWSAssert(countryCode.length > 0);
OWSAssertDebug(countryCode.length > 0);
NSString *callingCodeSelected = [PhoneNumberUtil callingCodeFromCountryCode:countryCode];
NSString *countryNameSelected = [PhoneNumberUtil countryNameFromCountryCode:countryCode];

View File

@ -48,21 +48,21 @@ NS_ASSUME_NONNULL_BEGIN
- (void)phoneNumberWasSelected:(NSString *)phoneNumber
{
OWSAssert(phoneNumber.length > 0);
OWSAssertDebug(phoneNumber.length > 0);
[self selectRecipient:phoneNumber];
}
- (void)signalAccountWasSelected:(SignalAccount *)signalAccount
{
OWSAssert(signalAccount);
OWSAssertDebug(signalAccount);
[self selectRecipient:signalAccount.recipientId];
}
- (void)selectRecipient:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
[self.nonContactConversationDelegate recipientIdWasSelected:recipientId];
}

View File

@ -78,7 +78,7 @@ NS_ASSUME_NONNULL_BEGIN
// if a view has unsaved changes.
- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item
{
OWSAssert(self.interactivePopGestureRecognizer.delegate == self);
OWSAssertDebug(self.interactivePopGestureRecognizer.delegate == self);
UIViewController *topViewController = self.topViewController;
// wasBackButtonClicked is YES if the back button was pressed but not
@ -110,7 +110,7 @@ NS_ASSUME_NONNULL_BEGIN
// if a view has unsaved changes.
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
OWSAssert(gestureRecognizer == self.interactivePopGestureRecognizer);
OWSAssertDebug(gestureRecognizer == self.interactivePopGestureRecognizer);
UIViewController *topViewController = self.topViewController;
if ([topViewController conformsToProtocol:@protocol(OWSNavigationView)]) {

View File

@ -32,7 +32,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
- (void)addSection:(OWSTableSection *)section
{
OWSAssert(section);
OWSAssertDebug(section);
[_sections addObject:section];
}
@ -69,7 +69,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
- (void)addItem:(OWSTableItem *)item
{
OWSAssert(item);
OWSAssertDebug(item);
[_items addObject:item];
}
@ -120,7 +120,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
+ (OWSTableItem *)itemWithTitle:(NSString *)title actionBlock:(nullable OWSTableActionBlock)actionBlock
{
OWSAssert(title.length > 0);
OWSAssertDebug(title.length > 0);
OWSTableItem *item = [OWSTableItem new];
item.actionBlock = actionBlock;
@ -132,8 +132,8 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
customRowHeight:(CGFloat)customRowHeight
actionBlock:(nullable OWSTableActionBlock)actionBlock
{
OWSAssert(customCell);
OWSAssert(customRowHeight > 0 || customRowHeight == UITableViewAutomaticDimension);
OWSAssertDebug(customCell);
OWSAssertDebug(customRowHeight > 0 || customRowHeight == UITableViewAutomaticDimension);
OWSTableItem *item = [OWSTableItem new];
item.actionBlock = actionBlock;
@ -146,7 +146,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
customRowHeight:(CGFloat)customRowHeight
actionBlock:(nullable OWSTableActionBlock)actionBlock
{
OWSAssert(customRowHeight > 0 || customRowHeight == UITableViewAutomaticDimension);
OWSAssertDebug(customRowHeight > 0 || customRowHeight == UITableViewAutomaticDimension);
OWSTableItem *item = [self itemWithCustomCellBlock:customCellBlock actionBlock:actionBlock];
item.customRowHeight = @(customRowHeight);
@ -156,7 +156,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
+ (OWSTableItem *)itemWithCustomCellBlock:(OWSTableCustomCellBlock)customCellBlock
actionBlock:(nullable OWSTableActionBlock)actionBlock
{
OWSAssert(customCellBlock);
OWSAssertDebug(customCellBlock);
OWSTableItem *item = [OWSTableItem new];
item.actionBlock = actionBlock;
@ -178,8 +178,8 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
actionBlock:(nullable OWSTableActionBlock)actionBlock
accessoryType:(UITableViewCellAccessoryType)accessoryType
{
OWSAssert(text.length > 0);
OWSAssert(actionBlock);
OWSAssertDebug(text.length > 0);
OWSAssertDebug(actionBlock);
OWSTableItem *item = [OWSTableItem new];
item.actionBlock = actionBlock;
@ -196,7 +196,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
customRowHeight:(CGFloat)customRowHeight
actionBlock:(nullable OWSTableActionBlock)actionBlock
{
OWSAssert(customRowHeight > 0 || customRowHeight == UITableViewAutomaticDimension);
OWSAssertDebug(customRowHeight > 0 || customRowHeight == UITableViewAutomaticDimension);
OWSTableItem *item = [self disclosureItemWithText:text actionBlock:actionBlock];
item.customRowHeight = @(customRowHeight);
@ -207,8 +207,8 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
detailText:(NSString *)detailText
actionBlock:(nullable OWSTableActionBlock)actionBlock
{
OWSAssert(text.length > 0);
OWSAssert(actionBlock);
OWSAssertDebug(text.length > 0);
OWSAssertDebug(actionBlock);
OWSTableItem *item = [OWSTableItem new];
item.actionBlock = actionBlock;
@ -226,15 +226,15 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
+ (OWSTableItem *)subPageItemWithText:(NSString *)text actionBlock:(nullable OWSTableSubPageBlock)actionBlock
{
OWSAssert(text.length > 0);
OWSAssert(actionBlock);
OWSAssertDebug(text.length > 0);
OWSAssertDebug(actionBlock);
OWSTableItem *item = [OWSTableItem new];
__weak OWSTableItem *weakItem = item;
item.actionBlock = ^{
OWSTableItem *strongItem = weakItem;
OWSAssert(strongItem);
OWSAssert(strongItem.tableViewController);
OWSAssertDebug(strongItem);
OWSAssertDebug(strongItem.tableViewController);
if (actionBlock) {
actionBlock(strongItem.tableViewController);
@ -253,7 +253,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
customRowHeight:(CGFloat)customRowHeight
actionBlock:(nullable OWSTableSubPageBlock)actionBlock
{
OWSAssert(customRowHeight > 0 || customRowHeight == UITableViewAutomaticDimension);
OWSAssertDebug(customRowHeight > 0 || customRowHeight == UITableViewAutomaticDimension);
OWSTableItem *item = [self subPageItemWithText:text actionBlock:actionBlock];
item.customRowHeight = @(customRowHeight);
@ -262,8 +262,8 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
+ (OWSTableItem *)actionItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock
{
OWSAssert(text.length > 0);
OWSAssert(actionBlock);
OWSAssertDebug(text.length > 0);
OWSAssertDebug(actionBlock);
OWSTableItem *item = [OWSTableItem new];
item.actionBlock = actionBlock;
@ -277,7 +277,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
+ (OWSTableItem *)softCenterLabelItemWithText:(NSString *)text
{
OWSAssert(text.length > 0);
OWSAssertDebug(text.length > 0);
OWSTableItem *item = [OWSTableItem new];
item.customCellBlock = ^{
@ -300,7 +300,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
+ (OWSTableItem *)softCenterLabelItemWithText:(NSString *)text customRowHeight:(CGFloat)customRowHeight
{
OWSAssert(customRowHeight > 0 || customRowHeight == UITableViewAutomaticDimension);
OWSAssertDebug(customRowHeight > 0 || customRowHeight == UITableViewAutomaticDimension);
OWSTableItem *item = [self softCenterLabelItemWithText:text];
item.customRowHeight = @(customRowHeight);
@ -309,7 +309,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
+ (OWSTableItem *)labelItemWithText:(NSString *)text
{
OWSAssert(text.length > 0);
OWSAssertDebug(text.length > 0);
OWSTableItem *item = [OWSTableItem new];
item.customCellBlock = ^{
@ -323,8 +323,8 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
+ (OWSTableItem *)labelItemWithText:(NSString *)text accessoryText:(NSString *)accessoryText
{
OWSAssert(text.length > 0);
OWSAssert(accessoryText.length > 0);
OWSAssertDebug(text.length > 0);
OWSAssertDebug(accessoryText.length > 0);
OWSTableItem *item = [OWSTableItem new];
item.customCellBlock = ^{
@ -356,9 +356,9 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
target:(id)target
selector:(SEL)selector
{
OWSAssert(text.length > 0);
OWSAssert(target);
OWSAssert(selector);
OWSAssertDebug(text.length > 0);
OWSAssertDebug(target);
OWSAssertDebug(selector);
OWSTableItem *item = [OWSTableItem new];
__weak id weakTarget = target;
@ -452,7 +452,7 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
{
[super loadView];
OWSAssert(self.contents);
OWSAssertDebug(self.contents);
if (self.contents.title.length > 0) {
self.title = self.contents.title;
@ -503,8 +503,8 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
- (OWSTableSection *)sectionForIndex:(NSInteger)sectionIndex
{
OWSAssert(self.contents);
OWSAssert(sectionIndex >= 0 && sectionIndex < (NSInteger)self.contents.sections.count);
OWSAssertDebug(self.contents);
OWSAssertDebug(sectionIndex >= 0 && sectionIndex < (NSInteger)self.contents.sections.count);
OWSTableSection *section = self.contents.sections[(NSUInteger)sectionIndex];
return section;
@ -512,11 +512,11 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
- (OWSTableItem *)itemForIndexPath:(NSIndexPath *)indexPath
{
OWSAssert(self.contents);
OWSAssert(indexPath.section >= 0 && indexPath.section < (NSInteger)self.contents.sections.count);
OWSAssertDebug(self.contents);
OWSAssertDebug(indexPath.section >= 0 && indexPath.section < (NSInteger)self.contents.sections.count);
OWSTableSection *section = self.contents.sections[(NSUInteger)indexPath.section];
OWSAssert(indexPath.item >= 0 && indexPath.item < (NSInteger)section.items.count);
OWSAssertDebug(indexPath.item >= 0 && indexPath.item < (NSInteger)section.items.count);
OWSTableItem *item = section.items[(NSUInteger)indexPath.item];
return item;
@ -524,7 +524,7 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
- (void)setContents:(OWSTableContents *)contents
{
OWSAssert(contents);
OWSAssertDebug(contents);
OWSAssertIsOnMainThread();
_contents = contents;
@ -536,14 +536,14 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
OWSAssert(self.contents);
OWSAssertDebug(self.contents);
return (NSInteger)self.contents.sections.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)sectionIndex
{
OWSTableSection *section = [self sectionForIndex:sectionIndex];
OWSAssert(section.items);
OWSAssertDebug(section.items);
return (NSInteger)section.items.count;
}
@ -571,7 +571,7 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
}
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kOWSTableCellIdentifier];
OWSAssert(cell);
OWSAssertDebug(cell);
[OWSTableItem configureCell:cell];
cell.textLabel.text = item.title;
@ -610,7 +610,7 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
}
if (section.customHeaderHeight) {
OWSAssert([section.customHeaderHeight floatValue] > 0);
OWSAssertDebug([section.customHeaderHeight floatValue] > 0);
return [section.customHeaderHeight floatValue];
} else if (section.headerTitle.length > 0) {
return UITableViewAutomaticDimension;
@ -628,7 +628,7 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
}
if (section.customFooterHeight) {
OWSAssert([section.customFooterHeight floatValue] > 0);
OWSAssertDebug([section.customFooterHeight floatValue] > 0);
return [section.customFooterHeight floatValue];
} else if (section.footerTitle.length > 0) {
return UITableViewAutomaticDimension;
@ -682,7 +682,7 @@ NSString *const kOWSTableCellIdentifier = @"kOWSTableCellIdentifier";
- (void)presentFromViewController:(UIViewController *)fromViewController
{
OWSAssert(fromViewController);
OWSAssertDebug(fromViewController);
OWSNavigationController *navigationController = [[OWSNavigationController alloc] initWithRootViewController:self];
self.navigationItem.leftBarButtonItem =

View File

@ -64,8 +64,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)autoPinViewToBottomOfViewControllerOrKeyboard:(UIView *)view avoidNotch:(BOOL)avoidNotch
{
OWSAssert(view);
OWSAssert(!self.bottomLayoutConstraint);
OWSAssertDebug(view);
OWSAssertDebug(!self.bottomLayoutConstraint);
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)

View File

@ -70,7 +70,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
- (void)viewDidLoad
{
OWSAssert(self.tableViewController);
OWSAssertDebug(self.tableViewController);
[super viewDidLoad];
}
@ -87,7 +87,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
- (void)createViews
{
OWSAssert(self.delegate);
OWSAssertDebug(self.delegate);
_tableViewController = [OWSTableViewController new];
_tableViewController.delegate = self;
@ -212,13 +212,13 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
- (void)populateDefaultCountryNameAndCode
{
PhoneNumber *localNumber = [PhoneNumber phoneNumberFromE164:[TSAccountManager localNumber]];
OWSAssert(localNumber);
OWSAssertDebug(localNumber);
NSString *countryCode;
NSNumber *callingCode;
if (localNumber) {
callingCode = [localNumber getCountryCode];
OWSAssert(callingCode);
OWSAssertDebug(callingCode);
if (callingCode) {
NSString *prefix = [NSString stringWithFormat:@"+%d", callingCode.intValue];
countryCode = [[PhoneNumberUtil sharedThreadLocal] probableCountryCodeForCallingCode:prefix];
@ -283,7 +283,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
- (void)tryToSelectPhoneNumber
{
OWSAssert(self.delegate);
OWSAssertDebug(self.delegate);
if (![self hasValidPhoneNumber]) {
OWSFailDebug(@"Invalid phone number was selected.");
@ -307,7 +307,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
// There should only be one phone number, since we're explicitly specifying
// a country code and therefore parsing a number in e164 format.
OWSAssert([possiblePhoneNumbers count] == 1);
OWSAssertDebug([possiblePhoneNumbers count] == 1);
if ([self.delegate shouldValidatePhoneNumbers]) {
// Show an alert while validating the recipient.
@ -403,9 +403,9 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
countryName:(NSString *)countryName
callingCode:(NSString *)callingCode
{
OWSAssert(countryCode.length > 0);
OWSAssert(countryName.length > 0);
OWSAssert(callingCode.length > 0);
OWSAssertDebug(countryCode.length > 0);
OWSAssertDebug(countryName.length > 0);
OWSAssertDebug(callingCode.length > 0);
[self updateCountryWithName:countryName callingCode:callingCode countryCode:countryCode];
@ -456,7 +456,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
const CGFloat kButtonRowHeight = 60;
[phoneNumberSection addItem:[OWSTableItem itemWithCustomCellBlock:^{
SelectRecipientViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
OWSCAssertDebug(strongSelf);
UITableViewCell *cell = [OWSTableItem newCell];
cell.preservesSuperviewLayoutMargins = YES;
@ -539,7 +539,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
SelectRecipientViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
OWSCAssertDebug(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId];

View File

@ -84,7 +84,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)createViews
{
OWSAssert(self.selectThreadViewDelegate);
OWSAssertDebug(self.selectThreadViewDelegate);
// Search
UISearchBar *searchBar = [OWSSearchBar new];
@ -191,7 +191,7 @@ NS_ASSUME_NONNULL_BEGIN
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
SelectThreadViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
OWSCAssertDebug(strongSelf);
// To be consistent with the threads (above), we use ContactTableViewCell
// instead of HomeViewCell to present contacts and threads.
@ -273,7 +273,7 @@ NS_ASSUME_NONNULL_BEGIN
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
SelectThreadViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
OWSCAssertDebug(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId];
@ -309,8 +309,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)signalAccountWasSelected:(SignalAccount *)signalAccount
{
OWSAssert(signalAccount);
OWSAssert(self.selectThreadViewDelegate);
OWSAssertDebug(signalAccount);
OWSAssertDebug(self.selectThreadViewDelegate);
ContactsViewHelper *helper = self.contactsViewHelper;
@ -334,7 +334,7 @@ NS_ASSUME_NONNULL_BEGIN
[OWSPrimaryStorage.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
thread = [TSContactThread getOrCreateThreadWithContactId:signalAccount.recipientId transaction:transaction];
}];
OWSAssert(thread);
OWSAssertDebug(thread);
[self.selectThreadViewDelegate threadWasSelected:thread];
}

View File

@ -82,7 +82,7 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
- (nullable UIView *)createHeaderWithSearchBar:(UISearchBar *)searchBar
{
OWSAssert(searchBar);
OWSAssertDebug(searchBar);
const CGFloat contentVMargin = 0;
@ -135,7 +135,7 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
return nil;
}
NSData *data = self.attachment.data;
OWSAssert(data.length < kOversizeTextMessageSizeThreshold);
OWSAssertDebug(data.length < kOversizeTextMessageSizeThreshold);
NSString *_Nullable messageText = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
OWSLogVerbose(@"messageTextForAttachment: %@", messageText);
return [messageText filterStringForDisplay];
@ -143,8 +143,8 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
- (void)threadWasSelected:(TSThread *)thread
{
OWSAssert(self.attachment);
OWSAssert(thread);
OWSAssertDebug(self.attachment);
OWSAssertDebug(thread);
self.thread = thread;
@ -172,9 +172,9 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
- (void)showContactShareApproval
{
OWSAssert(self.attachment);
OWSAssert(self.thread);
OWSAssert(self.attachment.isConvertibleToContactShare);
OWSAssertDebug(self.attachment);
OWSAssertDebug(self.thread);
OWSAssertDebug(self.attachment.isConvertibleToContactShare);
NSData *data = self.attachment.data;
@ -262,7 +262,7 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
- (void)messageApproval:(MessageApprovalViewController *)approvalViewController
didApproveMessage:(NSString *)messageText
{
OWSAssert(messageText.length > 0);
OWSAssertDebug(messageText.length > 0);
[ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread];
[self tryToSendMessageWithBlock:^(SendCompletionBlock sendCompletion) {
@ -397,9 +397,9 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
fromViewController:(UIViewController *)fromViewController
{
OWSAssertIsOnMainThread();
OWSAssert(error);
OWSAssert(message);
OWSAssert(fromViewController);
OWSAssertDebug(error);
OWSAssertDebug(message);
OWSAssertDebug(fromViewController);
NSString *failureTitle = NSLocalizedString(@"SHARE_EXTENSION_SENDING_FAILURE_TITLE", @"Alert title");
@ -472,9 +472,9 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
fromViewController:(UIViewController *)fromViewController
{
OWSAssertIsOnMainThread();
OWSAssert(message);
OWSAssert(recipientId.length > 0);
OWSAssert(fromViewController);
OWSAssertDebug(message);
OWSAssertDebug(recipientId.length > 0);
OWSAssertDebug(fromViewController);
OWSLogDebug(@"Confirming identity for recipient: %@", recipientId);
@ -500,7 +500,7 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
OWSLogInfo(@"marked recipient: %@ as default verification status.", recipientId);
NSData *identityKey =
[[OWSIdentityManager sharedManager] identityKeyForRecipientId:recipientId transaction:transaction];
OWSAssert(identityKey);
OWSAssertDebug(identityKey);
[[OWSIdentityManager sharedManager] setVerificationState:OWSVerificationStateDefault
identityKey:identityKey
recipientId:recipientId
@ -519,8 +519,8 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
- (void)resendMessage:(TSOutgoingMessage *)message fromViewController:(UIViewController *)fromViewController
{
OWSAssertIsOnMainThread();
OWSAssert(message);
OWSAssert(fromViewController);
OWSAssertDebug(message);
OWSAssertDebug(fromViewController);
NSString *progressTitle = NSLocalizedString(@"SHARE_EXTENSION_SENDING_IN_PROGRESS_TITLE", @"Alert title");
UIAlertController *progressAlert = [UIAlertController alertControllerWithTitle:progressTitle
@ -565,7 +565,7 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
{
OWSLogDebug(@"upload progress.");
OWSAssertIsOnMainThread();
OWSAssert(self.progressView);
OWSAssertDebug(self.progressView);
if (!self.outgoingMessage) {
OWSLogDebug(@"Ignoring upload progress until there is an outgoing message.");

View File

@ -129,11 +129,11 @@ const NSUInteger kMax2FAPinLength = 16;
+ (NSString *)examplePhoneNumberForCountryCode:(NSString *)countryCode callingCode:(NSString *)callingCode
{
OWSAssert(countryCode.length > 0);
OWSAssert(callingCode.length > 0);
OWSAssertDebug(countryCode.length > 0);
OWSAssertDebug(callingCode.length > 0);
NSString *examplePhoneNumber = [PhoneNumberUtil examplePhoneNumberForCountryCode:countryCode];
OWSAssert(!examplePhoneNumber || [examplePhoneNumber hasPrefix:callingCode]);
OWSAssertDebug(!examplePhoneNumber || [examplePhoneNumber hasPrefix:callingCode]);
if (examplePhoneNumber && [examplePhoneNumber hasPrefix:callingCode]) {
NSString *formattedPhoneNumber =
[PhoneNumber bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:examplePhoneNumber

View File

@ -75,7 +75,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (instancetype)quotedReplyWithQuotedMessage:(TSQuotedMessage *)quotedMessage
transaction:(YapDatabaseReadTransaction *)transaction
{
OWSAssert(quotedMessage.quotedAttachments.count <= 1);
OWSAssertDebug(quotedMessage.quotedAttachments.count <= 1);
OWSAttachmentInfo *attachmentInfo = quotedMessage.quotedAttachments.firstObject;
BOOL thumbnailDownloadFailed = NO;
@ -118,8 +118,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (nullable instancetype)quotedReplyForSendingWithConversationViewItem:(ConversationViewItem *)conversationItem
transaction:(YapDatabaseReadTransaction *)transaction;
{
OWSAssert(conversationItem);
OWSAssert(transaction);
OWSAssertDebug(conversationItem);
OWSAssertDebug(transaction);
TSMessage *message = (TSMessage *)conversationItem.interaction;
if (![message isKindOfClass:[TSMessage class]]) {
@ -128,7 +128,7 @@ NS_ASSUME_NONNULL_BEGIN
}
TSThread *thread = [message threadWithTransaction:transaction];
OWSAssert(thread);
OWSAssertDebug(thread);
uint64_t timestamp = message.timestamp;
@ -142,7 +142,7 @@ NS_ASSUME_NONNULL_BEGIN
return (NSString * _Nullable) nil;
}
}();
OWSAssert(authorId.length > 0);
OWSAssertDebug(authorId.length > 0);
if (conversationItem.contactShare) {
ContactShareViewModel *contactShare = conversationItem.contactShare;

View File

@ -48,7 +48,7 @@ const CGFloat kContactCellAvatarTextMargin = 12;
- (void)configure
{
OWSAssert(!self.nameLabel);
OWSAssertDebug(!self.nameLabel);
self.layoutMargins = UIEdgeInsetsZero;
@ -105,8 +105,8 @@ const CGFloat kContactCellAvatarTextMargin = 12;
- (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager
{
OWSAssert(recipientId.length > 0);
OWSAssert(contactsManager);
OWSAssertDebug(recipientId.length > 0);
OWSAssertDebug(contactsManager);
// Update fonts to reflect changes to dynamic type.
[self configureFontsAndColors];
@ -135,7 +135,7 @@ const CGFloat kContactCellAvatarTextMargin = 12;
- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager
{
OWSAssert(thread);
OWSAssertDebug(thread);
self.thread = thread;
// Update fonts to reflect changes to dynamic type.
@ -196,7 +196,7 @@ const CGFloat kContactCellAvatarTextMargin = 12;
if (self.thread) {
return self.thread.conversationColorName;
} else {
OWSAssert(self.recipientId);
OWSAssertDebug(self.recipientId);
return [TSThread stableConversationColorNameForString:self.recipientId];
}
}();
@ -255,7 +255,7 @@ const CGFloat kContactCellAvatarTextMargin = 12;
OWSAssertIsOnMainThread();
NSString *recipientId = notification.userInfo[kNSNotificationKey_ProfileRecipientId];
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
if (recipientId.length > 0 && [self.recipientId isEqualToString:recipientId]) {
[self updateProfileName];
@ -291,9 +291,9 @@ const CGFloat kContactCellAvatarTextMargin = 12;
- (void)setAccessoryView:(UIView *)accessoryView
{
OWSAssert(accessoryView);
OWSAssert(self.accessoryViewContainer);
OWSAssert(self.accessoryViewContainer.subviews.count < 1);
OWSAssertDebug(accessoryView);
OWSAssertDebug(self.accessoryViewContainer);
OWSAssertDebug(self.accessoryViewContainer.subviews.count < 1);
[self.accessoryViewContainer addSubview:accessoryView];

View File

@ -42,7 +42,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)configure
{
OWSAssert(!self.cellView);
OWSAssertDebug(!self.cellView);
self.preservesSuperviewLayoutMargins = YES;
self.contentView.preservesSuperviewLayoutMargins = YES;
@ -65,7 +65,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager
{
OWSAssert(thread);
OWSAssertDebug(thread);
[OWSTableItem configureCell:self];
@ -77,7 +77,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)setAccessoryMessage:(nullable NSString *)accessoryMessage
{
OWSAssert(self.cellView);
OWSAssertDebug(self.cellView);
self.cellView.accessoryMessage = accessoryMessage;
}

View File

@ -47,7 +47,7 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
OWSAssert(delegate);
OWSAssertDebug(delegate);
_delegate = delegate;
_blockingManager = [OWSBlockingManager sharedManager];
@ -105,14 +105,14 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable SignalAccount *)fetchSignalAccountForRecipientId:(NSString *)recipientId
{
OWSAssertIsOnMainThread();
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
return self.signalAccountMap[recipientId];
}
- (SignalAccount *)fetchOrBuildSignalAccountForRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
SignalAccount *_Nullable signalAccount = [self fetchSignalAccountForRecipientId:recipientId];
return (signalAccount ?: [[SignalAccount alloc] initWithRecipientId:recipientId]);
@ -201,8 +201,8 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)doesContact:(Contact *)contact matchSearchTerm:(NSString *)searchTerm
{
OWSAssert(contact);
OWSAssert(searchTerm.length > 0);
OWSAssertDebug(contact);
OWSAssertDebug(searchTerm.length > 0);
if ([contact.fullName.lowercaseString containsString:searchTerm.lowercaseString]) {
return YES;
@ -222,8 +222,8 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)doesContact:(Contact *)contact matchSearchTerms:(NSArray<NSString *> *)searchTerms
{
OWSAssert(contact);
OWSAssert(searchTerms.count > 0);
OWSAssertDebug(contact);
OWSAssertDebug(searchTerms.count > 0);
for (NSString *searchTerm in searchTerms) {
if (![self doesContact:contact matchSearchTerm:searchTerm]) {

View File

@ -191,7 +191,7 @@ NS_ASSUME_NONNULL_BEGIN
NSMutableArray<TSThread *> *threads = [NSMutableArray new];
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
NSUInteger numberOfSections = [self.threadMappings numberOfSections];
OWSAssert(numberOfSections == 1);
OWSAssertDebug(numberOfSections == 1);
for (NSUInteger section = 0; section < numberOfSections; section++) {
NSUInteger numberOfItems = [self.threadMappings numberOfItemsInSection:section];
for (NSUInteger item = 0; item < numberOfItems; item++) {

View File

@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)showShareUIForAttachment:(TSAttachmentStream *)stream
{
OWSAssert(stream);
OWSAssertDebug(stream);
[self showShareUIForURL:stream.mediaURL];
}
@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)showShareUIForURL:(NSURL *)url completion:(nullable AttachmentSharingCompletion)completion
{
OWSAssert(url);
OWSAssertDebug(url);
[AttachmentSharing showShareUIForActivityItems:@[
url,
@ -41,7 +41,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)showShareUIForText:(NSString *)text completion:(nullable AttachmentSharingCompletion)completion
{
OWSAssert(text);
OWSAssertDebug(text);
[AttachmentSharing showShareUIForActivityItems:@[
text,
@ -52,7 +52,7 @@ NS_ASSUME_NONNULL_BEGIN
#ifdef DEBUG
+ (void)showShareUIForUIImage:(UIImage *)image
{
OWSAssert(image);
OWSAssertDebug(image);
[AttachmentSharing showShareUIForActivityItems:@[
image,
@ -63,7 +63,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (void)showShareUIForActivityItems:(NSArray *)activityItems completion:(nullable AttachmentSharingCompletion)completion
{
OWSAssert(activityItems);
OWSAssertDebug(activityItems);
DispatchMainThreadSafe(^{
UIActivityViewController *activityViewController =
@ -89,7 +89,7 @@ NS_ASSUME_NONNULL_BEGIN
while (fromViewController.presentedViewController) {
fromViewController = fromViewController.presentedViewController;
}
OWSAssert(fromViewController);
OWSAssertDebug(fromViewController);
[fromViewController presentViewController:activityViewController animated:YES completion:nil];
});
}

View File

@ -12,8 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
- (NSAttributedString *)rtlSafeAppend:(NSString *)text attributes:(NSDictionary *)attributes
{
OWSAssert(text);
OWSAssert(attributes);
OWSAssertDebug(text);
OWSAssertDebug(attributes);
NSAttributedString *substring = [[NSAttributedString alloc] initWithString:text attributes:attributes];
return [self rtlSafeAppend:substring];
@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSAttributedString *)rtlSafeAppend:(NSAttributedString *)string
{
OWSAssert(string);
OWSAssertDebug(string);
NSMutableAttributedString *result = [NSMutableAttributedString new];
if (CurrentAppContext().isRTL) {

View File

@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSString *)rtlSafeAppend:(NSString *)string
{
OWSAssert(string);
OWSAssertDebug(string);
if (CurrentAppContext().isRTL) {
return [string stringByAppendingString:self];
@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSString *)removeAllCharactersIn:(NSCharacterSet *)characterSet
{
OWSAssert(characterSet);
OWSAssertDebug(characterSet);
return [[self componentsSeparatedByCharactersInSet:characterSet] componentsJoinedByString:@""];
}

View File

@ -110,14 +110,14 @@ NS_ASSUME_NONNULL_BEGIN
BOOL result =
#endif
[self getRed:&r0 green:&g0 blue:&b0 alpha:&a0];
OWSAssert(result);
OWSAssertDebug(result);
CGFloat r1, g1, b1, a1;
#ifdef DEBUG
result =
#endif
[otherColor getRed:&r1 green:&g1 blue:&b1 alpha:&a1];
OWSAssert(result);
OWSAssertDebug(result);
return [UIColor colorWithRed:CGFloatLerp(r0, r1, alpha)
green:CGFloatLerp(g0, g1, alpha)
@ -306,7 +306,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (nullable UIColor *)ows_conversationColorForColorName:(NSString *)colorName
{
OWSAssert(colorName.length > 0);
OWSAssertDebug(colorName.length > 0);
return [self.ows_conversationColorMap objectForKey:colorName];
}

View File

@ -113,7 +113,7 @@ NS_ASSUME_NONNULL_BEGIN
{
UIFontDescriptor *fontDescriptor = [self.fontDescriptor fontDescriptorWithSymbolicTraits:symbolicTraits];
UIFont *font = [UIFont fontWithDescriptor:fontDescriptor size:0];
OWSAssert(font);
OWSAssertDebug(font);
return font ?: self;
}

View File

@ -113,7 +113,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
- (void)autoPinWidthToWidthOfView:(UIView *)view
{
OWSAssert(view);
OWSAssertDebug(view);
[self autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:view];
[self autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:view];
@ -121,7 +121,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
- (void)autoPinHeightToHeightOfView:(UIView *)view
{
OWSAssert(view);
OWSAssertDebug(view);
[self autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:view];
[self autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:view];
@ -252,7 +252,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
- (void)centerOnSuperview
{
OWSAssert(self.superview);
OWSAssertDebug(self.superview);
CGFloat x = (CGFloat)round((self.superview.width - self.width) * 0.5f);
CGFloat y = (CGFloat)round((self.superview.height - self.height) * 0.5f);
@ -323,14 +323,14 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
- (NSLayoutConstraint *)autoPinLeadingToTrailingEdgeOfView:(UIView *)view
{
OWSAssert(view);
OWSAssertDebug(view);
return [self autoPinLeadingToTrailingEdgeOfView:view offset:0];
}
- (NSLayoutConstraint *)autoPinLeadingToTrailingEdgeOfView:(UIView *)view offset:(CGFloat)offset
{
OWSAssert(view);
OWSAssertDebug(view);
self.translatesAutoresizingMaskIntoConstraints = NO;
@ -341,14 +341,14 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
- (NSLayoutConstraint *)autoPinTrailingToLeadingEdgeOfView:(UIView *)view
{
OWSAssert(view);
OWSAssertDebug(view);
return [self autoPinTrailingToLeadingEdgeOfView:view offset:0];
}
- (NSLayoutConstraint *)autoPinTrailingToLeadingEdgeOfView:(UIView *)view offset:(CGFloat)offset
{
OWSAssert(view);
OWSAssertDebug(view);
self.translatesAutoresizingMaskIntoConstraints = NO;
@ -359,14 +359,14 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
- (NSLayoutConstraint *)autoPinLeadingToEdgeOfView:(UIView *)view
{
OWSAssert(view);
OWSAssertDebug(view);
return [self autoPinLeadingToEdgeOfView:view offset:0];
}
- (NSLayoutConstraint *)autoPinLeadingToEdgeOfView:(UIView *)view offset:(CGFloat)offset
{
OWSAssert(view);
OWSAssertDebug(view);
self.translatesAutoresizingMaskIntoConstraints = NO;
@ -377,14 +377,14 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
- (NSLayoutConstraint *)autoPinTrailingToEdgeOfView:(UIView *)view
{
OWSAssert(view);
OWSAssertDebug(view);
return [self autoPinTrailingToEdgeOfView:view offset:0];
}
- (NSLayoutConstraint *)autoPinTrailingToEdgeOfView:(UIView *)view offset:(CGFloat)margin
{
OWSAssert(view);
OWSAssertDebug(view);
self.translatesAutoresizingMaskIntoConstraints = NO;
@ -408,7 +408,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
- (NSArray<NSLayoutConstraint *> *)autoPinToEdgesOfView:(UIView *)view
{
OWSAssert(view);
OWSAssertDebug(view);
return @[
[self autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:view],
@ -514,7 +514,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
- (void)traverseViewHierarchyWithVisitor:(UIViewVisitorBlock)visitor
{
OWSAssertIsOnMainThread();
OWSAssert(visitor);
OWSAssertDebug(visitor);
visitor(self);

View File

@ -50,8 +50,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (UIBarButtonItem *)createOWSBackButtonWithTarget:(id)target selector:(SEL)selector
{
OWSAssert(target);
OWSAssert(selector);
OWSAssertDebug(target);
OWSAssertDebug(selector);
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
BOOL isRTL = CurrentAppContext().isRTL;
@ -75,7 +75,7 @@ NS_ASSUME_NONNULL_BEGIN
UIImage *backImage = [[UIImage imageNamed:(isRTL ? @"NavBarBackRTL" : @"NavBarBack")]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
OWSAssert(backImage);
OWSAssertDebug(backImage);
[backButton setImage:backImage forState:UIControlStateNormal];
backButton.tintColor = Theme.navbarIconColor;

View File

@ -158,7 +158,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (nullable CNContact *)cnContactWithId:(nullable NSString *)contactId
{
OWSAssert(self.cnContactCache);
OWSAssertDebug(self.cnContactCache);
if (!contactId) {
return nil;
@ -187,7 +187,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (nullable UIImage *)avatarImageForCNContactId:(nullable NSString *)contactId
{
OWSAssert(self.cnContactAvatarCache);
OWSAssertDebug(self.cnContactAvatarCache);
if (!contactId) {
return nil;
@ -242,7 +242,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (NSSet<NSString *> *)recipientIdsForIntersectionWithContacts:(NSArray<Contact *> *)contacts
{
OWSAssert(contacts);
OWSAssertDebug(contacts);
NSMutableSet<NSString *> *recipientIds = [NSMutableSet set];
@ -259,8 +259,8 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
isUserRequested:(BOOL)isUserRequested
completion:(void (^)(NSError *_Nullable error))completion
{
OWSAssert(contacts);
OWSAssert(completion);
OWSAssertDebug(contacts);
OWSAssertDebug(completion);
dispatch_async(self.serialQueue, ^{
__block BOOL isFullIntersection = YES;
@ -299,7 +299,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
}
}
}];
OWSAssert(recipientIdsForIntersection);
OWSAssertDebug(recipientIdsForIntersection);
if (recipientIdsForIntersection.count < 1) {
OWSLogInfo(@"Skipping intersection; no contacts to intersect.");
@ -329,7 +329,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (void)markIntersectionAsComplete:(NSSet<NSString *> *)recipientIdsForIntersection
isFullIntersection:(BOOL)isFullIntersection
{
OWSAssert(recipientIdsForIntersection.count > 0);
OWSAssertDebug(recipientIdsForIntersection.count > 0);
dispatch_async(self.serialQueue, ^{
[self.dbReadConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
@ -355,10 +355,10 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
success:(void (^)(NSSet<SignalRecipient *> *))successParameter
failure:(void (^)(NSError *))failureParameter
{
OWSAssert(recipientIds.count > 0);
OWSAssert(retryDelaySeconds > 0);
OWSAssert(successParameter);
OWSAssert(failureParameter);
OWSAssertDebug(recipientIds.count > 0);
OWSAssertDebug(retryDelaySeconds > 0);
OWSAssertDebug(successParameter);
OWSAssertDebug(failureParameter);
void (^success)(NSArray<SignalRecipient *> *) = ^(NSArray<SignalRecipient *> *registeredRecipientIds) {
OWSLogInfo(@"Successfully intersected contacts.");
@ -401,7 +401,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
OWSAssertIsOnMainThread();
NSString *recipientId = notification.userInfo[kNSNotificationKey_ProfileRecipientId];
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
[self.avatarCache removeAllImagesForKey:recipientId];
}
@ -482,7 +482,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
[SignalAccount
enumerateCollectionObjectsWithTransaction:transaction
usingBlock:^(id _Nonnull object, BOOL *_Nonnull stop) {
OWSAssert([object isKindOfClass:[SignalAccount class]]);
OWSAssertDebug([object isKindOfClass:[SignalAccount class]]);
SignalAccount *oldSignalAccount = (SignalAccount *)object;
oldSignalAccounts[oldSignalAccount.uniqueId] = oldSignalAccount;
@ -582,7 +582,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (NSString *_Nullable)cachedContactNameForRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
SignalAccount *_Nullable signalAccount = [self fetchSignalAccountForRecipientId:recipientId];
if (!signalAccount) {
@ -610,7 +610,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (NSString *_Nullable)cachedFirstNameForRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
SignalAccount *_Nullable signalAccount = [self fetchSignalAccountForRecipientId:recipientId];
return signalAccount.contact.firstName.filterStringForDisplay;
@ -618,7 +618,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (NSString *_Nullable)cachedLastNameForRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
SignalAccount *_Nullable signalAccount = [self fetchSignalAccountForRecipientId:recipientId];
return signalAccount.contact.lastName.filterStringForDisplay;
@ -629,9 +629,9 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
// TODO move into Contact class.
+ (NSString *)accountLabelForContact:(Contact *)contact recipientId:(NSString *)recipientId
{
OWSAssert(contact);
OWSAssert(recipientId.length > 0);
OWSAssert([contact.textSecureIdentifiers containsObject:recipientId]);
OWSAssertDebug(contact);
OWSAssertDebug(recipientId.length > 0);
OWSAssertDebug([contact.textSecureIdentifiers containsObject:recipientId]);
if (contact.textSecureIdentifiers.count <= 1) {
return nil;
@ -648,7 +648,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
}
}
OWSAssert([phoneNumbersWithTheSameName containsObject:recipientId]);
OWSAssertDebug([phoneNumbersWithTheSameName containsObject:recipientId]);
if (phoneNumbersWithTheSameName.count > 1) {
NSUInteger index =
[[phoneNumbersWithTheSameName sortedArrayUsingSelector:@selector((compare:))] indexOfObject:recipientId];
@ -673,14 +673,14 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (BOOL)isSystemContact:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
return self.allContactsMap[recipientId] != nil;
}
- (BOOL)isSystemContactWithSignalAccount:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
return [self hasSignalAccountForRecipientId:recipientId];
}
@ -737,23 +737,23 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (NSString *_Nonnull)displayNameForSignalAccount:(SignalAccount *)signalAccount
{
OWSAssert(signalAccount);
OWSAssertDebug(signalAccount);
return [self displayNameForPhoneIdentifier:signalAccount.recipientId];
}
- (NSAttributedString *_Nonnull)formattedDisplayNameForSignalAccount:(SignalAccount *)signalAccount font:(UIFont *)font
{
OWSAssert(signalAccount);
OWSAssert(font);
OWSAssertDebug(signalAccount);
OWSAssertDebug(font);
return [self formattedFullNameForRecipientId:signalAccount.recipientId font:font];
}
- (NSAttributedString *)formattedFullNameForRecipientId:(NSString *)recipientId font:(UIFont *)font
{
OWSAssert(recipientId.length > 0);
OWSAssert(font);
OWSAssertDebug(recipientId.length > 0);
OWSAssertDebug(font);
UIFont *boldFont = [UIFont ows_mediumFontWithSize:font.pointSize];
@ -819,7 +819,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
// Append unique label for contacts with multiple Signal accounts
SignalAccount *_Nullable signalAccount = [self fetchSignalAccountForRecipientId:recipientId];
if (signalAccount && signalAccount.multipleAccountLabelText) {
OWSAssert(signalAccount.multipleAccountLabelText.length > 0);
OWSAssertDebug(signalAccount.multipleAccountLabelText.length > 0);
[formattedName
appendAttributedString:[[NSAttributedString alloc] initWithString:@" (" attributes:normalFontAttributes]];
@ -866,8 +866,8 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
primaryFont:(UIFont *)primaryFont
secondaryFont:(UIFont *)secondaryFont
{
OWSAssert(primaryFont);
OWSAssert(secondaryFont);
OWSAssertDebug(primaryFont);
OWSAssertDebug(secondaryFont);
return [self attributedContactOrProfileNameForPhoneIdentifier:(NSString *)recipientId
primaryAttributes:@{
@ -882,8 +882,8 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
primaryAttributes:(NSDictionary *)primaryAttributes
secondaryAttributes:(NSDictionary *)secondaryAttributes
{
OWSAssert(primaryAttributes.count > 0);
OWSAssert(secondaryAttributes.count > 0);
OWSAssertDebug(primaryAttributes.count > 0);
OWSAssertDebug(secondaryAttributes.count > 0);
// Prefer a saved name from system contacts, if available
NSString *_Nullable savedContactName = [self cachedContactNameForRecipientId:recipientId];
@ -936,7 +936,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (nullable SignalAccount *)fetchSignalAccountForRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
__block SignalAccount *signalAccount = self.signalAccountMap[recipientId];
@ -953,7 +953,7 @@ NSString *const OWSContactsManagerKeyNextFullIntersectionDate = @"OWSContactsMan
- (SignalAccount *)fetchOrBuildSignalAccountForRecipientId:(NSString *)recipientId
{
OWSAssert(recipientId.length > 0);
OWSAssertDebug(recipientId.length > 0);
SignalAccount *_Nullable signalAccount = [self fetchSignalAccountForRecipientId:recipientId];
return (signalAccount ?: [[SignalAccount alloc] initWithRecipientId:recipientId]);

View File

@ -64,9 +64,9 @@ NSString *const kOWSPrimaryStorageOWSContactsSyncingLastMessageKey
return self;
}
OWSAssert(contactsManager);
OWSAssert(messageSender);
OWSAssert(identityManager);
OWSAssertDebug(contactsManager);
OWSAssertDebug(messageSender);
OWSAssertDebug(identityManager);
_contactsManager = contactsManager;
_identityManager = identityManager;

View File

@ -22,9 +22,9 @@ NS_ASSUME_NONNULL_BEGIN
notificationsProtocolBlock:(NotificationsManagerBlock)notificationsManagerBlock
migrationCompletion:(dispatch_block_t)migrationCompletion
{
OWSAssert(callMessageHandlerBlock);
OWSAssert(notificationsManagerBlock);
OWSAssert(migrationCompletion);
OWSAssertDebug(callMessageHandlerBlock);
OWSAssertDebug(notificationsManagerBlock);
OWSAssertDebug(migrationCompletion);
__block OWSBackgroundTask *_Nullable backgroundTask =
[OWSBackgroundTask backgroundTaskWithLabelStr:__PRETTY_FUNCTION__];
@ -58,7 +58,7 @@ NS_ASSUME_NONNULL_BEGIN
migrationCompletion();
OWSAssert(backgroundTask);
OWSAssertDebug(backgroundTask);
backgroundTask = nil;
}];
}];

View File

@ -31,7 +31,7 @@ static Environment *sharedEnvironment = nil;
+ (Environment *)current
{
OWSAssert(sharedEnvironment);
OWSAssertDebug(sharedEnvironment);
return sharedEnvironment;
}
@ -42,8 +42,8 @@ static Environment *sharedEnvironment = nil;
//
// App extensions may be opened multiple times in the same process,
// so statics will persist.
OWSAssert(!sharedEnvironment || !CurrentAppContext().isMainApp);
OWSAssert(environment);
OWSAssertDebug(!sharedEnvironment || !CurrentAppContext().isMainApp);
OWSAssertDebug(environment);
sharedEnvironment = environment;
}
@ -75,35 +75,35 @@ static Environment *sharedEnvironment = nil;
- (OWSContactsManager *)contactsManager
{
OWSAssert(_contactsManager);
OWSAssertDebug(_contactsManager);
return _contactsManager;
}
- (ContactsUpdater *)contactsUpdater
{
OWSAssert(_contactsUpdater);
OWSAssertDebug(_contactsUpdater);
return _contactsUpdater;
}
- (TSNetworkManager *)networkManager
{
OWSAssert(_networkManager);
OWSAssertDebug(_networkManager);
return _networkManager;
}
- (OWSMessageSender *)messageSender
{
OWSAssert(_messageSender);
OWSAssertDebug(_messageSender);
return _messageSender;
}
+ (OWSPreferences *)preferences
{
OWSAssert([Environment current].preferences);
OWSAssertDebug([Environment current].preferences);
return [Environment current].preferences;
}

View File

@ -39,8 +39,8 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob
SystemSoundID newSoundID;
OSStatus status = AudioServicesCreateSystemSoundID((__bridge CFURLRef _Nonnull)(url), &newSoundID);
OWSAssert(status == kAudioServicesNoError);
OWSAssert(newSoundID);
OWSAssertDebug(status == kAudioServicesNoError);
OWSAssertDebug(newSoundID);
_soundID = newSoundID;
return self;
@ -50,7 +50,7 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob
{
OWSLogDebug(@"in dealloc disposing sound: %@", _soundURL.lastPathComponent);
OSStatus status = AudioServicesDisposeSystemSoundID(_soundID);
OWSAssert(status == kAudioServicesNoError);
OWSAssertDebug(status == kAudioServicesNoError);
}
@end
@ -91,7 +91,7 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob
return self;
}
OWSAssert(primaryStorage);
OWSAssertDebug(primaryStorage);
_dbConnection = primaryStorage.newDatabaseConnection;
@ -253,7 +253,7 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob
}
NSURL *_Nullable url = [[NSBundle mainBundle] URLForResource:filename.stringByDeletingPathExtension
withExtension:filename.pathExtension];
OWSAssert(url);
OWSAssertDebug(url);
return url;
}
@ -268,7 +268,7 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob
OWSSystemSound *_Nullable cachedSound = (OWSSystemSound *)[self.cachedSystemSounds getWithKey:cacheKey];
if (cachedSound) {
OWSAssert([cachedSound isKindOfClass:[OWSSystemSound class]]);
OWSAssertDebug([cachedSound isKindOfClass:[OWSSystemSound class]]);
return cachedSound.soundID;
}
@ -314,7 +314,7 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob
- (void)setGlobalNotificationSound:(OWSSound)sound transaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(transaction);
OWSAssertDebug(transaction);
OWSLogInfo(@"Setting global notification sound to: %@", [[self class] displayNameForSound:sound]);
@ -336,7 +336,7 @@ NSString *const kOWSSoundsStorageGlobalNotificationKey = @"kOWSSoundsStorageGlob
if (soundURL) {
return [NSData dataWithContentsOfURL:soundURL];
} else {
OWSAssert(sound == OWSSound_None);
OWSAssertDebug(sound == OWSSound_None);
return [NSData new];
}
}();

View File

@ -37,8 +37,8 @@ NS_ASSUME_NONNULL_BEGIN
// performUpdateCheck must be invoked after Environment has been initialized because
// upgrade process may depend on Environment.
OWSAssert([Environment current]);
OWSAssert(completion);
OWSAssertDebug([Environment current]);
OWSAssertDebug(completion);
NSString *previousVersion = AppVersion.sharedInstance.lastAppVersion;
NSString *currentVersion = AppVersion.sharedInstance.currentAppVersion;

View File

@ -19,7 +19,7 @@ static NSString *const OWS100RemoveTSRecipientsMigrationId = @"100";
- (void)runUpWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(transaction);
OWSAssertDebug(transaction);
NSUInteger legacyRecipientCount = [transaction numberOfKeysInCollection:@"TSRecipient"];
OWSLogWarn(@"Removing %lu objects from TSRecipient collection", (unsigned long)legacyRecipientCount);

View File

@ -24,7 +24,7 @@ static NSString *const OWS101ExistingUsersBlockOnIdentityChangeMigrationId = @"1
- (void)runUpWithTransaction:(YapDatabaseReadWriteTransaction *)transaction
{
OWSAssert(transaction);
OWSAssertDebug(transaction);
OWSFailDebug(@"[OWS101ExistingUsersBlockOnIdentityChange] has been obviated.");
}

Some files were not shown because too many files have changed in this diff Show More