mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
3.3 KiB
Matlab
111 lines
3.3 KiB
Matlab
8 years ago
|
//
|
||
7 years ago
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||
8 years ago
|
//
|
||
|
|
||
|
#import "AddToBlockListViewController.h"
|
||
8 years ago
|
#import "BlockListUIUtils.h"
|
||
4 years ago
|
#import <SessionMessagingKit/SSKEnvironment.h>
|
||
|
#import <SessionMessagingKit/OWSBlockingManager.h>
|
||
5 years ago
|
#import <SignalUtilitiesKit/SignalAccount.h>
|
||
8 years ago
|
|
||
|
NS_ASSUME_NONNULL_BEGIN
|
||
|
|
||
8 years ago
|
@interface AddToBlockListViewController () <SelectRecipientViewControllerDelegate>
|
||
8 years ago
|
|
||
8 years ago
|
@end
|
||
|
|
||
|
#pragma mark -
|
||
|
|
||
|
@implementation AddToBlockListViewController
|
||
|
|
||
|
- (void)loadView
|
||
|
{
|
||
8 years ago
|
self.delegate = self;
|
||
|
|
||
8 years ago
|
[super loadView];
|
||
7 years ago
|
|
||
8 years ago
|
self.title = NSLocalizedString(@"SETTINGS_ADD_TO_BLOCK_LIST_TITLE", @"Title for the 'add to block list' view.");
|
||
|
}
|
||
|
|
||
8 years ago
|
- (NSString *)phoneNumberSectionTitle
|
||
8 years ago
|
{
|
||
8 years ago
|
return NSLocalizedString(@"SETTINGS_ADD_TO_BLOCK_LIST_BLOCK_PHONE_NUMBER_TITLE",
|
||
|
@"Title for the 'block phone number' section of the 'add to block list' view.");
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
- (NSString *)phoneNumberButtonText
|
||
8 years ago
|
{
|
||
8 years ago
|
return NSLocalizedString(@"BLOCK_LIST_VIEW_BLOCK_BUTTON", @"A label for the block button in the block list view");
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
- (NSString *)contactsSectionTitle
|
||
8 years ago
|
{
|
||
8 years ago
|
return NSLocalizedString(@"SETTINGS_ADD_TO_BLOCK_LIST_BLOCK_CONTACT_TITLE",
|
||
|
@"Title for the 'block contact' section of the 'add to block list' view.");
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
- (void)phoneNumberWasSelected:(NSString *)phoneNumber
|
||
8 years ago
|
{
|
||
7 years ago
|
OWSAssertDebug(phoneNumber.length > 0);
|
||
8 years ago
|
|
||
8 years ago
|
__weak AddToBlockListViewController *weakSelf = self;
|
||
8 years ago
|
[BlockListUIUtils showBlockPhoneNumberActionSheet:phoneNumber
|
||
8 years ago
|
fromViewController:self
|
||
5 years ago
|
blockingManager:SSKEnvironment.shared.blockingManager
|
||
8 years ago
|
completionBlock:^(BOOL isBlocked) {
|
||
|
if (isBlocked) {
|
||
8 years ago
|
[weakSelf.navigationController popViewControllerAnimated:YES];
|
||
8 years ago
|
}
|
||
|
}];
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
- (BOOL)canSignalAccountBeSelected:(SignalAccount *)signalAccount
|
||
|
{
|
||
7 years ago
|
OWSAssertDebug(signalAccount);
|
||
8 years ago
|
|
||
5 years ago
|
return ![SSKEnvironment.shared.blockingManager isRecipientIdBlocked:signalAccount.recipientId];
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
- (void)signalAccountWasSelected:(SignalAccount *)signalAccount
|
||
8 years ago
|
{
|
||
7 years ago
|
OWSAssertDebug(signalAccount);
|
||
8 years ago
|
|
||
8 years ago
|
__weak AddToBlockListViewController *weakSelf = self;
|
||
5 years ago
|
if ([SSKEnvironment.shared.blockingManager isRecipientIdBlocked:signalAccount.recipientId]) {
|
||
7 years ago
|
OWSFailDebug(@"Cannot add already blocked user to block list.");
|
||
8 years ago
|
return;
|
||
|
}
|
||
8 years ago
|
[BlockListUIUtils showBlockSignalAccountActionSheet:signalAccount
|
||
|
fromViewController:self
|
||
5 years ago
|
blockingManager:SSKEnvironment.shared.blockingManager
|
||
8 years ago
|
completionBlock:^(BOOL isBlocked) {
|
||
|
if (isBlocked) {
|
||
|
[weakSelf.navigationController popViewControllerAnimated:YES];
|
||
|
}
|
||
|
}];
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
- (BOOL)shouldHideLocalNumber
|
||
|
{
|
||
|
return YES;
|
||
|
}
|
||
8 years ago
|
|
||
8 years ago
|
- (BOOL)shouldHideContacts
|
||
|
{
|
||
|
return NO;
|
||
|
}
|
||
|
|
||
8 years ago
|
- (BOOL)shouldValidatePhoneNumbers
|
||
8 years ago
|
{
|
||
8 years ago
|
return NO;
|
||
8 years ago
|
}
|
||
|
|
||
8 years ago
|
- (nullable NSString *)accessoryMessageForSignalAccount:(SignalAccount *)signalAccount
|
||
|
{
|
||
|
return nil;
|
||
|
}
|
||
|
|
||
8 years ago
|
@end
|
||
|
|
||
|
NS_ASSUME_NONNULL_END
|