Merge branch 'develop' into privacy

This commit is contained in:
manuroe
2019-10-04 11:56:55 +02:00
committed by GitHub
45 changed files with 2273 additions and 129 deletions
@@ -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];
@@ -1384,6 +1384,7 @@
if (section == participantsSection && userParticipant && (0 == row) && !currentSearchText.length)
{
// Leave ?
MXWeakify(self);
currentAlert = [UIAlertController alertControllerWithTitle:NSLocalizedStringFromTable(@"room_participants_leave_prompt_title", @"Vector", nil)
message:NSLocalizedStringFromTable(@"room_participants_leave_prompt_msg", @"Vector", nil)
preferredStyle:UIAlertControllerStyleAlert];
@@ -1392,11 +1393,8 @@
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
if (weakSelf)
{
typeof(self) self = weakSelf;
self->currentAlert = nil;
}
MXStrongifyAndReturnIfNil(self);
self->currentAlert = nil;
}]];
@@ -1404,25 +1402,25 @@
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
if (weakSelf)
{
typeof(self) self = weakSelf;
self->currentAlert = nil;
MXStrongifyAndReturnIfNil(self);
self->currentAlert = nil;
[self addPendingActionMask];
MXWeakify(self);
[self.mxRoom leave:^{
[self addPendingActionMask];
[self.mxRoom leave:^{
[self withdrawViewControllerAnimated:YES completion:nil];
} failure:^(NSError *error) {
[self removePendingActionMask];
NSLog(@"[RoomParticipantsVC] Leave room %@ failed", self.mxRoom.roomId);
// Alert user
[[AppDelegate theDelegate] showErrorAsAlert:error];
}];
}
MXStrongifyAndReturnIfNil(self);
[self withdrawViewControllerAnimated:YES completion:nil];
} failure:^(NSError *error) {
MXStrongifyAndReturnIfNil(self);
[self removePendingActionMask];
NSLog(@"[RoomParticipantsVC] Leave room %@ failed", self.mxRoom.roomId);
// Alert user
[[AppDelegate theDelegate] showErrorAsAlert:error];
}];
}]];
@@ -1464,6 +1462,7 @@
if (row < participants.count)
{
Contact *contact = participants[row];
MXWeakify(self);
if (contact.mxMember)
{
@@ -1479,11 +1478,8 @@
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
if (weakSelf)
{
typeof(self) self = weakSelf;
self->currentAlert = nil;
}
MXStrongifyAndReturnIfNil(self);
self->currentAlert = nil;
}]];
@@ -1491,51 +1487,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];
}];
}]];
}