diff --git a/CHANGES.md b/CHANGES.md index 966ee4efa..53518bf12 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,35 @@ +## Changes in 1.6.8 (2021-11-17) + +🙌 Improvements + +- Upgrade MatrixKit version ([v0.16.10](https://github.com/matrix-org/matrix-ios-kit/releases/tag/v0.16.10)). +- Using mutable room list fetch sort options after chaning them to be a structure. ([#4384](https://github.com/vector-im/element-ios/issues/4384)) +- Share Extension: Remove the image compression prompt when the showMediaSizeSelection setting is disabled. ([#4815](https://github.com/vector-im/element-ios/issues/4815)) +- Replaced GrowingTextView with simpler, custom implementation. Cleaned up the RoomInputToolbar header. ([#4976](https://github.com/vector-im/element-ios/issues/4976)) +- Settings: Update about section footer text. ([#5090](https://github.com/vector-im/element-ios/issues/5090)) +- MXSession: Add logs to track if E2EE is enabled by default on the current HS. ([#5129](https://github.com/vector-im/element-ios/issues/5129)) + +🐛 Bugfixes + +- Fixed share extension and message forwarding room list accessory view icon. ([#5041](https://github.com/vector-im/element-ios/issues/5041)) +- Fixed message composer not following keyboard when swiping to dismiss. ([#5042](https://github.com/vector-im/element-ios/issues/5042)) +- RoomVC: Fix retain cycles that prevents `RoomViewController` to be deallocated. ([#5055](https://github.com/vector-im/element-ios/issues/5055)) +- Share Extension: Fix missing avatars and don't list spaces as rooms. ([#5057](https://github.com/vector-im/element-ios/issues/5057)) +- Fix retain cycles that prevents deallocation in several classes. ([#5058](https://github.com/vector-im/element-ios/issues/5058)) +- Fixed retain cycles between the user suggestion coordinator and the suggestion service, and in the suggestion service currentTextTrigger subject sink. ([#5063](https://github.com/vector-im/element-ios/issues/5063)) +- Ensure alerts with weak references are retained until they've been presented. ([#5071](https://github.com/vector-im/element-ios/issues/5071)) +- Message Composer: Ensure there is no text view when the user isn't allowed to send messages. ([#5079](https://github.com/vector-im/element-ios/issues/5079)) +- Home: Fix bug where favourited DM would be shown in both Favourites and People section. ([#5081](https://github.com/vector-im/element-ios/issues/5081)) +- Fix a crash when selected space is not home and a clear cache or logout is performed. ([#5082](https://github.com/vector-im/element-ios/issues/5082)) +- Room Previews: Fix room previews not loading. ([#5083](https://github.com/vector-im/element-ios/issues/5083)) +- Do not make the placeholder appearing when leaving a room on iPhone. ([#5084](https://github.com/vector-im/element-ios/issues/5084)) +- Fix room ordering when switching between Home and People/Rooms/Favourites. ([#5105](https://github.com/vector-im/element-ios/issues/5105)) + +Others + +- Improve wording around rageshakes in the defect issue template. ([#4987](https://github.com/vector-im/element-ios/issues/4987)) + + ## Changes in 1.6.6 (2021-10-21) ✨ Features diff --git a/Config/AppVersion.xcconfig b/Config/AppVersion.xcconfig index 5e6c9928e..4b18e27d3 100644 --- a/Config/AppVersion.xcconfig +++ b/Config/AppVersion.xcconfig @@ -15,5 +15,5 @@ // // Version -MARKETING_VERSION = 1.6.7 -CURRENT_PROJECT_VERSION = 1.6.7 +MARKETING_VERSION = 1.6.8 +CURRENT_PROJECT_VERSION = 1.6.8 diff --git a/Podfile b/Podfile index 4cf944f90..2fed586f1 100644 --- a/Podfile +++ b/Podfile @@ -13,7 +13,7 @@ use_frameworks! # - `{ {kit spec hash} => {sdk spec hash}` to depend on specific pod options (:git => …, :podspec => …) for each repo. Used by Fastfile during CI # # Warning: our internal tooling depends on the name of this variable name, so be sure not to change it -$matrixKitVersion = '= 0.16.9' +$matrixKitVersion = '= 0.16.10' # $matrixKitVersion = :local # $matrixKitVersion = {'develop' => 'develop'} diff --git a/Podfile.lock b/Podfile.lock index 9e25bd5ec..2684759af 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -59,29 +59,29 @@ PODS: - MatomoTracker (7.4.1): - MatomoTracker/Core (= 7.4.1) - MatomoTracker/Core (7.4.1) - - MatrixKit (0.16.9): + - MatrixKit (0.16.10): - Down (~> 0.11.0) - DTCoreText (~> 1.6.25) - HPGrowingTextView (~> 1.1) - libPhoneNumber-iOS (~> 0.9.13) - - MatrixKit/Core (= 0.16.9) - - MatrixSDK (= 0.20.9) - - MatrixKit/Core (0.16.9): + - MatrixKit/Core (= 0.16.10) + - MatrixSDK (= 0.20.10) + - MatrixKit/Core (0.16.10): - Down (~> 0.11.0) - DTCoreText (~> 1.6.25) - HPGrowingTextView (~> 1.1) - libPhoneNumber-iOS (~> 0.9.13) - - MatrixSDK (= 0.20.9) - - MatrixSDK (0.20.9): - - MatrixSDK/Core (= 0.20.9) - - MatrixSDK/Core (0.20.9): + - MatrixSDK (= 0.20.10) + - MatrixSDK (0.20.10): + - MatrixSDK/Core (= 0.20.10) + - MatrixSDK/Core (0.20.10): - AFNetworking (~> 4.0.0) - GZIP (~> 1.3.0) - libbase58 (~> 0.1.4) - OLMKit (~> 3.2.5) - Realm (= 10.16.0) - SwiftyBeaver (= 1.9.5) - - MatrixSDK/JingleCallStack (0.20.9): + - MatrixSDK/JingleCallStack (0.20.10): - JitsiMeetSDK (= 3.10.2) - MatrixSDK/Core - OLMKit (3.2.5): @@ -126,7 +126,7 @@ DEPENDENCIES: - KeychainAccess (~> 4.2.2) - KTCenterFlowLayout (~> 1.3.1) - MatomoTracker (~> 7.4.1) - - MatrixKit (= 0.16.9) + - MatrixKit (= 0.16.10) - MatrixSDK - MatrixSDK/JingleCallStack - OLMKit @@ -210,8 +210,8 @@ SPEC CHECKSUMS: LoggerAPI: ad9c4a6f1e32f518fdb43a1347ac14d765ab5e3d Logging: beeb016c9c80cf77042d62e83495816847ef108b MatomoTracker: 24a846c9d3aa76933183fe9d47fd62c9efa863fb - MatrixKit: ed209774b5c3408974c52cfe2aaba4d2e8b4b05b - MatrixSDK: 9e312e3874027bf9eab61be7d0779102f8bd323a + MatrixKit: c3f0bb056ceeb015e2f1688543ac4dbcf88bef2f + MatrixSDK: 0e2ed8fc6f004cac4b4ab46f038a86fe49ce4007 OLMKit: 9fb4799c4a044dd2c06bda31ec31a12191ad30b5 ReadMoreTextView: 19147adf93abce6d7271e14031a00303fe28720d Realm: b6027801398f3743fc222f096faa85281b506e6c @@ -226,6 +226,6 @@ SPEC CHECKSUMS: zxcvbn-ios: fef98b7c80f1512ff0eec47ac1fa399fc00f7e3c ZXingObjC: fdbb269f25dd2032da343e06f10224d62f537bdb -PODFILE CHECKSUM: 56547a5087a419eb4461b0fb59380381194392dc +PODFILE CHECKSUM: 62cc1ccaaa8e126900f2d3a1d9def9ce814a3216 COCOAPODS: 1.11.2 diff --git a/Riot/Categories/MXSession+Riot.m b/Riot/Categories/MXSession+Riot.m index 51a2b3db9..faf32bd01 100644 --- a/Riot/Categories/MXSession+Riot.m +++ b/Riot/Categories/MXSession+Riot.m @@ -65,6 +65,7 @@ } else { + MXLogWarning(@"[MXSession] E2EE is disabled by default on this homeserver.\nWellknown content: %@", self.homeserverWellknown.JSONDictionary); success(NO); return [MXHTTPOperation new]; } diff --git a/Riot/Managers/Settings/RiotSettings.swift b/Riot/Managers/Settings/RiotSettings.swift index 4b372d460..dade3bafd 100644 --- a/Riot/Managers/Settings/RiotSettings.swift +++ b/Riot/Managers/Settings/RiotSettings.swift @@ -143,7 +143,7 @@ final class RiotSettings: NSObject { @UserDefault(key: "roomsAllowToJoinPublicRooms", defaultValue: BuildSettings.roomsAllowToJoinPublicRooms, storage: defaults) var roomsAllowToJoinPublicRooms - @UserDefault(key: UserDefaultsKeys.showAllRoomsInHomeSpace, defaultValue: false, storage: defaults) + @UserDefault(key: UserDefaultsKeys.showAllRoomsInHomeSpace, defaultValue: true, storage: defaults) var showAllRoomsInHomeSpace // MARK: - Room Screen diff --git a/Riot/Modules/Application/AppCoordinator.swift b/Riot/Modules/Application/AppCoordinator.swift index 32121a0f6..d60faf924 100755 --- a/Riot/Modules/Application/AppCoordinator.swift +++ b/Riot/Modules/Application/AppCoordinator.swift @@ -228,7 +228,7 @@ extension AppCoordinator: LegacyAppDelegateDelegate { } func legacyAppDelegateRestoreEmptyDetailsViewController(_ legacyAppDelegate: LegacyAppDelegate!) { - self.splitViewCoordinator?.restorePlaceholderDetails() + self.splitViewCoordinator?.resetDetails(animated: false) } func legacyAppDelegate(_ legacyAppDelegate: LegacyAppDelegate!, didAddMatrixSession session: MXSession!) { diff --git a/Riot/Modules/Common/Recents/RecentsViewController.m b/Riot/Modules/Common/Recents/RecentsViewController.m index 9254a7ce3..c9b9bb3c0 100644 --- a/Riot/Modules/Common/Recents/RecentsViewController.m +++ b/Riot/Modules/Common/Recents/RecentsViewController.m @@ -539,11 +539,13 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro [self->currentAlert dismissViewControllerAnimated:NO completion:nil]; - self->currentAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n roomErrorJoinFailedTitle] message:msg preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *errorAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n roomErrorJoinFailedTitle] + message:msg + preferredStyle:UIAlertControllerStyleAlert]; - [self->currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [errorAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); self->currentAlert = nil; @@ -553,7 +555,8 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro } }]]; - [self presentViewController:self->currentAlert animated:YES completion:nil]; + [self presentViewController:errorAlert animated:YES completion:nil]; + currentAlert = errorAlert; } #pragma mark - Sticky Headers @@ -1202,13 +1205,13 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro } // confirm leave - currentAlert = [UIAlertController alertControllerWithTitle:title - message:message - preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *leavePrompt = [UIAlertController alertControllerWithTitle:title + message:message + preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { + [leavePrompt addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] + style:UIAlertActionStyleCancel + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -1218,8 +1221,8 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n leave] - style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + [leavePrompt addAction:[UIAlertAction actionWithTitle:[VectorL10n leave] + style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { if (weakSelf) { @@ -1280,8 +1283,9 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro }]]; - [currentAlert mxk_setAccessibilityIdentifier:@"LeaveEditedRoomAlert"]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [leavePrompt mxk_setAccessibilityIdentifier:@"LeaveEditedRoomAlert"]; + [self presentViewController:leavePrompt animated:YES completion:nil]; + currentAlert = leavePrompt; } } @@ -1836,11 +1840,11 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro [currentAlert dismissViewControllerAnimated:NO completion:nil]; - currentAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; + UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomRecentsStartChatWith] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[VectorL10n roomRecentsStartChatWith] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -1852,9 +1856,9 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomRecentsCreateEmptyRoom] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[VectorL10n roomRecentsCreateEmptyRoom] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -1866,9 +1870,9 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomRecentsJoinRoom] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[VectorL10n roomRecentsJoinRoom] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -1882,10 +1886,9 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro if (self.mainSession.callManager.supportsPSTN) { - [currentAlert addAction:[UIAlertAction - actionWithTitle:[VectorL10n roomOpenDialpad] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[VectorL10n roomOpenDialpad] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -1898,9 +1901,9 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro }]]; } - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] + style:UIAlertActionStyleCancel + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -1910,11 +1913,12 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro }]]; - [currentAlert popoverPresentationController].sourceView = plusButtonImageView; - [currentAlert popoverPresentationController].sourceRect = plusButtonImageView.bounds; + [actionSheet popoverPresentationController].sourceView = plusButtonImageView; + [actionSheet popoverPresentationController].sourceRect = plusButtonImageView.bounds; - [currentAlert mxk_setAccessibilityIdentifier:@"RecentsVCCreateRoomAlert"]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [actionSheet mxk_setAccessibilityIdentifier:@"RecentsVCCreateRoomAlert"]; + [self presentViewController:actionSheet animated:YES completion:nil]; + currentAlert = actionSheet; } - (void)openDialpad @@ -2008,7 +2012,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro } // Check whether the user has already joined the selected public room - if ([self.recentsDataSource.publicRoomsDirectoryDataSource.mxSession roomWithRoomId:publicRoom.roomId]) + if ([self.recentsDataSource.publicRoomsDirectoryDataSource.mxSession isJoinedOnRoom:publicRoom.roomId]) { // Open the public room [self showRoomWithRoomId:publicRoom.roomId diff --git a/Riot/Modules/Common/Recents/Service/MatrixSDK/RecentsListService.swift b/Riot/Modules/Common/Recents/Service/MatrixSDK/RecentsListService.swift index 1fbc04371..6651fddba 100644 --- a/Riot/Modules/Common/Recents/Service/MatrixSDK/RecentsListService.swift +++ b/Riot/Modules/Common/Recents/Service/MatrixSDK/RecentsListService.swift @@ -20,7 +20,12 @@ import Foundation public class RecentsListService: NSObject, RecentsListServiceProtocol { private weak var session: MXSession? - public private(set) var mode: RecentsDataSourceMode + public private(set) var mode: RecentsDataSourceMode { + didSet { + refresh() + } + } + public private(set) var query: String? public private(set) var space: MXSpace? @@ -427,7 +432,7 @@ public class RecentsListService: NSObject, RecentsListServiceProtocol { private func updateDirectFetcher(_ fetcher: MXRoomListDataFetcher, for mode: RecentsDataSourceMode) { switch mode { case .home: - fetcher.fetchOptions.filterOptions.notDataTypes = [.invited, .lowPriority] + fetcher.fetchOptions.filterOptions.notDataTypes = [.invited, .favorited, .lowPriority] case .people: fetcher.fetchOptions.filterOptions.notDataTypes = [.lowPriority] default: diff --git a/Riot/Modules/Common/Recents/Service/Mock/MockRoomSummary.swift b/Riot/Modules/Common/Recents/Service/Mock/MockRoomSummary.swift index 713932423..c211db025 100644 --- a/Riot/Modules/Common/Recents/Service/Mock/MockRoomSummary.swift +++ b/Riot/Modules/Common/Recents/Service/Mock/MockRoomSummary.swift @@ -60,6 +60,18 @@ public class MockRoomSummary: NSObject, MXRoomSummaryProtocol { public var highlightCount: UInt = 0 + public var hasAnyUnread: Bool { + return localUnreadEventCount > 0 + } + + public var hasAnyNotification: Bool { + return notificationCount > 0 + } + + public var hasAnyHighlight: Bool { + return highlightCount > 0 + } + public var isDirect: Bool { return isTyped(.direct) } diff --git a/Riot/Modules/GlobalSearch/Rooms/DirectoryViewController.m b/Riot/Modules/GlobalSearch/Rooms/DirectoryViewController.m index 0c0e26622..47300a956 100644 --- a/Riot/Modules/GlobalSearch/Rooms/DirectoryViewController.m +++ b/Riot/Modules/GlobalSearch/Rooms/DirectoryViewController.m @@ -190,7 +190,7 @@ MXPublicRoom *publicRoom = [dataSource roomAtIndexPath:indexPath]; // Check whether the user has already joined the selected public room - if ([dataSource.mxSession roomWithRoomId:publicRoom.roomId]) + if ([dataSource.mxSession isJoinedOnRoom:publicRoom.roomId]) { // Open the public room. [self showRoomWithId:publicRoom.roomId inMatrixSession:dataSource.mxSession]; diff --git a/Riot/Modules/Room/RoomCoordinator.swift b/Riot/Modules/Room/RoomCoordinator.swift index fa9a5d2db..3a6c803ff 100644 --- a/Riot/Modules/Room/RoomCoordinator.swift +++ b/Riot/Modules/Room/RoomCoordinator.swift @@ -99,7 +99,9 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol { // FIXME: Find a better way to manage modal dismiss. This makes the `roomViewController` to never be released // self.roomViewController.presentationController?.delegate = self - if let eventId = self.selectedEventId { + if let previewData = self.parameters.previewData { + self.loadRoomPreview(withData: previewData, completion: completion) + } else if let eventId = self.selectedEventId { self.loadRoom(withId: self.parameters.roomId, and: eventId, completion: completion) } else { self.loadRoom(withId: self.parameters.roomId, completion: completion) @@ -185,6 +187,13 @@ final class RoomCoordinator: NSObject, RoomCoordinatorProtocol { completion?() } } + + private func loadRoomPreview(withData previewData: RoomPreviewData, completion: (() -> Void)?) { + + self.roomViewController.displayRoomPreview(previewData) + + completion?() + } } // MARK: - RoomIdentifiable diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index 589b6be8c..10c75553e 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -1098,16 +1098,12 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; if (self.roomDataSource) { - // Restore tool bar view and room activities view if none - if (!self.inputToolbarView) - { - [self updateRoomInputToolbarViewClassIfNeeded]; - - [self refreshRoomInputToolbar]; - - self.inputToolbarView.hidden = (self.roomDataSource.state != MXKDataSourceStateReady); - } + // Update the input toolbar class and update the layout + [self updateRoomInputToolbarViewClassIfNeeded]; + self.inputToolbarView.hidden = (self.roomDataSource.state != MXKDataSourceStateReady); + + // Restore room activities view if none if (!self.activitiesView) { // And the extra area @@ -1192,6 +1188,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } [self updateInputToolBarViewHeight]; + [self refreshRoomInputToolbar]; } } @@ -2077,20 +2074,22 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; [VectorL10n widgetStickerPickerNoStickerpacksAlert], [VectorL10n widgetStickerPickerNoStickerpacksAlertAddNow]]; - currentAlert = [UIAlertController alertControllerWithTitle:nil message:alertMessage preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *installPrompt = [UIAlertController alertControllerWithTitle:nil + message:alertMessage + preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n no] - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) + [installPrompt addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n no] + style:UIAlertActionStyleCancel + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); self->currentAlert = nil; }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n yes] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) + [installPrompt addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n yes] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); self->currentAlert = nil; @@ -2105,8 +2104,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; [self presentViewController:modularVC animated:NO completion:nil]; }]]; - [currentAlert mxk_setAccessibilityIdentifier:@"RoomVCStickerPickerAlert"]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [installPrompt mxk_setAccessibilityIdentifier:@"RoomVCStickerPickerAlert"]; + [self presentViewController:installPrompt animated:YES completion:nil]; + currentAlert = installPrompt; } } @@ -3160,14 +3160,14 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } MXWeakify(self); - currentAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; + UIAlertController *actionsMenu = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; // Add actions for a failed event if (selectedEvent.sentState == MXEventSentStateFailed) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n retry] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n retry] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self cancelEventSelection]; @@ -3176,9 +3176,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; [self.roomDataSource resendEventWithEventId:selectedEvent.eventId success:nil failure:nil]; }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionDelete] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionDelete] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self cancelEventSelection]; @@ -3208,9 +3208,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; selectedEvent.sentState == MXEventSentStateEncrypting || selectedEvent.sentState == MXEventSentStateSending) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionCancelSend] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionCancelSend] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); self->currentAlert = nil; @@ -3224,9 +3224,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } if (selectedEvent.sentState == MXEventSentStateSent) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionForward] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionForward] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self presentEventForwardingDialogForSelectedEvent:selectedEvent]; }]]; @@ -3234,9 +3234,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; if (!isJitsiCallEvent) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionQuote] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionQuote] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self cancelEventSelection]; @@ -3251,9 +3251,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; if (!isJitsiCallEvent && BuildSettings.messageDetailsAllowShare) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionShare] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionShare] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self cancelEventSelection]; @@ -3280,9 +3280,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; attachment.type == MXKAttachmentTypeImage || attachment.type == MXKAttachmentTypeVideo || attachment.type == MXKAttachmentTypeVoiceMessage)) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionForward] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionForward] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self presentEventForwardingDialogForSelectedEvent:selectedEvent]; }]]; @@ -3292,9 +3292,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; { if (attachment.type == MXKAttachmentTypeImage || attachment.type == MXKAttachmentTypeVideo) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionSave] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionSave] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self cancelEventSelection]; @@ -3329,9 +3329,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; NSString *uploadId = roomBubbleTableViewCell.bubbleData.attachment.contentURL; if ([MXMediaManager existingUploaderWithId:uploadId]) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionCancelSend] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionCancelSend] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); @@ -3363,9 +3363,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; { if (BuildSettings.messageDetailsAllowShare) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionShare] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionShare] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self cancelEventSelection]; @@ -3410,9 +3410,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; NSString *downloadId = roomBubbleTableViewCell.bubbleData.attachment.downloadId; if ([MXMediaManager existingDownloaderWithIdentifier:downloadId]) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionCancelDownload] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionCancelDownload] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self cancelEventSelection]; @@ -3433,9 +3433,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; // because it breaks everything if (selectedEvent.eventType != MXEventTypeRoomEncryption) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionRedact] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionRedact] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self cancelEventSelection]; @@ -3459,9 +3459,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; if (BuildSettings.messageDetailsAllowPermalink) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionPermalink] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionPermalink] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self cancelEventSelection]; @@ -3483,9 +3483,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; // Add reaction history if event contains reactions if (roomBubbleTableViewCell.bubbleData.reactions[selectedEvent.eventId].aggregatedReactionsWithNonZeroCount) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionReactionHistory] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionReactionHistory] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self cancelEventSelection]; @@ -3497,9 +3497,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; if (BuildSettings.messageDetailsAllowViewSource) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionViewSource] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionViewSource] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self cancelEventSelection]; @@ -3512,9 +3512,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; // Add "View Decrypted Source" for e2ee event we can decrypt if (selectedEvent.isEncrypted && selectedEvent.clearEvent) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionViewDecryptedSource] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionViewDecryptedSource] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self cancelEventSelection]; @@ -3527,24 +3527,26 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; if (![selectedEvent.sender isEqualToString:self.mainSession.myUser.userId] && RiotSettings.shared.roomContextualMenuShowReportContentOption) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionReport] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n roomEventActionReport] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self cancelEventSelection]; // Prompt user to enter a description of the problem content. - self->currentAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomEventActionReportPromptReason] message:nil preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *reportReasonAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomEventActionReportPromptReason] + message:nil + preferredStyle:UIAlertControllerStyleAlert]; - [self->currentAlert addTextFieldWithConfigurationHandler:^(UITextField *textField) { + [reportReasonAlert addTextFieldWithConfigurationHandler:^(UITextField *textField) { textField.secureTextEntry = NO; textField.placeholder = nil; textField.keyboardType = UIKeyboardTypeDefault; }]; MXWeakify(self); - [self->currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + [reportReasonAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); NSString *text = [self->currentAlert textFields].firstObject.text; @@ -3559,10 +3561,12 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; [self stopActivityIndicator]; // Prompt user to ignore content from this user - self->currentAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomEventActionReportPromptIgnoreUser] message:nil preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *ignoreUserAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomEventActionReportPromptIgnoreUser] + message:nil + preferredStyle:UIAlertControllerStyleAlert]; MXWeakify(self); - [self->currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n yes] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + [ignoreUserAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n yes] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); self->currentAlert = nil; @@ -3584,12 +3588,13 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; }]; }]]; - [self->currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n no] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + [ignoreUserAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n no] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); self->currentAlert = nil; }]]; - [self presentViewController:self->currentAlert animated:YES completion:nil]; + [self presentViewController:ignoreUserAlert animated:YES completion:nil]; + self->currentAlert = ignoreUserAlert; } failure:^(NSError *error) { MXStrongifyAndReturnIfNil(self); @@ -3602,12 +3607,13 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; }]; }]]; - [self->currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) { + [reportReasonAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); self->currentAlert = nil; }]]; - [self presentViewController:self->currentAlert animated:YES completion:nil]; + [self presentViewController:reportReasonAlert animated:YES completion:nil]; + self->currentAlert = reportReasonAlert; }]]; } @@ -3626,29 +3632,26 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } } - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n cancel] - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { + [actionsMenu addAction:[UIAlertAction actionWithTitle:[VectorL10n cancel] + style:UIAlertActionStyleCancel + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self hideContextualMenuAnimated:YES]; }]]; // Do not display empty action sheet - if (currentAlert.actions.count > 1) + if (actionsMenu.actions.count > 1) { NSInteger bubbleComponentIndex = [roomBubbleTableViewCell.bubbleData bubbleComponentIndexForEventId:selectedEvent.eventId]; CGRect sourceRect = [roomBubbleTableViewCell componentFrameInContentViewForIndex:bubbleComponentIndex]; - [currentAlert mxk_setAccessibilityIdentifier:@"RoomVCEventMenuAlert"]; - [currentAlert popoverPresentationController].sourceView = roomBubbleTableViewCell; - [currentAlert popoverPresentationController].sourceRect = sourceRect; - [self presentViewController:currentAlert animated:animated completion:nil]; - } - else - { - currentAlert = nil; + [actionsMenu mxk_setAccessibilityIdentifier:@"RoomVCEventMenuAlert"]; + [actionsMenu popoverPresentationController].sourceView = roomBubbleTableViewCell; + [actionsMenu popoverPresentationController].sourceRect = sourceRect; + [self presentViewController:actionsMenu animated:animated completion:nil]; + currentAlert = actionsMenu; } } @@ -4040,14 +4043,14 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; - (void)showVoiceCallActionSheet { // Ask the user the kind of the call: voice or dialpad? - currentAlert = [UIAlertController alertControllerWithTitle:nil - message:nil - preferredStyle:UIAlertControllerStyleActionSheet]; + UIAlertController *callActionSheet = [UIAlertController alertControllerWithTitle:nil + message:nil + preferredStyle:UIAlertControllerStyleActionSheet]; __weak typeof(self) weakSelf = self; - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomPlaceVoiceCall] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [callActionSheet addAction:[UIAlertAction actionWithTitle:[VectorL10n roomPlaceVoiceCall] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -4059,9 +4062,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomOpenDialpad] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [callActionSheet addAction:[UIAlertAction actionWithTitle:[VectorL10n roomOpenDialpad] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -4073,9 +4076,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { + [callActionSheet addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] + style:UIAlertActionStyleCancel + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -4085,9 +4088,10 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; }]]; - [currentAlert popoverPresentationController].barButtonItem = self.navigationItem.rightBarButtonItems.firstObject; - [currentAlert popoverPresentationController].permittedArrowDirections = UIPopoverArrowDirectionUp; - [self presentViewController:currentAlert animated:YES completion:nil]; + [callActionSheet popoverPresentationController].barButtonItem = self.navigationItem.rightBarButtonItems.firstObject; + [callActionSheet popoverPresentationController].permittedArrowDirections = UIPopoverArrowDirectionUp; + [self presentViewController:callActionSheet animated:YES completion:nil]; + currentAlert = callActionSheet; } - (void)placeCallWithVideo2:(BOOL)video @@ -4139,20 +4143,21 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; MXWeakify(self); [currentAlert dismissViewControllerAnimated:NO completion:nil]; - currentAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomNoPrivilegesToCreateGroupCall] - message:nil - preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *unprivilegedAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomNoPrivilegesToCreateGroupCall] + message:nil + preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) + [unprivilegedAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); self->currentAlert = nil; }]]; - [currentAlert mxk_setAccessibilityIdentifier:@"RoomVCCallAlert"]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [unprivilegedAlert mxk_setAccessibilityIdentifier:@"RoomVCCallAlert"]; + [self presentViewController:unprivilegedAlert animated:YES completion:nil]; + currentAlert = unprivilegedAlert; } } } @@ -5080,6 +5085,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; [VectorL10n roomUnsentMessagesUnknownDevicesNotification] : [VectorL10n roomUnsentMessagesNotification]; + MXWeakify(self); RoomActivitiesView *roomActivitiesView = (RoomActivitiesView*) self.activitiesView; self.activitiesViewExpanded = YES; [roomActivitiesView displayUnsentMessagesNotification:notification withResendLink:^{ @@ -5091,57 +5097,53 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; [self cancelAllUnsentMessages]; } andIconTapGesture:^{ + MXStrongifyAndReturnIfNil(self); - if (currentAlert) + if (self->currentAlert) { - [currentAlert dismissViewControllerAnimated:NO completion:nil]; + [self->currentAlert dismissViewControllerAnimated:NO completion:nil]; } - __weak __typeof(self) weakSelf = self; - currentAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; + MXWeakify(self); + UIAlertController *resendAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomResendUnsentMessages] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [resendAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomResendUnsentMessages] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { - if (weakSelf) - { - typeof(self) self = weakSelf; - [self resendAllUnsentMessages]; - self->currentAlert = nil; - } + MXStrongifyAndReturnIfNil(self); + + [self resendAllUnsentMessages]; + self->currentAlert = nil; }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomDeleteUnsentMessages] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [resendAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n roomDeleteUnsentMessages] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { - if (weakSelf) - { - typeof(self) self = weakSelf; - [self cancelAllUnsentMessages]; - self->currentAlert = nil; - } + MXStrongifyAndReturnIfNil(self); + + [self cancelAllUnsentMessages]; + self->currentAlert = nil; }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n cancel] - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { + [resendAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n cancel] + style:UIAlertActionStyleCancel + handler:^(UIAlertAction * action) { - if (weakSelf) - { - typeof(self) self = weakSelf; - self->currentAlert = nil; - } + MXStrongifyAndReturnIfNil(self); + + self->currentAlert = nil; }]]; - [currentAlert mxk_setAccessibilityIdentifier:@"RoomVCUnsentMessagesMenuAlert"]; - [currentAlert popoverPresentationController].sourceView = roomActivitiesView; - [currentAlert popoverPresentationController].sourceRect = roomActivitiesView.bounds; - [self presentViewController:currentAlert animated:YES completion:nil]; + [resendAlert mxk_setAccessibilityIdentifier:@"RoomVCUnsentMessagesMenuAlert"]; + [resendAlert popoverPresentationController].sourceView = roomActivitiesView; + [resendAlert popoverPresentationController].sourceRect = roomActivitiesView.bounds; + [self presentViewController:resendAlert animated:YES completion:nil]; + self->currentAlert = resendAlert; }]; } @@ -5181,13 +5183,13 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } } - currentAlert = [UIAlertController alertControllerWithTitle:[VectorL10n unknownDevicesAlertTitle] - message:[VectorL10n unknownDevicesAlert] - preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *unknownDevicesAlert = [UIAlertController alertControllerWithTitle:[VectorL10n unknownDevicesAlertTitle] + message:[VectorL10n unknownDevicesAlert] + preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n unknownDevicesVerify] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [unknownDevicesAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n unknownDevicesVerify] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -5199,9 +5201,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n unknownDevicesSendAnyway] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [unknownDevicesAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n unknownDevicesSendAnyway] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -5222,8 +5224,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; }]]; - [currentAlert mxk_setAccessibilityIdentifier:@"RoomVCUnknownDevicesAlert"]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [unknownDevicesAlert mxk_setAccessibilityIdentifier:@"RoomVCUnknownDevicesAlert"]; + [self presentViewController:unknownDevicesAlert animated:YES completion:nil]; + currentAlert = unknownDevicesAlert; } } @@ -5285,15 +5288,17 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; - (void)cancelAllUnsentMessages { - currentAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomUnsentMessagesCancelTitle] message:[VectorL10n roomUnsentMessagesCancelMessage] preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *cancelAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomUnsentMessagesCancelTitle] + message:[VectorL10n roomUnsentMessagesCancelMessage] + preferredStyle:UIAlertControllerStyleAlert]; MXWeakify(self); - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) { + [cancelAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); self->currentAlert = nil; }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n delete] style:UIAlertActionStyleDestructive handler:^(UIAlertAction * action) { + [cancelAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n delete] style:UIAlertActionStyleDestructive handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); // Remove unsent event ids for (NSUInteger index = 0; index < self.roomDataSource.room.outgoingMessages.count;) @@ -5310,9 +5315,11 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; } [self refreshActivitiesViewDisplay]; + self->currentAlert = nil; }]]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [self presentViewController:cancelAlert animated:YES completion:nil]; + currentAlert = cancelAlert; } # pragma mark - Encryption Information view @@ -5541,11 +5548,11 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; // Invite ? NSString *promptMsg = [VectorL10n roomParticipantsInvitePromptMsg:contact.displayName]; - currentAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomParticipantsInvitePromptTitle] - message:promptMsg - preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *invitePrompt = [UIAlertController alertControllerWithTitle:[VectorL10n roomParticipantsInvitePromptTitle] + message:promptMsg + preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] + [invitePrompt addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) { @@ -5557,7 +5564,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n invite] + [invitePrompt addAction:[UIAlertAction actionWithTitle:[VectorL10n invite] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { @@ -5652,8 +5659,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; }]]; - [currentAlert mxk_setAccessibilityIdentifier:@"RoomVCInviteAlert"]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [invitePrompt mxk_setAccessibilityIdentifier:@"RoomVCInviteAlert"]; + [self presentViewController:invitePrompt animated:YES completion:nil]; + currentAlert = invitePrompt; } #pragma mark - Re-request encryption keys @@ -5697,8 +5705,6 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; alert = [UIAlertController alertControllerWithTitle:VectorL10n.rerequestKeysAlertTitle message:[VectorL10n e2eRoomKeyRequestMessage:AppInfo.current.displayName] preferredStyle:UIAlertControllerStyleAlert]; - currentAlert = alert; - [alert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] style:UIAlertActionStyleDefault @@ -5712,7 +5718,8 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; self->currentAlert = nil; }]]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [self presentViewController:alert animated:YES completion:nil]; + currentAlert = alert; } - (void)presentReviewUnverifiedSessionsAlert @@ -5986,18 +5993,19 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05; [self hideContextualMenuAnimated:YES cancelEventSelection:YES completion:^{ MXStrongifyAndReturnIfNil(self); - self->currentAlert = [UIAlertController alertControllerWithTitle:[VectorL10n roomEventActionDeleteConfirmationTitle] - message:[VectorL10n roomEventActionDeleteConfirmationMessage] - preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *deleteConfirmation = [UIAlertController alertControllerWithTitle:[VectorL10n roomEventActionDeleteConfirmationTitle] + message:[VectorL10n roomEventActionDeleteConfirmationMessage] + preferredStyle:UIAlertControllerStyleAlert]; - [self->currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + [deleteConfirmation addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { }]]; - [self->currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n delete] style:UIAlertActionStyleDestructive handler:^(UIAlertAction * action) { + [deleteConfirmation addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n delete] style:UIAlertActionStyleDestructive handler:^(UIAlertAction * action) { [self.roomDataSource removeEventWithEventId:event.eventId]; }]]; - [self presentViewController:self->currentAlert animated:YES completion:nil]; + [self presentViewController:deleteConfirmation animated:YES completion:nil]; + self->currentAlert = deleteConfirmation; }]; }; diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index 5d80ae011..87763dca2 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -541,13 +541,8 @@ TableViewSectionsDelegate> sectionAbout.headerTitle = VectorL10n.settingsAbout; if (BuildSettings.settingsScreenShowAdvancedSettings) - { - sectionAbout.footerTitle = [NSString stringWithFormat:@"Element %@ (%@) / Olm %@\n%@\n%@", - AppInfo.current.appVersion.bundleShortVersion, - AppInfo.current.appVersion.bundleVersion, - [OLMKit versionString], - [MatrixKitL10n settingsConfigUserId:account.mxCredentials.userId], - [MatrixKitL10n settingsConfigHomeServer:account.mxCredentials.homeServer]]; + { + sectionAbout.footerTitle = [self buildAboutSectionFooterTitleWithAccount:account]; } [tmpSections addObject:sectionAbout]; @@ -991,9 +986,11 @@ TableViewSectionsDelegate> { MXWeakify(self); [currentAlert dismissViewControllerAnimated:NO completion:nil]; - currentAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n accountEmailValidationTitle] message:message preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *validationAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n accountEmailValidationTitle] + message:message + preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + [validationAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); self->currentAlert = nil; [self stopActivityIndicator]; @@ -1002,14 +999,15 @@ TableViewSectionsDelegate> self.newEmailEditingEnabled = NO; }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n continue] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + [validationAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n continue] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); [self tryFinaliseAddEmailSession:threePidAddSession withAuthenticationParameters:authenticationParameters threePidAddManager:threePidAddManager]; }]]; - [currentAlert mxk_setAccessibilityIdentifier:@"SettingsVCEmailValidationAlert"]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [validationAlert mxk_setAccessibilityIdentifier:@"SettingsVCEmailValidationAlert"]; + [self presentViewController:validationAlert animated:YES completion:nil]; + currentAlert = validationAlert; } - (void)tryFinaliseAddEmailSession:(MX3PidAddSession*)threePidAddSession withAuthenticationParameters:(NSDictionary*)authParams threePidAddManager:(MX3PidAddManager*)threePidAddManager @@ -1049,11 +1047,13 @@ TableViewSectionsDelegate> MXLogDebug(@"[SettingsViewController] tryFinaliseAddEmailSession: Wrong credentials"); // Ask password again - self->currentAlert = [UIAlertController alertControllerWithTitle:nil - message:[VectorL10n settingsAdd3pidInvalidPasswordMessage] - preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *passwordPrompt = [UIAlertController alertControllerWithTitle:nil + message:[VectorL10n settingsAdd3pidInvalidPasswordMessage] + preferredStyle:UIAlertControllerStyleAlert]; - [self->currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n retry] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + MXWeakify(self); + [passwordPrompt addAction:[UIAlertAction actionWithTitle:[VectorL10n retry] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + MXStrongifyAndReturnIfNil(self); self->currentAlert = nil; [self showAuthenticationIfNeededForAdding:kMX3PIDMediumEmail withSession:self.mainSession completion:^(NSDictionary *authParams) { @@ -1061,7 +1061,8 @@ TableViewSectionsDelegate> }]; }]]; - [self presentViewController:self->currentAlert animated:YES completion:nil]; + [self presentViewController:passwordPrompt animated:YES completion:nil]; + self->currentAlert = passwordPrompt; return; } @@ -1102,9 +1103,11 @@ TableViewSectionsDelegate> MXWeakify(self); [currentAlert dismissViewControllerAnimated:NO completion:nil]; - currentAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n accountMsisdnValidationTitle] message:message preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *validationAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n accountMsisdnValidationTitle] + message:message + preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + [validationAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); self->currentAlert = nil; @@ -1115,13 +1118,13 @@ TableViewSectionsDelegate> self.newPhoneEditingEnabled = NO; }]]; - [currentAlert addTextFieldWithConfigurationHandler:^(UITextField *textField) { + [validationAlert addTextFieldWithConfigurationHandler:^(UITextField *textField) { textField.secureTextEntry = NO; textField.placeholder = nil; textField.keyboardType = UIKeyboardTypeDecimalPad; }]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n submit] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + [validationAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n submit] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { MXStrongifyAndReturnIfNil(self); @@ -1140,8 +1143,9 @@ TableViewSectionsDelegate> } }]]; - [currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCMsisdnValidationAlert"]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [validationAlert mxk_setAccessibilityIdentifier: @"SettingsVCMsisdnValidationAlert"]; + [self presentViewController:validationAlert animated:YES completion:nil]; + currentAlert = validationAlert; } - (void)finaliseAddPhoneNumberSession:(MX3PidAddSession*)threePidAddSession withToken:(NSString*)token andAuthenticationParameters:(NSDictionary*)authParams message:(NSString*)message threePidAddManager:(MX3PidAddManager*)threePidAddManager @@ -1180,11 +1184,13 @@ TableViewSectionsDelegate> MXLogDebug(@"[SettingsViewController] finaliseAddPhoneNumberSession: Wrong authentication credentials"); // Ask password again - self->currentAlert = [UIAlertController alertControllerWithTitle:nil - message:[VectorL10n settingsAdd3pidInvalidPasswordMessage] - preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *passwordPrompt = [UIAlertController alertControllerWithTitle:nil + message:[VectorL10n settingsAdd3pidInvalidPasswordMessage] + preferredStyle:UIAlertControllerStyleAlert]; - [self->currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n retry] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + MXWeakify(self); + [passwordPrompt addAction:[UIAlertAction actionWithTitle:[VectorL10n retry] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + MXStrongifyAndReturnIfNil(self); self->currentAlert = nil; [self showAuthenticationIfNeededForAdding:kMX3PIDMediumMSISDN withSession:self.mainSession completion:^(NSDictionary *authParams) { @@ -1192,7 +1198,8 @@ TableViewSectionsDelegate> }]; }]]; - [self presentViewController:self->currentAlert animated:YES completion:nil]; + [self presentViewController:passwordPrompt animated:YES completion:nil]; + self->currentAlert = passwordPrompt; return; } @@ -1232,17 +1239,20 @@ TableViewSectionsDelegate> } - self->currentAlert = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *errorAlert = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert]; - [self->currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + MXWeakify(self); + [errorAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { + MXStrongifyAndReturnIfNil(self); self->currentAlert = nil; // Ask again the sms token [self showValidationMsisdnDialogWithMessage:message for3PidAddSession:threePidAddSession threePidAddManager:threePidAddManager authenticationParameters:authParams]; }]]; - [self->currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCErrorAlert"]; - [self presentViewController:self->currentAlert animated:YES completion:nil]; + [errorAlert mxk_setAccessibilityIdentifier: @"SettingsVCErrorAlert"]; + [self presentViewController:errorAlert animated:YES completion:nil]; + self->currentAlert = errorAlert; } }]; } @@ -1410,6 +1420,35 @@ TableViewSectionsDelegate> } } +- (NSString*)buildAboutSectionFooterTitleWithAccount:(MXKAccount*)account +{ + NSMutableString *footerText = [NSMutableString new]; + + AppInfo *appInfo = AppInfo.current; + + NSString *appName = appInfo.displayName; + NSString *appVersion = appInfo.appVersion.bundleShortVersion; + NSString *buildVersion = appInfo.appVersion.bundleVersion; + + NSString *appVersionInfo = [NSString stringWithFormat:@"%@ %@ (%@)", appName, appVersion, buildVersion]; + + NSString *loggedUserInfo = [MatrixKitL10n settingsConfigUserId:account.mxCredentials.userId]; + + NSString *homeserverInfo = [MatrixKitL10n settingsConfigHomeServer:account.mxCredentials.homeServer]; + + NSString *sdkVersionInfo = [NSString stringWithFormat:@"Matrix SDK %@", MatrixSDKVersion]; + + NSString *olmVersionInfo = [NSString stringWithFormat:@"OLM %@", [OLMKit versionString]]; + + [footerText appendFormat:@"%@\n", loggedUserInfo]; + [footerText appendFormat:@"%@\n", homeserverInfo]; + [footerText appendFormat:@"%@\n", appVersionInfo]; + [footerText appendFormat:@"%@\n", sdkVersionInfo]; + [footerText appendFormat:@"%@", olmVersionInfo]; + + return [footerText copy]; +} + #pragma mark - 3Pid Add - (void)showAuthenticationIfNeededForAdding:(MX3PIDMedium)medium withSession:(MXSession*)session completion:(void (^)(NSDictionary* authParams))completion @@ -2606,11 +2645,11 @@ TableViewSectionsDelegate> __weak typeof(self) weakSelf = self; - currentAlert = [UIAlertController alertControllerWithTitle:[VectorL10n settingsUnignoreUser:ignoredUserId] message:nil preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *unignorePrompt = [UIAlertController alertControllerWithTitle:[VectorL10n settingsUnignoreUser:ignoredUserId] message:nil preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n yes] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [unignorePrompt addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n yes] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -2639,9 +2678,9 @@ TableViewSectionsDelegate> }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n no] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [unignorePrompt addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n no] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -2651,8 +2690,9 @@ TableViewSectionsDelegate> }]]; - [currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCUnignoreAlert"]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [unignorePrompt mxk_setAccessibilityIdentifier: @"SettingsVCUnignoreAlert"]; + [self presentViewController:unignorePrompt animated:YES completion:nil]; + currentAlert = unignorePrompt; } } else if (section == SECTION_TAG_ABOUT) @@ -2838,9 +2878,9 @@ TableViewSectionsDelegate> } // Remove ? - currentAlert = [UIAlertController alertControllerWithTitle:[VectorL10n settingsRemovePromptTitle] message:promptMsg preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *removePrompt = [UIAlertController alertControllerWithTitle:[VectorL10n settingsRemovePromptTitle] message:promptMsg preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] + [removePrompt addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) { @@ -2852,7 +2892,7 @@ TableViewSectionsDelegate> }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[VectorL10n remove] + [removePrompt addAction:[UIAlertAction actionWithTitle:[VectorL10n remove] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { @@ -2892,8 +2932,9 @@ TableViewSectionsDelegate> }]]; - [currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCRemove3PIDAlert"]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [removePrompt mxk_setAccessibilityIdentifier: @"SettingsVCRemove3PIDAlert"]; + [self presentViewController:removePrompt animated:YES completion:nil]; + currentAlert = removePrompt; } } } @@ -2915,9 +2956,9 @@ TableViewSectionsDelegate> NSString *title = [VectorL10n settingsNotificationsDisabledAlertTitle]; NSString *message = [VectorL10n settingsNotificationsDisabledAlertMessage]; - currentAlert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *showSettingsPrompt = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] + [showSettingsPrompt addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] style:UIAlertActionStyleCancel handler:^(UIAlertAction * action) { @@ -2941,13 +2982,14 @@ TableViewSectionsDelegate> } }]; - [currentAlert addAction:settingsAction]; - currentAlert.preferredAction = settingsAction; + [showSettingsPrompt addAction:settingsAction]; + showSettingsPrompt.preferredAction = settingsAction; - [currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCPushNotificationsAlert"]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [showSettingsPrompt mxk_setAccessibilityIdentifier: @"SettingsVCPushNotificationsAlert"]; + [self presentViewController:showSettingsPrompt animated:YES completion:nil]; + currentAlert = showSettingsPrompt; - // Keep off the switch + // Keep the the switch off. sender.on = NO; } else if ([MXKAccountManager sharedManager].activeAccounts.count) @@ -3336,11 +3378,11 @@ TableViewSectionsDelegate> [currentAlert dismissViewControllerAnimated:NO completion:nil]; - currentAlert = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *errorAlert = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [errorAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -3361,9 +3403,9 @@ TableViewSectionsDelegate> }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n retry] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [errorAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n retry] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -3377,8 +3419,9 @@ TableViewSectionsDelegate> }]]; - [currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCSaveChangesFailedAlert"]; - [rootViewController presentViewController:currentAlert animated:YES completion:nil]; + [errorAlert mxk_setAccessibilityIdentifier: @"SettingsVCSaveChangesFailedAlert"]; + [rootViewController presentViewController:errorAlert animated:YES completion:nil]; + currentAlert = errorAlert; } } @@ -3399,13 +3442,13 @@ TableViewSectionsDelegate> [currentAlert dismissViewControllerAnimated:NO completion:nil]; - currentAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n accountErrorEmailWrongTitle] - message:[MatrixKitL10n accountErrorEmailWrongDescription] - preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *errorAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n accountErrorEmailWrongTitle] + message:[MatrixKitL10n accountErrorEmailWrongDescription] + preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [errorAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -3416,8 +3459,9 @@ TableViewSectionsDelegate> }]]; - [currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCAddEmailAlert"]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [errorAlert mxk_setAccessibilityIdentifier: @"SettingsVCAddEmailAlert"]; + [self presentViewController:errorAlert animated:YES completion:nil]; + currentAlert = errorAlert; return; } @@ -3509,11 +3553,11 @@ TableViewSectionsDelegate> [currentAlert dismissViewControllerAnimated:NO completion:nil]; __weak typeof(self) weakSelf = self; - currentAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n accountErrorMsisdnWrongTitle] - message:[MatrixKitL10n accountErrorMsisdnWrongDescription] - preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *errorAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n accountErrorMsisdnWrongTitle] + message:[MatrixKitL10n accountErrorMsisdnWrongDescription] + preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] + [errorAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { @@ -3525,8 +3569,9 @@ TableViewSectionsDelegate> }]]; - [currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCAddMsisdnAlert"]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [errorAlert mxk_setAccessibilityIdentifier: @"SettingsVCAddMsisdnAlert"]; + [self presentViewController:errorAlert animated:YES completion:nil]; + currentAlert = errorAlert; return; } @@ -3882,9 +3927,9 @@ TableViewSectionsDelegate> { [self->currentAlert dismissViewControllerAnimated:NO completion:nil]; - self->currentAlert = [UIAlertController alertControllerWithTitle:nil message:[VectorL10n settingsPasswordUpdated] preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *successAlert = [UIAlertController alertControllerWithTitle:nil message:[VectorL10n settingsPasswordUpdated] preferredStyle:UIAlertControllerStyleAlert]; - [self->currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] + [successAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { @@ -3904,8 +3949,9 @@ TableViewSectionsDelegate> }]]; - [self->currentAlert mxk_setAccessibilityIdentifier:@"SettingsVCOnPasswordUpdatedAlert"]; - [self presentViewController:self->currentAlert animated:YES completion:nil]; + [successAlert mxk_setAccessibilityIdentifier:@"SettingsVCOnPasswordUpdatedAlert"]; + [self presentViewController:successAlert animated:YES completion:nil]; + self->currentAlert = successAlert; } else { @@ -3930,9 +3976,9 @@ TableViewSectionsDelegate> { [self->currentAlert dismissViewControllerAnimated:NO completion:nil]; - self->currentAlert = [UIAlertController alertControllerWithTitle:nil message:[VectorL10n settingsFailToUpdatePassword] preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *errorAlert = [UIAlertController alertControllerWithTitle:nil message:[VectorL10n settingsFailToUpdatePassword] preferredStyle:UIAlertControllerStyleAlert]; - [self->currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] + [errorAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { @@ -3953,8 +3999,9 @@ TableViewSectionsDelegate> }]]; - [self->currentAlert mxk_setAccessibilityIdentifier:@"SettingsVCPasswordChangeFailedAlert"]; - [rootViewController presentViewController:self->currentAlert animated:YES completion:nil]; + [errorAlert mxk_setAccessibilityIdentifier:@"SettingsVCPasswordChangeFailedAlert"]; + [rootViewController presentViewController:errorAlert animated:YES completion:nil]; + self->currentAlert = errorAlert; } } diff --git a/Riot/Modules/Spaces/SpaceList/SpaceListViewModel.swift b/Riot/Modules/Spaces/SpaceList/SpaceListViewModel.swift index 3f9924531..62770e05e 100644 --- a/Riot/Modules/Spaces/SpaceList/SpaceListViewModel.swift +++ b/Riot/Modules/Spaces/SpaceList/SpaceListViewModel.swift @@ -131,6 +131,9 @@ final class SpaceListViewModel: SpaceListViewModelType { private func loadData() { guard let session = self.userSessionsService.mainUserSession?.matrixSession else { + // If there is no main session, reset current selection and give an empty section list + // It can happen when the user make a clear cache or logout + self.resetList() return } @@ -243,4 +246,15 @@ final class SpaceListViewModel: SpaceListViewModelType { return spaceViewData.spaceId } } + + private func resetList() { + self.sections = [] + + let selectedIndexPath = IndexPath(row: 0, section: 0) + + self.selectedIndexPath = selectedIndexPath + self.homeIndexPath = selectedIndexPath + + self.update(viewState: .loaded([])) + } } diff --git a/Riot/Modules/SplitView/SplitViewCoordinator.swift b/Riot/Modules/SplitView/SplitViewCoordinator.swift index 479ebf702..ee1ad5af7 100644 --- a/Riot/Modules/SplitView/SplitViewCoordinator.swift +++ b/Riot/Modules/SplitView/SplitViewCoordinator.swift @@ -125,20 +125,20 @@ final class SplitViewCoordinator: NSObject, SplitViewCoordinatorType { } // TODO: Do not expose publicly this method - func restorePlaceholderDetails() { + func resetDetails(animated: Bool) { // Be sure that the primary is then visible too. if splitViewController.displayMode == .primaryHidden { splitViewController.preferredDisplayMode = .allVisible } - self.resetDetailNavigationControllerWithPlaceholder(animated: false) + self.resetDetailNavigationController(animated: animated) // Release the current selected item (room/contact/group...). self.tabBarCoordinator?.releaseSelectedItems() - } + } func popToHome(animated: Bool, completion: (() -> Void)?) { - self.resetDetailNavigationControllerWithPlaceholder(animated: animated) + self.resetDetails(animated: animated) // Force back to the main screen if this is not the one that is displayed self.tabBarCoordinator?.popToHome(animated: animated, completion: completion) @@ -172,6 +172,17 @@ final class SplitViewCoordinator: NSObject, SplitViewCoordinatorType { // Set placeholder screen as root controller of detail navigation controller let placeholderDetailsVC = self.createPlaceholderDetailsViewController() detailNavigationRouter.setRootModule(placeholderDetailsVC, hideNavigationBar: false, animated: animated, popCompletion: nil) + } + + private func resetDetailNavigationController(animated: Bool) { + + if self.splitViewController.isCollapsed { + if let topMostNavigationController = self.selectedNavigationRouter?.modules.last as? UINavigationController, topMostNavigationController == self.detailNavigationController { + self.selectedNavigationRouter?.popModule(animated: animated) + } + } else { + self.resetDetailNavigationControllerWithPlaceholder(animated: animated) + } } private func isPlaceholderShown(from secondaryViewController: UIViewController) -> Bool { @@ -270,7 +281,7 @@ extension SplitViewCoordinator: UISplitViewControllerDelegate { } // Restore detail navigation controller with placeholder as root - self.resetDetailNavigationControllerWithPlaceholder(animated: false) + self.resetDetailNavigationController(animated: false) // Return up to date detail navigation controller // In any cases `detailNavigationController` will be used as secondary view of the split view controller. @@ -353,6 +364,6 @@ extension SplitViewCoordinator: SplitViewMasterPresentableDelegate { } func splitViewMasterPresentableWantsToResetDetail(_ presentable: Presentable) { - self.resetDetailNavigationControllerWithPlaceholder(animated: false) + self.resetDetails(animated: false) } } diff --git a/Riot/Modules/SplitView/SplitViewCoordinatorType.swift b/Riot/Modules/SplitView/SplitViewCoordinatorType.swift index e49a54879..4fd2cfef6 100644 --- a/Riot/Modules/SplitView/SplitViewCoordinatorType.swift +++ b/Riot/Modules/SplitView/SplitViewCoordinatorType.swift @@ -30,8 +30,10 @@ protocol SplitViewCoordinatorType: Coordinator, Presentable { /// - Parameter spaceId: The id of the Space to use. func start(with spaceId: String?) + /// Restore navigation stack and show home screen func popToHome(animated: Bool, completion: (() -> Void)?) - + // TODO: Do not expose publicly this method - func restorePlaceholderDetails() + /// Remove detail screens and display placeholder if needed + func resetDetails(animated: Bool) } diff --git a/changelog.d/4384.change b/changelog.d/4384.change deleted file mode 100644 index 9103529a3..000000000 --- a/changelog.d/4384.change +++ /dev/null @@ -1 +0,0 @@ -Using mutable room list fetch sort options after chaning them to be a structure. \ No newline at end of file diff --git a/changelog.d/4815.change b/changelog.d/4815.change deleted file mode 100644 index 757ff6d22..000000000 --- a/changelog.d/4815.change +++ /dev/null @@ -1 +0,0 @@ -Share Extension: Remove the image compression prompt when the showMediaSizeSelection setting is disabled. \ No newline at end of file diff --git a/changelog.d/4976.change b/changelog.d/4976.change deleted file mode 100644 index 7c52865d3..000000000 --- a/changelog.d/4976.change +++ /dev/null @@ -1 +0,0 @@ -Replaced GrowingTextView with simpler, custom implementation. Cleaned up the RoomInputToolbar header. \ No newline at end of file diff --git a/changelog.d/4987.misc b/changelog.d/4987.misc deleted file mode 100644 index ac7a294f3..000000000 --- a/changelog.d/4987.misc +++ /dev/null @@ -1 +0,0 @@ -Improve wording around rageshakes in the defect issue template. diff --git a/changelog.d/5041.bugfix b/changelog.d/5041.bugfix deleted file mode 100644 index 07882c073..000000000 --- a/changelog.d/5041.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fixed share extension and message forwarding room list accessory view icon. \ No newline at end of file diff --git a/changelog.d/5042.bugfix b/changelog.d/5042.bugfix deleted file mode 100644 index 481c4c053..000000000 --- a/changelog.d/5042.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fixed message composer not following keyboard when swiping to dismiss. \ No newline at end of file diff --git a/changelog.d/5055.bugfix b/changelog.d/5055.bugfix deleted file mode 100644 index a969f4fef..000000000 --- a/changelog.d/5055.bugfix +++ /dev/null @@ -1 +0,0 @@ -RoomVC: Fix retain cycles that prevents `RoomViewController` to be deallocated. \ No newline at end of file diff --git a/changelog.d/5057.bugfix b/changelog.d/5057.bugfix deleted file mode 100644 index b3f2b9744..000000000 --- a/changelog.d/5057.bugfix +++ /dev/null @@ -1 +0,0 @@ -Share Extension: Fix missing avatars and don't list spaces as rooms. \ No newline at end of file diff --git a/changelog.d/5058.bugfix b/changelog.d/5058.bugfix deleted file mode 100644 index 1e8112a36..000000000 --- a/changelog.d/5058.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix retain cycles that prevents deallocation in several classes. \ No newline at end of file diff --git a/changelog.d/5063.bugfix b/changelog.d/5063.bugfix deleted file mode 100644 index d1ee811c1..000000000 --- a/changelog.d/5063.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fixed retain cycles between the user suggestion coordinator and the suggestion service, and in the suggestion service currentTextTrigger subject sink. \ No newline at end of file