From 8168641c4224d508b528e16334aa820a8bb8a487 Mon Sep 17 00:00:00 2001 From: giomfo Date: Tue, 3 May 2016 18:29:54 +0200 Subject: [PATCH 1/7] Report abusif content and Ignore user. - Room member: Add new option Ignore to ignore content from a room member - Chat screen: Add report option in the contextual per-message menu + Option to ignore the event sender --- Vector/Assets/en.lproj/Vector.strings | 8 +- .../RoomMemberDetailsViewController.m | 9 + Vector/ViewController/RoomViewController.m | 170 +++++++++++++----- 3 files changed, 143 insertions(+), 44 deletions(-) diff --git a/Vector/Assets/en.lproj/Vector.strings b/Vector/Assets/en.lproj/Vector.strings index 215aad6a8..44f8f7b79 100644 --- a/Vector/Assets/en.lproj/Vector.strings +++ b/Vector/Assets/en.lproj/Vector.strings @@ -121,8 +121,9 @@ "room_participants_action_invite" = "Invite"; "room_participants_action_leave" = "Leave this room"; "room_participants_action_remove" = "Remove from this room"; -"room_participants_action_ban" = "Block"; -"room_participants_action_unban" = "Unblock"; +"room_participants_action_ban" = "Ban"; +"room_participants_action_unban" = "Unban"; +"room_participants_action_ignore" = "Ignore"; "room_participants_action_set_default_power_level" = "Reset to normal user"; "room_participants_action_set_moderator" = "Make moderator"; "room_participants_action_set_admin" = "Make admin"; @@ -144,6 +145,9 @@ "room_event_action_share" = "Share"; "room_event_action_redact" = "Redact"; "room_event_action_permalink" = "Permalink"; +"room_event_action_report" = "Report"; +"room_event_action_report_prompt_reason" = "Enter a description of the problem content"; +"room_event_action_report_prompt_ignore_user" = "Do you want to ignore content from this user"; "room_event_action_save" = "Save"; "room_event_action_resend" = "Resend"; "room_event_action_delete" = "Delete"; diff --git a/Vector/ViewController/RoomMemberDetailsViewController.m b/Vector/ViewController/RoomMemberDetailsViewController.m index f3d8b50e8..a51bc08b2 100644 --- a/Vector/ViewController/RoomMemberDetailsViewController.m +++ b/Vector/ViewController/RoomMemberDetailsViewController.m @@ -358,6 +358,12 @@ { [actionsArray addObject:@(MXKRoomMemberDetailsActionBan)]; } + + // Check whether the option Ignore may be presented + if (self.mxRoomMember.membership == MXMembershipJoin /*FIXME: is he already ignored ?*/) + { + [actionsArray addObject:@(MXKRoomMemberDetailsActionIgnore)]; + } break; } case MXMembershipLeave: @@ -414,6 +420,9 @@ case MXKRoomMemberDetailsActionUnban: title = NSLocalizedStringFromTable(@"room_participants_action_unban", @"Vector", nil); break; + case MXKRoomMemberDetailsActionIgnore: + title = NSLocalizedStringFromTable(@"room_participants_action_ignore", @"Vector", nil); + break; case MXKRoomMemberDetailsActionSetDefaultPowerLevel: title = NSLocalizedStringFromTable(@"room_participants_action_set_default_power_level", @"Vector", nil); break; diff --git a/Vector/ViewController/RoomViewController.m b/Vector/ViewController/RoomViewController.m index 3b43b5f6e..973a3a0b9 100644 --- a/Vector/ViewController/RoomViewController.m +++ b/Vector/ViewController/RoomViewController.m @@ -97,8 +97,6 @@ CGPoint startScrollingPoint; } -@property (strong, nonatomic) MXKAlert *currentAlert; - @end @implementation RoomViewController @@ -276,10 +274,10 @@ [super viewWillDisappear:animated]; // hide action - if (self.currentAlert) + if (currentAlert) { - [self.currentAlert dismiss:NO]; - self.currentAlert = nil; + [currentAlert dismiss:NO]; + currentAlert = nil; } [self removeTypingNotificationsListener]; @@ -569,10 +567,10 @@ { self.navigationItem.rightBarButtonItem.enabled = NO; - if (self.currentAlert) + if (currentAlert) { - [self.currentAlert dismiss:NO]; - self.currentAlert = nil; + [currentAlert dismiss:NO]; + currentAlert = nil; } if (customizedRoomDataSource) @@ -1081,19 +1079,19 @@ if (selectedEvent) { - if (self.currentAlert) + if (currentAlert) { - [self.currentAlert dismiss:NO]; - self.currentAlert = nil; + [currentAlert dismiss:NO]; + currentAlert = nil; } __weak __typeof(self) weakSelf = self; - self.currentAlert = [[MXKAlert alloc] initWithTitle:nil message:nil style:MXKAlertStyleActionSheet]; + currentAlert = [[MXKAlert alloc] initWithTitle:nil message:nil style:MXKAlertStyleActionSheet]; // Add actions for a failed event if (selectedEvent.mxkState == MXKEventStateSendingFailed) { - [self.currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_resend", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + [currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_resend", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { __strong __typeof(weakSelf)strongSelf = weakSelf; [strongSelf cancelEventSelection]; @@ -1103,7 +1101,7 @@ }]; - [self.currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_delete", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + [currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_delete", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { __strong __typeof(weakSelf)strongSelf = weakSelf; [strongSelf cancelEventSelection]; @@ -1127,7 +1125,7 @@ selectedComponent = nil; } - [self.currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_copy", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + [currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_copy", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { __strong __typeof(weakSelf)strongSelf = weakSelf; [strongSelf cancelEventSelection]; @@ -1136,7 +1134,7 @@ }]; - [self.currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_share", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + [currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_share", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { __strong __typeof(weakSelf)strongSelf = weakSelf; [strongSelf cancelEventSelection]; @@ -1157,7 +1155,7 @@ { if (attachment.type == MXKAttachmentTypeImage || attachment.type == MXKAttachmentTypeVideo) { - [self.currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_save", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + [currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_save", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { __strong __typeof(weakSelf)strongSelf = weakSelf; [strongSelf cancelEventSelection]; @@ -1185,7 +1183,7 @@ }]; } - [self.currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_copy", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + [currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_copy", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { __strong __typeof(weakSelf)strongSelf = weakSelf; [strongSelf cancelEventSelection]; @@ -1211,7 +1209,7 @@ [roomBubbleTableViewCell startProgressUI]; }]; - [self.currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_share", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + [currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_share", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { __strong __typeof(weakSelf)strongSelf = weakSelf; [strongSelf cancelEventSelection]; @@ -1249,7 +1247,7 @@ NSString *uploadId = roomBubbleTableViewCell.bubbleData.attachment.actualURL; if ([MXKMediaManager existingUploaderWithId:uploadId]) { - [self.currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_cancel_upload", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + [currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_cancel_upload", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { __strong __typeof(weakSelf)strongSelf = weakSelf; [strongSelf cancelEventSelection]; @@ -1274,7 +1272,7 @@ NSString *cacheFilePath = roomBubbleTableViewCell.bubbleData.attachment.cacheFilePath; if ([MXKMediaManager existingDownloaderWithOutputFilePath:cacheFilePath]) { - [self.currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_cancel_download", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + [currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_cancel_download", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { __strong __typeof(weakSelf)strongSelf = weakSelf; [strongSelf cancelEventSelection]; @@ -1292,7 +1290,7 @@ } } - [self.currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_redact", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + [currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_redact", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { __strong __typeof(weakSelf)strongSelf = weakSelf; [strongSelf cancelEventSelection]; @@ -1316,7 +1314,7 @@ }]; }]; - [self.currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_permalink", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + [currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_permalink", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { __strong __typeof(weakSelf)strongSelf = weakSelf; [strongSelf cancelEventSelection]; @@ -1332,9 +1330,97 @@ [[UIPasteboard generalPasteboard] setString:permalink]; }]; + + [currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_event_action_report", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + + __strong __typeof(weakSelf)strongSelf = weakSelf; + [strongSelf cancelEventSelection]; + + // Prompt user to enter a description of the problem content. + MXKAlert *reasonAlert = [[MXKAlert alloc] initWithTitle:NSLocalizedStringFromTable(@"room_event_action_report_prompt_reason", @"Vector", nil) message:nil style:MXKAlertStyleAlert]; + + [reasonAlert addTextFieldWithConfigurationHandler:^(UITextField *textField) { + textField.secureTextEntry = NO; + textField.placeholder = nil; + textField.keyboardType = UIKeyboardTypeDefault; + }]; + + [reasonAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"ok"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + + UITextField *textField = [alert textFieldAtIndex:0]; + + __strong __typeof(weakSelf)strongSelf = weakSelf; + strongSelf->currentAlert = nil; + + [strongSelf startActivityIndicator]; + + [strongSelf.roomDataSource.room reportEvent:selectedEvent.eventId score:-100 reason:textField.text success:^{ + + __strong __typeof(weakSelf)strongSelf = weakSelf; + [strongSelf stopActivityIndicator]; + + // Prompt user to ignore content from this user + MXKAlert *ignoreAlert = [[MXKAlert alloc] initWithTitle:NSLocalizedStringFromTable(@"room_event_action_report_prompt_ignore_user", @"Vector", nil) message:nil style:MXKAlertStyleAlert]; + + [ignoreAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"yes"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + + __strong __typeof(weakSelf)strongSelf = weakSelf; + strongSelf->currentAlert = nil; + + [strongSelf startActivityIndicator]; + + // Add the user to the blacklist: ignored users + [strongSelf.mainSession ignoreUser:selectedEvent.sender success:^{ + + __strong __typeof(weakSelf)strongSelf = weakSelf; + [strongSelf stopActivityIndicator]; + + } failure:^(NSError *error) { + + __strong __typeof(weakSelf)strongSelf = weakSelf; + [strongSelf stopActivityIndicator]; + + NSLog(@"[Vector RoomVC] Ignore user (%@) failed", selectedEvent.sender); + //Alert user + [[AppDelegate theDelegate] showErrorAsAlert:error]; + + }]; + + }]; + + ignoreAlert.cancelButtonIndex = [ignoreAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"no"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + + __strong __typeof(weakSelf)strongSelf = weakSelf; + strongSelf->currentAlert = nil; + }]; + + strongSelf->currentAlert = ignoreAlert; + [ignoreAlert showInViewController:strongSelf]; + + } failure:^(NSError *error) { + + __strong __typeof(weakSelf)strongSelf = weakSelf; + [strongSelf stopActivityIndicator]; + + NSLog(@"[Vector RoomVC] Report event (%@) failed", selectedEvent.eventId); + //Alert user + [[AppDelegate theDelegate] showErrorAsAlert:error]; + + }]; + }]; + + reasonAlert.cancelButtonIndex = [reasonAlert addActionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + + __strong __typeof(weakSelf)strongSelf = weakSelf; + strongSelf->currentAlert = nil; + }]; + + strongSelf->currentAlert = reasonAlert; + [reasonAlert showInViewController:strongSelf]; + }]; } - self.currentAlert.cancelButtonIndex = [self.currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"cancel", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + currentAlert.cancelButtonIndex = [currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"cancel", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { __strong __typeof(weakSelf)strongSelf = weakSelf; [strongSelf cancelEventSelection]; @@ -1342,14 +1428,14 @@ }]; // Do not display empty action sheet - if (self.currentAlert.cancelButtonIndex) + if (currentAlert.cancelButtonIndex) { - self.currentAlert.sourceView = roomBubbleTableViewCell; - [self.currentAlert showInViewController:self]; + currentAlert.sourceView = roomBubbleTableViewCell; + [currentAlert showInViewController:self]; } else { - self.currentAlert = nil; + currentAlert = nil; } } } @@ -1392,10 +1478,10 @@ - (void)cancelEventSelection { - if (self.currentAlert) + if (currentAlert) { - [self.currentAlert dismiss:NO]; - self.currentAlert = nil; + [currentAlert dismiss:NO]; + currentAlert = nil; } customizedRoomDataSource.selectedEventId = nil; @@ -1883,23 +1969,23 @@ } andIconTapGesture:^{ - if (self.currentAlert) + if (currentAlert) { - [self.currentAlert dismiss:NO]; + [currentAlert dismiss:NO]; } __weak __typeof(self) weakSelf = self; - self.currentAlert = [[MXKAlert alloc] initWithTitle:nil message:nil style:MXKAlertStyleActionSheet]; + currentAlert = [[MXKAlert alloc] initWithTitle:nil message:nil style:MXKAlertStyleActionSheet]; - [self.currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_resend_unsent_messages", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + [currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_resend_unsent_messages", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { __strong __typeof(weakSelf)strongSelf = weakSelf; [strongSelf resendAllUnsentMessages]; - strongSelf.currentAlert = nil; + strongSelf->currentAlert = nil; }]; - [self.currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_delete_unsent_messages", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + [currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"room_delete_unsent_messages", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { __strong __typeof(weakSelf)strongSelf = weakSelf; @@ -1916,18 +2002,18 @@ index ++; } } - strongSelf.currentAlert = nil; + strongSelf->currentAlert = nil; }]; - self.currentAlert.cancelButtonIndex = [self.currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"cancel", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { + currentAlert.cancelButtonIndex = [currentAlert addActionWithTitle:NSLocalizedStringFromTable(@"cancel", @"Vector", nil) style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) { __strong __typeof(weakSelf)strongSelf = weakSelf; - strongSelf.currentAlert = nil; + strongSelf->currentAlert = nil; }]; - self.currentAlert.sourceView = roomActivitiesView; - [self.currentAlert showInViewController:self]; + currentAlert.sourceView = roomActivitiesView; + [currentAlert showInViewController:self]; }]; } From 658b3a0eb7ae15ed18da702d864d9ba4949d5398 Mon Sep 17 00:00:00 2001 From: giomfo Date: Tue, 3 May 2016 21:53:04 +0200 Subject: [PATCH 2/7] Report abusif content and Ignore user. Rename "Ban" with "Ban from this room" --- Vector/Assets/en.lproj/Vector.strings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vector/Assets/en.lproj/Vector.strings b/Vector/Assets/en.lproj/Vector.strings index 44f8f7b79..4a8229bc5 100644 --- a/Vector/Assets/en.lproj/Vector.strings +++ b/Vector/Assets/en.lproj/Vector.strings @@ -121,7 +121,7 @@ "room_participants_action_invite" = "Invite"; "room_participants_action_leave" = "Leave this room"; "room_participants_action_remove" = "Remove from this room"; -"room_participants_action_ban" = "Ban"; +"room_participants_action_ban" = "Ban from this room"; "room_participants_action_unban" = "Unban"; "room_participants_action_ignore" = "Ignore"; "room_participants_action_set_default_power_level" = "Reset to normal user"; From e12f7220ae3dad14cd5e34ecfc2e0792e341e6d3 Mon Sep 17 00:00:00 2001 From: giomfo Date: Wed, 4 May 2016 10:54:46 +0200 Subject: [PATCH 3/7] Report abusif content and Ignore user. Add unignore option --- Vector/Assets/en.lproj/Vector.strings | 9 +++++---- .../RoomMemberDetailsViewController.m | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Vector/Assets/en.lproj/Vector.strings b/Vector/Assets/en.lproj/Vector.strings index 4a8229bc5..8181e5517 100644 --- a/Vector/Assets/en.lproj/Vector.strings +++ b/Vector/Assets/en.lproj/Vector.strings @@ -123,7 +123,8 @@ "room_participants_action_remove" = "Remove from this room"; "room_participants_action_ban" = "Ban from this room"; "room_participants_action_unban" = "Unban"; -"room_participants_action_ignore" = "Ignore"; +"room_participants_action_ignore" = "Hide the user's messages"; +"room_participants_action_unignore" = "Show the user's messages"; "room_participants_action_set_default_power_level" = "Reset to normal user"; "room_participants_action_set_moderator" = "Make moderator"; "room_participants_action_set_admin" = "Make admin"; @@ -145,9 +146,9 @@ "room_event_action_share" = "Share"; "room_event_action_redact" = "Redact"; "room_event_action_permalink" = "Permalink"; -"room_event_action_report" = "Report"; -"room_event_action_report_prompt_reason" = "Enter a description of the problem content"; -"room_event_action_report_prompt_ignore_user" = "Do you want to ignore content from this user"; +"room_event_action_report" = "Report to moderator"; +"room_event_action_report_prompt_reason" = "Reason for reporting this content"; +"room_event_action_report_prompt_ignore_user" = "The content was successfully reported. Do you wish to hide all messages from this user?"; "room_event_action_save" = "Save"; "room_event_action_resend" = "Resend"; "room_event_action_delete" = "Delete"; diff --git a/Vector/ViewController/RoomMemberDetailsViewController.m b/Vector/ViewController/RoomMemberDetailsViewController.m index a51bc08b2..84002501e 100644 --- a/Vector/ViewController/RoomMemberDetailsViewController.m +++ b/Vector/ViewController/RoomMemberDetailsViewController.m @@ -360,9 +360,17 @@ } // Check whether the option Ignore may be presented - if (self.mxRoomMember.membership == MXMembershipJoin /*FIXME: is he already ignored ?*/) + if (self.mxRoomMember.membership == MXMembershipJoin) { - [actionsArray addObject:@(MXKRoomMemberDetailsActionIgnore)]; + //FIXME: is he already ignored ? + // if () + { + [actionsArray addObject:@(MXKRoomMemberDetailsActionIgnore)]; + } + // else + // { + // [actionsArray addObject:@(MXKRoomMemberDetailsActionUnignore)]; + // } } break; } @@ -423,6 +431,9 @@ case MXKRoomMemberDetailsActionIgnore: title = NSLocalizedStringFromTable(@"room_participants_action_ignore", @"Vector", nil); break; + case MXKRoomMemberDetailsActionUnignore: + title = NSLocalizedStringFromTable(@"room_participants_action_unignore", @"Vector", nil); + break; case MXKRoomMemberDetailsActionSetDefaultPowerLevel: title = NSLocalizedStringFromTable(@"room_participants_action_set_default_power_level", @"Vector", nil); break; From 29484a28b62b5da4ac709005add990e0a397b97e Mon Sep 17 00:00:00 2001 From: giomfo Date: Wed, 4 May 2016 11:21:32 +0200 Subject: [PATCH 4/7] Report abusif content and Ignore user. Apply Matthew's suggestions (see https://github.com/vector-im/vector-ios/issues/295) --- Vector/Assets/en.lproj/Vector.strings | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Vector/Assets/en.lproj/Vector.strings b/Vector/Assets/en.lproj/Vector.strings index 8181e5517..a15e9d973 100644 --- a/Vector/Assets/en.lproj/Vector.strings +++ b/Vector/Assets/en.lproj/Vector.strings @@ -123,8 +123,8 @@ "room_participants_action_remove" = "Remove from this room"; "room_participants_action_ban" = "Ban from this room"; "room_participants_action_unban" = "Unban"; -"room_participants_action_ignore" = "Hide the user's messages"; -"room_participants_action_unignore" = "Show the user's messages"; +"room_participants_action_ignore" = "Hide all messages from this user"; +"room_participants_action_unignore" = "Show all messages from this user"; "room_participants_action_set_default_power_level" = "Reset to normal user"; "room_participants_action_set_moderator" = "Make moderator"; "room_participants_action_set_admin" = "Make admin"; @@ -146,9 +146,9 @@ "room_event_action_share" = "Share"; "room_event_action_redact" = "Redact"; "room_event_action_permalink" = "Permalink"; -"room_event_action_report" = "Report to moderator"; +"room_event_action_report" = "Report content"; "room_event_action_report_prompt_reason" = "Reason for reporting this content"; -"room_event_action_report_prompt_ignore_user" = "The content was successfully reported. Do you wish to hide all messages from this user?"; +"room_event_action_report_prompt_ignore_user" = "Do you want to hide all messages from this user?"; "room_event_action_save" = "Save"; "room_event_action_resend" = "Resend"; "room_event_action_delete" = "Delete"; From 1d7dcff471f01845c6072c11432eb0d325722e67 Mon Sep 17 00:00:00 2001 From: manuroe Date: Wed, 4 May 2016 16:44:44 +0200 Subject: [PATCH 5/7] Ignore user: [MXSession isUserIgnored] now exists --- .../RoomMemberDetailsViewController.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Vector/ViewController/RoomMemberDetailsViewController.m b/Vector/ViewController/RoomMemberDetailsViewController.m index 84002501e..daeb334a1 100644 --- a/Vector/ViewController/RoomMemberDetailsViewController.m +++ b/Vector/ViewController/RoomMemberDetailsViewController.m @@ -362,18 +362,18 @@ // Check whether the option Ignore may be presented if (self.mxRoomMember.membership == MXMembershipJoin) { - //FIXME: is he already ignored ? - // if () + // is he already ignored ? + if (![self.mainSession isUserIgnored:self.mxRoomMember.userId]) { [actionsArray addObject:@(MXKRoomMemberDetailsActionIgnore)]; } - // else - // { - // [actionsArray addObject:@(MXKRoomMemberDetailsActionUnignore)]; - // } + else + { + [actionsArray addObject:@(MXKRoomMemberDetailsActionUnignore)]; + } } break; - } + } case MXMembershipLeave: { // Check conditions to be able to invite someone From cccae814a004eafbc51bd2de737f30261340ca36 Mon Sep 17 00:00:00 2001 From: manuroe Date: Wed, 4 May 2016 17:37:06 +0200 Subject: [PATCH 6/7] Ignore user: ignoreUsers method has been updated --- Vector/ViewController/RoomViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vector/ViewController/RoomViewController.m b/Vector/ViewController/RoomViewController.m index d04ba3cd6..75e43f472 100644 --- a/Vector/ViewController/RoomViewController.m +++ b/Vector/ViewController/RoomViewController.m @@ -1379,7 +1379,7 @@ [strongSelf startActivityIndicator]; // Add the user to the blacklist: ignored users - [strongSelf.mainSession ignoreUser:selectedEvent.sender success:^{ + [strongSelf.mainSession ignoreUsers:@[selectedEvent.sender] success:^{ __strong __typeof(weakSelf)strongSelf = weakSelf; [strongSelf stopActivityIndicator]; From bdb90059348482464780138dea021db0207e3124 Mon Sep 17 00:00:00 2001 From: manuroe Date: Wed, 4 May 2016 18:35:59 +0200 Subject: [PATCH 7/7] Ignore user: Reload entirely the app when a user has been ignored or unignored --- Vector/AppDelegate.m | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Vector/AppDelegate.m b/Vector/AppDelegate.m index cd87ffa34..ad04d246d 100644 --- a/Vector/AppDelegate.m +++ b/Vector/AppDelegate.m @@ -561,8 +561,11 @@ // Dispatch the completion in order to let navigation stack refresh itself // It is required to display the auth VC at startup dispatch_async(dispatch_get_main_queue(), ^{ - completion(); - }); + if (completion) + { + completion(); + } + }); } } @@ -1164,6 +1167,15 @@ [self logout]; } }]; + + [[NSNotificationCenter defaultCenter] addObserverForName:kMXSessionIgnoredUsersDidChangeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull notif) { + + NSLog(@"[AppDelegate] kMXSessionIgnoredUsersDidChangeNotification received. Reload the app"); + + // Reload entirely the app when a user has been ignored or unignored + [[AppDelegate theDelegate] reloadMatrixSessions:YES]; + + }]; // Observe settings changes [[MXKAppSettings standardAppSettings] addObserver:self forKeyPath:@"showAllEventsInRoomHistory" options:0 context:nil];