MESSENGER-3152 ignored users in own view

This commit is contained in:
Frank Rotermund
2022-07-14 13:03:00 +02:00
parent 72f132afe8
commit 9a0b7d9c81
5 changed files with 258 additions and 67 deletions
+81 -62
View File
@@ -132,6 +132,11 @@ typedef NS_ENUM(NSUInteger, NOTIFICATION_SETTINGS)
NOTIFICATION_SETTINGS_OTHER_SETTINGS_INDEX,
};
typedef NS_ENUM(NSUInteger, IGNORED_USERS)
{
IGNORED_USERS_INDEX
};
typedef NS_ENUM(NSUInteger, CALLS_ENABLE_STUN_SERVER)
{
CALLS_ENABLE_STUN_SERVER_FALLBACK_INDEX = 0
@@ -587,9 +592,14 @@ ThreadsBetaCoordinatorBridgePresenterDelegate>
if (session.ignoredUsers.count)
{
Section *sectionIgnoredUsers = [Section sectionWithTag:SECTION_TAG_IGNORED_USERS];
for (NSInteger index = 0; index < session.ignoredUsers.count; index++)
{
[sectionIgnoredUsers addRowWithTag:index];
if (BwiBuildSettings.bwiBetterIgnoredUsers) {
[sectionIgnoredUsers addRowWithTag:IGNORED_USERS_INDEX];
} else {
for (NSInteger index = 0; index < session.ignoredUsers.count; index++)
{
[sectionIgnoredUsers addRowWithTag:index];
}
}
sectionIgnoredUsers.headerTitle = [VectorL10n settingsIgnoredUsers];
[tmpSections addObject:sectionIgnoredUsers];
@@ -2484,9 +2494,11 @@ ThreadsBetaCoordinatorBridgePresenterDelegate>
else if (section == SECTION_TAG_IGNORED_USERS)
{
MXKTableViewCell *ignoredUserCell = [self getDefaultTableViewCell:tableView];
ignoredUserCell.textLabel.text = session.ignoredUsers[row];
if (BwiBuildSettings.bwiBetterIgnoredUsers) {
ignoredUserCell.textLabel.text = [VectorL10n settingsIgnoredUsers];
} else {
ignoredUserCell.textLabel.text = session.ignoredUsers[row];
}
cell = ignoredUserCell;
}
else if (section == SECTION_TAG_LOCAL_CONTACTS)
@@ -3124,64 +3136,68 @@ ThreadsBetaCoordinatorBridgePresenterDelegate>
}
else if (section == SECTION_TAG_IGNORED_USERS)
{
MXSession* session = self.mainSession;
if (BwiBuildSettings.bwiBetterIgnoredUsers) {
[self bwiShowIgnoredUsersScreen];
} else {
MXSession* session = self.mainSession;
NSString *ignoredUserId = session.ignoredUsers[row];
NSString *ignoredUserId = session.ignoredUsers[row];
if (ignoredUserId)
{
[currentAlert dismissViewControllerAnimated:NO completion:nil];
if (ignoredUserId)
{
[currentAlert dismissViewControllerAnimated:NO completion:nil];
__weak typeof(self) weakSelf = self;
UIAlertController *unignorePrompt = [UIAlertController alertControllerWithTitle:[VectorL10n settingsUnignoreUser:ignoredUserId] message:nil preferredStyle:UIAlertControllerStyleAlert];
__weak typeof(self) weakSelf = self;
UIAlertController *unignorePrompt = [UIAlertController alertControllerWithTitle:[VectorL10n settingsUnignoreUser:ignoredUserId] message:nil preferredStyle:UIAlertControllerStyleAlert];
[unignorePrompt addAction:[UIAlertAction actionWithTitle:[VectorL10n yes]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
if (weakSelf)
{
typeof(self) self = weakSelf;
self->currentAlert = nil;
[unignorePrompt addAction:[UIAlertAction actionWithTitle:[VectorL10n yes]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
MXSession* session = self.mainSession;
if (weakSelf)
{
typeof(self) self = weakSelf;
self->currentAlert = nil;
MXSession* session = self.mainSession;
// Remove the member from the ignored user list
[self startActivityIndicator];
[session unIgnoreUsers:@[ignoredUserId] success:^{
[self stopActivityIndicator];
} failure:^(NSError *error) {
[self stopActivityIndicator];
MXLogDebug(@"[SettingsViewController] Unignore %@ failed", ignoredUserId);
NSString *myUserId = session.myUser.userId;
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error userInfo:myUserId ? @{kMXKErrorUserIdKey: myUserId} : nil];
}];
}
// Remove the member from the ignored user list
[self startActivityIndicator];
[session unIgnoreUsers:@[ignoredUserId] success:^{
[self stopActivityIndicator];
} failure:^(NSError *error) {
[self stopActivityIndicator];
MXLogDebug(@"[SettingsViewController] Unignore %@ failed", ignoredUserId);
NSString *myUserId = session.myUser.userId;
[[NSNotificationCenter defaultCenter] postNotificationName:kMXKErrorNotification object:error userInfo:myUserId ? @{kMXKErrorUserIdKey: myUserId} : nil];
}];
}
}]];
[unignorePrompt addAction:[UIAlertAction actionWithTitle:[VectorL10n no]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
if (weakSelf)
{
typeof(self) self = weakSelf;
self->currentAlert = nil;
}
}]];
[unignorePrompt mxk_setAccessibilityIdentifier: @"SettingsVCUnignoreAlert"];
[self presentViewController:unignorePrompt animated:YES completion:nil];
currentAlert = unignorePrompt;
}]];
[unignorePrompt addAction:[UIAlertAction actionWithTitle:[VectorL10n no]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
if (weakSelf)
{
typeof(self) self = weakSelf;
self->currentAlert = nil;
}
}]];
[unignorePrompt mxk_setAccessibilityIdentifier: @"SettingsVCUnignoreAlert"];
[self presentViewController:unignorePrompt animated:YES completion:nil];
currentAlert = unignorePrompt;
}
}
}
else if (section == SECTION_TAG_ABOUT)
@@ -4417,10 +4433,8 @@ ThreadsBetaCoordinatorBridgePresenterDelegate>
- (void)showNotificationTimesSettings
{
if (@available(iOS 14.0, *)) {
UIViewController *notificationTimesViewController = [NotificationTimesViewController makeViewControllerWithSession:self.mainSession];
[self pushViewController:notificationTimesViewController];
}
UIViewController *notificationTimesViewController = [NotificationTimesViewController makeViewControllerWithSession:self.mainSession];
[self pushViewController:notificationTimesViewController];
}
- (void)toggleEnableRoomMessageBubbles:(UISwitch *)sender
@@ -5450,6 +5464,11 @@ ThreadsBetaCoordinatorBridgePresenterDelegate>
return [[[ServerDowntimeDefaultService alloc] init] downtimeTextColor];
}
- (void) bwiShowIgnoredUsersScreen {
UIViewController *ignoredUsersViewController = [IgnoredUsersViewController makeViewControllerWithSession:self.mainSession];
[self pushViewController:ignoredUsersViewController];
}
#pragma mark - ThreadsBetaCoordinatorBridgePresenterDelegate
- (void)threadsBetaCoordinatorBridgePresenterDelegateDidTapEnable:(ThreadsBetaCoordinatorBridgePresenter *)coordinatorBridgePresenter