diff --git a/CHANGES.rst b/CHANGES.rst index 0c6d4cf8a..28d9546b1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,7 @@ Improvements: * Prompt to accept integration manager policies on use (#2600). * Widgets: Whitelist [MSC1961](https://github.com/matrix-org/matrix-doc/pull/1961) widget urls * i18n: Enable Polish (pl). + * Room members: third-party invites can now be revoked Changes in 0.9.2 (2019-08-08) =============================================== diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index 51f8928dd..ce572c9b5 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -212,7 +212,7 @@ "room_participants_leave_prompt_msg" = "Are you sure you want to leave the room?"; "room_participants_remove_prompt_title" = "Confirmation"; "room_participants_remove_prompt_msg" = "Are you sure you want to remove %@ from this chat?"; -"room_participants_remove_third_party_invite_msg" = "Remove third-party invite is not supported yet until the api exists"; +"room_participants_remove_third_party_invite_prompt_msg" = "Are you sure you want to revoke this invite?"; "room_participants_invite_prompt_title" = "Confirmation"; "room_participants_invite_prompt_msg" = "Are you sure you want to invite %@ to this chat?"; "room_participants_filter_room_members" = "Filter room members"; diff --git a/Riot/Modules/Room/Members/RoomParticipantsViewController.m b/Riot/Modules/Room/Members/RoomParticipantsViewController.m index dfb55b6fc..4ed295300 100644 --- a/Riot/Modules/Room/Members/RoomParticipantsViewController.m +++ b/Riot/Modules/Room/Members/RoomParticipantsViewController.m @@ -798,7 +798,9 @@ - (void)addRoomThirdPartyInviteToParticipants:(MXRoomThirdPartyInvite*)roomThirdPartyInvite roomState:(MXRoomState*)roomState { // If the homeserver has converted the 3pid invite into a room member, do no show it - if (![roomState memberWithThirdPartyInviteToken:roomThirdPartyInvite.token]) + // If the invite has been revoked (null display name), do not show it too. + if (![roomState memberWithThirdPartyInviteToken:roomThirdPartyInvite.token] + && roomThirdPartyInvite.displayname) { Contact *contact = [[Contact alloc] initMatrixContactWithDisplayName:roomThirdPartyInvite.displayname andMatrixID:nil]; contact.isThirdPartyInvite = YES; @@ -1373,8 +1375,6 @@ if (section == participantsSection || section == invitedSection) { - __weak typeof(self) weakSelf = self; - if (currentAlert) { [currentAlert dismissViewControllerAnimated:NO completion:nil]; @@ -1464,6 +1464,7 @@ if (row < participants.count) { Contact *contact = participants[row]; + MXWeakify(self); if (contact.mxMember) { @@ -1479,11 +1480,8 @@ style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) { - if (weakSelf) - { - typeof(self) self = weakSelf; - self->currentAlert = nil; - } + MXStrongifyAndReturnIfNil(self); + self->currentAlert = nil; }]]; @@ -1491,51 +1489,80 @@ style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { - if (weakSelf) - { - typeof(self) self = weakSelf; - self->currentAlert = nil; - - [self addPendingActionMask]; - [self.mxRoom kickUser:memberUserId - reason:nil - success:^{ - - [self removePendingActionMask]; - - [participants removeObjectAtIndex:row]; - - // Refresh display - [self.tableView reloadData]; - - } failure:^(NSError *error) { - - [self removePendingActionMask]; - NSLog(@"[RoomParticipantsVC] Kick %@ failed", memberUserId); - // Alert user - [[AppDelegate theDelegate] showErrorAsAlert:error]; - - }]; - } + MXStrongifyAndReturnIfNil(self); + self->currentAlert = nil; + + [self addPendingActionMask]; + MXWeakify(self); + [self.mxRoom kickUser:memberUserId + reason:nil + success:^{ + + MXStrongifyAndReturnIfNil(self); + [self removePendingActionMask]; + + [participants removeObjectAtIndex:row]; + + // Refresh display + [self.tableView reloadData]; + + } failure:^(NSError *error) { + + MXStrongifyAndReturnIfNil(self); + [self removePendingActionMask]; + NSLog(@"[RoomParticipantsVC] Kick %@ failed", memberUserId); + // Alert user + [[AppDelegate theDelegate] showErrorAsAlert:error]; + + }]; }]]; } - else + else if (contact.mxThirdPartyInvite) { - // This is a third-party invite, it could not be removed until the api exists + // This is a third-party invite currentAlert = [UIAlertController alertControllerWithTitle:nil - message:NSLocalizedStringFromTable(@"room_participants_remove_third_party_invite_msg", @"Vector", nil) + message:NSLocalizedStringFromTable(@"room_participants_remove_third_party_invite_prompt_msg", @"Vector", nil) preferredStyle:UIAlertControllerStyleAlert]; [currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"cancel"] style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) { - if (weakSelf) - { - typeof(self) self = weakSelf; - self->currentAlert = nil; - } + MXStrongifyAndReturnIfNil(self); + self->currentAlert = nil; + + }]]; + + [currentAlert addAction:[UIAlertAction actionWithTitle:NSLocalizedStringFromTable(@"remove", @"Vector", nil) + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { + + MXStrongifyAndReturnIfNil(self); + self->currentAlert = nil; + + [self addPendingActionMask]; + MXWeakify(self); + [self.mxRoom sendStateEventOfType:kMXEventTypeStringRoomThirdPartyInvite + content:@{} stateKey:contact.mxThirdPartyInvite.token success:^(NSString *eventId) { + + MXStrongifyAndReturnIfNil(self); + [self removePendingActionMask]; + + [participants removeObjectAtIndex:row]; + + // Refresh display + [self.tableView reloadData]; + + } failure:^(NSError *error) { + + MXStrongifyAndReturnIfNil(self); + [self removePendingActionMask]; + NSLog(@"[RoomParticipantsVC] Revoke 3pid invite failed"); + // Alert user + [[AppDelegate theDelegate] showErrorAsAlert:error]; + + }]; }]]; }