From dcd5e66068399672653063249da2457ca0315ad4 Mon Sep 17 00:00:00 2001
From: Philippe Loriaux <philippel@element.io>
Date: Mon, 16 Jan 2023 14:47:48 +0100
Subject: [PATCH 1/2] Remove "Leave" button on Room details screen

---
 .../Settings/RoomSettingsViewController.m     | 90 +------------------
 1 file changed, 1 insertion(+), 89 deletions(-)

diff --git a/Riot/Modules/Room/Settings/RoomSettingsViewController.m b/Riot/Modules/Room/Settings/RoomSettingsViewController.m
index d042a5f183..d958bd2e84 100644
--- a/Riot/Modules/Room/Settings/RoomSettingsViewController.m
+++ b/Riot/Modules/Room/Settings/RoomSettingsViewController.m
@@ -52,8 +52,7 @@
     ROOM_SETTINGS_MAIN_SECTION_ROW_TOPIC,
     ROOM_SETTINGS_MAIN_SECTION_ROW_TAG,
     ROOM_SETTINGS_MAIN_SECTION_ROW_DIRECT_CHAT,
-    ROOM_SETTINGS_MAIN_SECTION_ROW_MUTE_NOTIFICATIONS,
-    ROOM_SETTINGS_MAIN_SECTION_ROW_LEAVE
+    ROOM_SETTINGS_MAIN_SECTION_ROW_MUTE_NOTIFICATIONS
 };
 
 enum
@@ -515,7 +514,6 @@ - (void)updateSections
     {
         [sectionMain addRowWithTag:ROOM_SETTINGS_MAIN_SECTION_ROW_MUTE_NOTIFICATIONS];
     }
-    [sectionMain addRowWithTag:ROOM_SETTINGS_MAIN_SECTION_ROW_LEAVE];
     [tmpSections addObject:sectionMain];
     
     if (RiotSettings.shared.roomSettingsScreenAllowChangingAccessSettings)
@@ -2325,22 +2323,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
                 cell = favoriteCell;
             }
         }
-        else if (row == ROOM_SETTINGS_MAIN_SECTION_ROW_LEAVE)
-        {
-            MXKTableViewCellWithButton *leaveCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCellWithButton defaultReuseIdentifier] forIndexPath:indexPath];
-            
-            NSString* title = [VectorL10n leave];
-            
-            [leaveCell.mxkButton setTitle:title forState:UIControlStateNormal];
-            [leaveCell.mxkButton setTitle:title forState:UIControlStateHighlighted];
-            [leaveCell.mxkButton setTintColor:ThemeService.shared.theme.tintColor];
-            leaveCell.mxkButton.titleLabel.font = [UIFont systemFontOfSize:17];
-            
-            [leaveCell.mxkButton  removeTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
-            [leaveCell.mxkButton addTarget:self action:@selector(onLeave:) forControlEvents:UIControlEventTouchUpInside];
-            
-            cell = leaveCell;
-        }
     }
     else if (section == SECTION_TAG_ACCESS)
     {
@@ -3196,76 +3178,6 @@ - (void)roomMemberDetailsViewController:(MXKRoomMemberDetailsViewController *)ro
 
 #pragma mark - actions
 
-- (void)onLeave:(id)sender
-{
-    // Prompt user before leaving the room
-    __weak typeof(self) weakSelf = self;
-    
-    [currentAlert dismissViewControllerAnimated:NO completion:nil];
-    
-    NSString *title, *message;
-    if ([self.mainSession roomWithRoomId:self.roomId].isDirect)
-    {
-        title = [VectorL10n roomParticipantsLeavePromptTitleForDm];
-        message = [VectorL10n roomParticipantsLeavePromptMsgForDm];
-    }
-    else
-    {
-        title = [VectorL10n roomParticipantsLeavePromptTitle];
-        message = [VectorL10n roomParticipantsLeavePromptMsg];
-    }
-    
-    currentAlert = [UIAlertController alertControllerWithTitle:title
-                                                       message:message
-                                                preferredStyle:UIAlertControllerStyleAlert];
-    
-    [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n cancel]
-                                                     style:UIAlertActionStyleCancel
-                                                   handler:^(UIAlertAction * action) {
-                                                       
-                                                       if (weakSelf)
-                                                       {
-                                                           typeof(self) self = weakSelf;
-                                                           self->currentAlert = nil;
-                                                       }
-                                                       
-                                                   }]];
-    
-    [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n leave]
-                                                     style:UIAlertActionStyleDefault
-                                                   handler:^(UIAlertAction * action) {
-                                                       
-                                                       if (weakSelf)
-                                                       {
-                                                           typeof(self) self = weakSelf;
-                                                           self->currentAlert = nil;
-                                                           
-                                                           [self startActivityIndicator];
-                                                           [self->mxRoom leave:^{
-                                                               
-                                                               if (self.delegate) {
-                                                                   [self.delegate roomSettingsViewControllerDidLeaveRoom:self];
-                                                               } else {
-                                                                   [[LegacyAppDelegate theDelegate] restoreInitialDisplay:nil];
-                                                               }
-                                                               
-                                                           } failure:^(NSError *error) {
-                                                               
-                                                               [self stopActivityIndicator];
-                                                               
-                                                               MXLogDebug(@"[RoomSettingsViewController] Leave room failed");
-                                                               // Alert user
-                                                               [[AppDelegate theDelegate] showErrorAsAlert:error];
-                                                               
-                                                           }];
-                                                       }
-                                                       
-                                                   }]];
-    
-    [currentAlert mxk_setAccessibilityIdentifier:@"RoomSettingsVCLeaveAlert"];
-    [self presentViewController:currentAlert animated:YES completion:nil];
-}
-
 - (void)onRoomAvatarTap:(UITapGestureRecognizer *)recognizer
 {
     SingleImagePickerPresenter *singleImagePickerPresenter = [[SingleImagePickerPresenter alloc] initWithSession:self.mainSession];

From 73a5d937130ea210263f01a5cbc9f1bb121ebef3 Mon Sep 17 00:00:00 2001
From: Philippe Loriaux <philippel@element.io>
Date: Mon, 16 Jan 2023 15:02:33 +0100
Subject: [PATCH 2/2] Add Towncrier file

---
 changelog.d/pr-7275.change | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 changelog.d/pr-7275.change

diff --git a/changelog.d/pr-7275.change b/changelog.d/pr-7275.change
new file mode 100644
index 0000000000..6435f2f71d
--- /dev/null
+++ b/changelog.d/pr-7275.change
@@ -0,0 +1 @@
+Remove "Leave" button on Room details screen