diff --git a/CHANGES.md b/CHANGES.md index d8ba1a0ad..5bd8b8d8f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,19 @@ +## Changes in 0.16.10 (2021-11-17) + +🙌 Improvements + +- Upgrade MatrixSDK version ([v0.20.10](https://github.com/matrix-org/matrix-ios-sdk/releases/tag/v0.20.10)). + +🐛 Bugfixes + +- MXKRoomViewController: Share sheet is properly presented on iOS 12 when necessary. ([#949](https://github.com/matrix-org/matrix-ios-kit/pull/949)) +- MXKRoomTitleView: Remove room summary observer on destroy. ([#951](https://github.com/matrix-org/matrix-ios-kit/pull/951)) +- MXKRoomViewController: Fix retain cycles that prevents deallocation. ([#5055](https://github.com/vector-im/element-ios/issues/5055)) +- Fix retain cycles that prevents deallocation in several classes. ([#5058](https://github.com/vector-im/element-ios/issues/5058)) +- Ensure alerts with weak references are retained until they've been presented. ([#5071](https://github.com/vector-im/element-ios/issues/5071)) +- Fix room ordering regression. ([#5105](https://github.com/vector-im/element-ios/issues/5105)) + + ## Changes in 0.16.9 (2021-10-21) 🙌 Improvements diff --git a/MatrixKit.podspec b/MatrixKit.podspec index 595b290d0..9461b2d8b 100644 --- a/MatrixKit.podspec +++ b/MatrixKit.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "MatrixKit" - s.version = "0.16.9" + s.version = "0.16.10" s.summary = "The Matrix reusable UI library for iOS based on MatrixSDK." s.description = <<-DESC @@ -23,7 +23,7 @@ Pod::Spec.new do |s| s.swift_version = '5.0' - s.dependency 'MatrixSDK', "= 0.20.9" + s.dependency 'MatrixSDK', "= 0.20.10" s.dependency 'HPGrowingTextView', '~> 1.1' s.dependency 'libPhoneNumber-iOS', '~> 0.9.13' s.dependency 'DTCoreText', '~> 1.6.25' diff --git a/MatrixKit/Assets/MatrixKitAssets.bundle/en.lproj/MatrixKit.strings b/MatrixKit/Assets/MatrixKitAssets.bundle/en.lproj/MatrixKit.strings index b97ed7514..f9e40406a 100644 --- a/MatrixKit/Assets/MatrixKitAssets.bundle/en.lproj/MatrixKit.strings +++ b/MatrixKit/Assets/MatrixKitAssets.bundle/en.lproj/MatrixKit.strings @@ -281,6 +281,8 @@ "attachment_multiselection_original" = "Actual Size"; "attachment_e2e_keys_file_prompt" = "This file contains encryption keys exported from a Matrix client.\nDo you want to view the file content or import the keys it contains?"; "attachment_e2e_keys_import" = "Import..."; +"attachment_unsupported_preview_title" = "Unable to preview"; +"attachment_unsupported_preview_message" = "This file type is not supported."; // Contacts "contact_mx_users" = "Matrix Users"; diff --git a/MatrixKit/Controllers/MXKAuthenticationViewController.h b/MatrixKit/Controllers/MXKAuthenticationViewController.h index 49a0edd93..ffb64afbe 100644 --- a/MatrixKit/Controllers/MXKAuthenticationViewController.h +++ b/MatrixKit/Controllers/MXKAuthenticationViewController.h @@ -146,7 +146,7 @@ /** The delegate for the view controller. */ -@property (nonatomic) id delegate; +@property (nonatomic, weak) id delegate; /** current ongoing MXHTTPOperation. Nil if none. diff --git a/MatrixKit/Controllers/MXKContactDetailsViewController.h b/MatrixKit/Controllers/MXKContactDetailsViewController.h index 3d2e13222..417f586a7 100644 --- a/MatrixKit/Controllers/MXKContactDetailsViewController.h +++ b/MatrixKit/Controllers/MXKContactDetailsViewController.h @@ -56,7 +56,7 @@ /** The delegate for the view controller. */ -@property (nonatomic) id delegate; +@property (nonatomic, weak) id delegate; #pragma mark - Class methods diff --git a/MatrixKit/Controllers/MXKContactListViewController.h b/MatrixKit/Controllers/MXKContactListViewController.h index 47de9e5e9..e516aa15d 100644 --- a/MatrixKit/Controllers/MXKContactListViewController.h +++ b/MatrixKit/Controllers/MXKContactListViewController.h @@ -62,7 +62,7 @@ /** The delegate for the view controller. */ -@property (nonatomic) id delegate; +@property (nonatomic, weak) id delegate; /** Enable the search option by adding a navigation item in the navigation bar (YES by default). diff --git a/MatrixKit/Controllers/MXKGroupListViewController.h b/MatrixKit/Controllers/MXKGroupListViewController.h index 14155eab1..020f78549 100644 --- a/MatrixKit/Controllers/MXKGroupListViewController.h +++ b/MatrixKit/Controllers/MXKGroupListViewController.h @@ -48,7 +48,7 @@ /** The fake top view displayed in case of vertical bounce. */ - UIView *topview; + __weak UIView *topview; } @property (weak, nonatomic) IBOutlet UISearchBar *groupsSearchBar; @@ -65,7 +65,7 @@ /** The delegate for the view controller. */ -@property (nonatomic) id delegate; +@property (nonatomic, weak) id delegate; /** Enable the search option by adding a navigation item in the navigation bar (YES by default). diff --git a/MatrixKit/Controllers/MXKGroupListViewController.m b/MatrixKit/Controllers/MXKGroupListViewController.m index 1d1e533d1..e9950fa3f 100644 --- a/MatrixKit/Controllers/MXKGroupListViewController.m +++ b/MatrixKit/Controllers/MXKGroupListViewController.m @@ -145,10 +145,11 @@ - (void)viewDidLoad // Add a top view which will be displayed in case of vertical bounce. CGFloat height = self.groupsTableView.frame.size.height; - topview = [[UIView alloc] initWithFrame:CGRectMake(0,-height,self.groupsTableView.frame.size.width,height)]; + UIView *topview = [[UIView alloc] initWithFrame:CGRectMake(0,-height,self.groupsTableView.frame.size.width,height)]; topview.autoresizingMask = UIViewAutoresizingFlexibleWidth; topview.backgroundColor = [UIColor groupTableViewBackgroundColor]; [self.groupsTableView addSubview:topview]; + self->topview = topview; } - (void)viewWillAppear:(BOOL)animated @@ -513,8 +514,13 @@ - (void)onSyncNotification { latestServerSync = [NSDate date]; + MXWeakify(self); + // Refresh all groups summary [self.dataSource refreshGroupsSummary:^{ + + MXStrongifyAndReturnIfNil(self); + [self removeReconnectingView]; }]; } diff --git a/MatrixKit/Controllers/MXKRecentListViewController.h b/MatrixKit/Controllers/MXKRecentListViewController.h index 39ff5de4c..da8d193f3 100644 --- a/MatrixKit/Controllers/MXKRecentListViewController.h +++ b/MatrixKit/Controllers/MXKRecentListViewController.h @@ -57,7 +57,7 @@ limitations under the License. /** The fake top view displayed in case of vertical bounce. */ - UIView *topview; + __weak UIView *topview; } @property (weak, nonatomic) IBOutlet UISearchBar *recentsSearchBar; @@ -74,7 +74,7 @@ limitations under the License. /** The delegate for the view controller. */ -@property (nonatomic) id delegate; +@property (nonatomic, weak) id delegate; /** Enable the search option by adding a navigation item in the navigation bar (YES by default). diff --git a/MatrixKit/Controllers/MXKRecentListViewController.m b/MatrixKit/Controllers/MXKRecentListViewController.m index 2ba7ae6c2..2f02f7e85 100644 --- a/MatrixKit/Controllers/MXKRecentListViewController.m +++ b/MatrixKit/Controllers/MXKRecentListViewController.m @@ -39,7 +39,7 @@ @interface MXKRecentListViewController () /** The reconnection animated view. */ - UIView* reconnectingView; + __weak UIView* reconnectingView; /** The current table view header if any. @@ -146,10 +146,11 @@ - (void)viewDidLoad // Add a top view which will be displayed in case of vertical bounce. CGFloat height = self.recentsTableView.frame.size.height; - topview = [[UIView alloc] initWithFrame:CGRectMake(0,-height,self.recentsTableView.frame.size.width,height)]; + UIView *topview = [[UIView alloc] initWithFrame:CGRectMake(0,-height,self.recentsTableView.frame.size.width,height)]; topview.autoresizingMask = UIViewAutoresizingFlexibleWidth; topview.backgroundColor = [UIColor groupTableViewBackgroundColor]; [self.recentsTableView addSubview:topview]; + self->topview = topview; } - (void)viewWillAppear:(BOOL)animated diff --git a/MatrixKit/Controllers/MXKRoomMemberDetailsViewController.h b/MatrixKit/Controllers/MXKRoomMemberDetailsViewController.h index 9d74a2ce0..6724f6998 100644 --- a/MatrixKit/Controllers/MXKRoomMemberDetailsViewController.h +++ b/MatrixKit/Controllers/MXKRoomMemberDetailsViewController.h @@ -142,7 +142,7 @@ typedef enum : NSUInteger /** The delegate for the view controller. */ -@property (nonatomic) id delegate; +@property (nonatomic, weak) id delegate; #pragma mark - Class methods diff --git a/MatrixKit/Controllers/MXKRoomViewController.h b/MatrixKit/Controllers/MXKRoomViewController.h index 718542260..8ae86eccb 100644 --- a/MatrixKit/Controllers/MXKRoomViewController.h +++ b/MatrixKit/Controllers/MXKRoomViewController.h @@ -54,12 +54,12 @@ typedef NS_ENUM(NSUInteger, MXKRoomViewControllerJoinRoomResult) { /** Potential event details view. */ - MXKEventDetailsView *eventDetailsView; + __weak MXKEventDetailsView *eventDetailsView; /** Current alert (if any). */ - UIAlertController *currentAlert; + __weak UIAlertController *currentAlert; /** The document interaction Controller used to share attachment @@ -138,12 +138,12 @@ typedef NS_ENUM(NSUInteger, MXKRoomViewControllerJoinRoomResult) { /** The current title view defined into the view controller. */ -@property (nonatomic, readonly) MXKRoomTitleView* titleView; +@property (nonatomic, weak, readonly) MXKRoomTitleView* titleView; /** The current input toolbar view defined into the view controller. */ -@property (nonatomic, readonly) MXKRoomInputToolbarView* inputToolbarView; +@property (nonatomic, weak, readonly) MXKRoomInputToolbarView* inputToolbarView; /** The current extra info view defined into the view controller. @@ -197,12 +197,12 @@ typedef NS_ENUM(NSUInteger, MXKRoomViewControllerJoinRoomResult) { This object is defined when the displayed room is left. It is added into the bubbles table header. This label is used to display the reason why the room has been left. */ -@property (nonatomic, readonly) UILabel *leftRoomReasonLabel; +@property (nonatomic, weak, readonly) UILabel *leftRoomReasonLabel; -@property (nonatomic) IBOutlet UITableView *bubblesTableView; -@property (nonatomic) IBOutlet UIView *roomTitleViewContainer; -@property (nonatomic) IBOutlet UIView *roomInputToolbarContainer; -@property (nonatomic) IBOutlet UIView *roomActivitiesContainer; +@property (weak, nonatomic) IBOutlet UITableView *bubblesTableView; +@property (weak, nonatomic) IBOutlet UIView *roomTitleViewContainer; +@property (weak, nonatomic) IBOutlet UIView *roomInputToolbarContainer; +@property (weak, nonatomic) IBOutlet UIView *roomActivitiesContainer; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *bubblesTableViewTopConstraint; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *bubblesTableViewBottomConstraint; diff --git a/MatrixKit/Controllers/MXKRoomViewController.m b/MatrixKit/Controllers/MXKRoomViewController.m index 49a7426bf..382373a92 100644 --- a/MatrixKit/Controllers/MXKRoomViewController.m +++ b/MatrixKit/Controllers/MXKRoomViewController.m @@ -284,8 +284,6 @@ - (void)viewDidLoad { [self shareEncryptionKeys]; } - - self.navigationController.delegate = self; } - (BOOL)prefersStatusBarHidden @@ -843,18 +841,21 @@ - (void)onTimelineError:(NSNotification *)notif [currentAlert dismissViewControllerAnimated:NO completion:nil]; __weak typeof(self) weakSelf = self; - currentAlert = [UIAlertController alertControllerWithTitle:errorTitle message:errorMessage preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *errorAlert = [UIAlertController alertControllerWithTitle:errorTitle + message:errorMessage + preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [errorAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; }]]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [self presentViewController:errorAlert animated:YES completion:nil]; + currentAlert = errorAlert; } } @@ -911,10 +912,15 @@ - (void)joinRoomWithRoomIdOrAlias:(NSString*)roomIdOrAlias self->joinRoomRequest = nil; [self stopActivityIndicator]; + MXWeakify(self); + // The room is now part of the user's room MXKRoomDataSourceManager *roomDataSourceManager = [MXKRoomDataSourceManager sharedManagerForMatrixSession:self.mainSession]; [roomDataSourceManager roomDataSourceForRoom:room.roomId create:YES onComplete:^(MXKRoomDataSource *newRoomDataSource) { + + MXStrongifyAndReturnIfNil(self); + // And can be displayed [self displayRoom:newRoomDataSource]; @@ -961,11 +967,13 @@ - (void)processRoomJoinFailureWithError:(NSError *)error completion:(void(^)(MXK MXWeakify(self); [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; @@ -976,7 +984,8 @@ - (void)processRoomJoinFailureWithError:(NSError *)error completion:(void(^)(MXK } }]]; - [self presentViewController:self->currentAlert animated:YES completion:nil]; + [self presentViewController:errorAlert animated:YES completion:nil]; + currentAlert = errorAlert; } - (void)leaveRoomOnEvent:(MXEvent*)event @@ -1056,8 +1065,7 @@ - (void)setRoomTitleViewClass:(Class)roomTitleViewClass [titleView destroy]; } - titleView = [roomTitleViewClass roomTitleView]; - + titleView = self.navigationItem.titleView = [roomTitleViewClass roomTitleView]; titleView.delegate = self; // Define directly the navigation titleView with the custom title view instance. Do not use anymore a container. @@ -1100,9 +1108,9 @@ - (void)setRoomInputToolbarViewClass:(Class)roomInputToolbarViewClass MXLogDebug(@"[MXKRoomVC] setRoomInputToolbarViewClass: Set inputToolbarView to class %@", roomInputToolbarViewClass); - inputToolbarView = [roomInputToolbarViewClass roomInputToolbarView]; - - inputToolbarView.delegate = self; + id inputToolbarView = [roomInputToolbarViewClass roomInputToolbarView]; + self->inputToolbarView = inputToolbarView; + self->inputToolbarView.delegate = self; // Add the input toolbar view and define edge constraints [_roomInputToolbarContainer addSubview:inputToolbarView]; @@ -1799,12 +1807,16 @@ - (void)triggerInitialBackPagination // Trigger back pagination to fill all the screen CGRect frame = [[UIScreen mainScreen] bounds]; + MXWeakify(self); + isPaginationInProgress = YES; [self startActivityIndicator]; [roomDataSource paginateToFillRect:frame direction:MXTimelineDirectionBackwards withMinRequestMessagesCount:_paginationLimit success:^{ + + MXStrongifyAndReturnIfNil(self); // Stop spinner self->isPaginationInProgress = NO; @@ -1866,6 +1878,8 @@ - (void)triggerInitialBackPagination self.bubbleTableViewDisplayInTransition = NO; } failure:^(NSError *error) { + + MXStrongifyAndReturnIfNil(self); // Stop spinner self->isPaginationInProgress = NO; @@ -1906,9 +1920,13 @@ - (void)triggerPagination:(NSUInteger)limit direction:(MXTimelineDirection)direc isPaginationInProgress = YES; + MXWeakify(self); + // Trigger pagination [roomDataSource paginate:limit direction:direction onlyFromStore:NO success:^(NSUInteger addedCellNumber) { + MXStrongifyAndReturnIfNil(self); + // We will adjust the vertical offset in order to unchange the current display (pagination should be inconspicuous) CGFloat verticalOffset = 0; @@ -1979,6 +1997,8 @@ - (void)triggerPagination:(NSUInteger)limit direction:(MXTimelineDirection)direc } failure:^(NSError *error) { + MXStrongifyAndReturnIfNil(self); + self.bubbleTableViewDisplayInTransition = YES; // Reload table on failure because some changes may have been ignored during pagination (see[dataSource:didCellChange:]) @@ -2002,9 +2022,13 @@ - (void)triggerAttachmentBackPagination:(NSString*)eventId isPaginationInProgress = YES; + MXWeakify(self); + // Trigger back pagination to find previous attachments [roomDataSource paginate:_paginationLimit direction:MXTimelineDirectionBackwards onlyFromStore:NO success:^(NSUInteger addedCellNumber) { + MXStrongifyAndReturnIfNil(self); + // Check whether attachments viewer is still visible if (self.attachmentsViewer) { @@ -2052,6 +2076,8 @@ - (void)triggerAttachmentBackPagination:(NSString*)eventId } failure:^(NSError *error) { + MXStrongifyAndReturnIfNil(self); + // Reload table on failure because some changes may have been ignored during back pagination (see[dataSource:didCellChange:]) self.bubbleTableViewDisplayInTransition = YES; self->isPaginationInProgress = NO; @@ -2088,6 +2114,8 @@ - (void)showEventDetails:(MXEvent *)event // Remove potential existing subviews [self dismissTemporarySubViews]; + MXKEventDetailsView *eventDetailsView; + if (customEventDetailsViewClass) { eventDetailsView = [[customEventDetailsViewClass alloc] initWithEvent:event andMatrixSession:roomDataSource.mxSession]; @@ -2105,6 +2133,8 @@ - (void)showEventDetails:(MXEvent *)event // Add the view and define edge constraints [self.view addSubview:eventDetailsView]; + self->eventDetailsView = eventDetailsView; + [self.view addConstraint:[NSLayoutConstraint constraintWithItem:eventDetailsView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual @@ -2163,20 +2193,22 @@ - (void)promptUserToResendEvent:(NSString *)eventId __weak typeof(self) weakSelf = self; - currentAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n resendMessage] message:textMessage preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *resendAlert = [UIAlertController alertControllerWithTitle:[MatrixKitL10n resendMessage] + message:textMessage + preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [resendAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [resendAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n ok] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; @@ -2186,7 +2218,8 @@ - (void)promptUserToResendEvent:(NSString *)eventId }]]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [self presentViewController:resendAlert animated:YES completion:nil]; + currentAlert = resendAlert; } } @@ -2605,20 +2638,22 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac } __weak __typeof(self) weakSelf = self; - currentAlert = [UIAlertController alertControllerWithTitle:nil message:[MatrixKitL10n attachmentCancelDownload] preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *cancelAlert = [UIAlertController alertControllerWithTitle:nil + message:[MatrixKitL10n attachmentCancelDownload] + preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n no] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [cancelAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n no] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n yes] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [cancelAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n yes] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; @@ -2635,7 +2670,8 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac }]]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [self presentViewController:cancelAlert animated:YES completion:nil]; + currentAlert = cancelAlert; } else if (roomBubbleTableViewCell.bubbleData.attachment.eventSentState == MXEventSentStatePreparing || roomBubbleTableViewCell.bubbleData.attachment.eventSentState == MXEventSentStateEncrypting || @@ -2652,20 +2688,22 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac } __weak __typeof(self) weakSelf = self; - currentAlert = [UIAlertController alertControllerWithTitle:nil message:[MatrixKitL10n attachmentCancelUpload] preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *cancelAlert = [UIAlertController alertControllerWithTitle:nil + message:[MatrixKitL10n attachmentCancelUpload] + preferredStyle:UIAlertControllerStyleAlert]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n no] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [cancelAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n no] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n yes] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [cancelAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n yes] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { // TODO cancel the attachment encryption if it is in progress. @@ -2692,7 +2730,8 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac }]]; - [self presentViewController:currentAlert animated:YES completion:nil]; + [self presentViewController:cancelAlert animated:YES completion:nil]; + currentAlert = cancelAlert; } } } @@ -2709,6 +2748,7 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac if (currentAlert) { [currentAlert dismissViewControllerAnimated:NO completion:nil]; + currentAlert = nil; // Cancel potential text selection in other bubbles for (MXKRoomBubbleTableViewCell *bubble in self.bubblesTableView.visibleCells) @@ -2718,14 +2758,14 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac } __weak __typeof(self) weakSelf = self; - currentAlert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; + UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; // Add actions for a failed event if (selectedEvent.sentState == MXEventSentStateFailed) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n resend] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n resend] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; @@ -2735,9 +2775,9 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac }]]; - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n delete] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n delete] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; @@ -2765,9 +2805,9 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac selectedComponent = nil; } - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n copy] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n copy] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; @@ -2789,9 +2829,9 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac if ([MXKAppSettings standardAppSettings].messageDetailsAllowSharing) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n share] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n share] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; @@ -2816,9 +2856,9 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac if (components.count > 1) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n selectAll] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n selectAll] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; @@ -2834,9 +2874,9 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac { if ([MXKAppSettings standardAppSettings].messageDetailsAllowSaving) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n save] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n save] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; @@ -2867,9 +2907,9 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac if (attachment.type != MXKAttachmentTypeSticker) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n copyButtonName] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n copyButtonName] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; @@ -2898,9 +2938,9 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac if ([MXKAppSettings standardAppSettings].messageDetailsAllowSharing) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n share] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n share] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; @@ -2942,9 +2982,9 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac NSString *uploadId = roomBubbleTableViewCell.bubbleData.attachment.contentURL; if ([MXMediaManager existingUploaderWithId:uploadId]) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancelUpload] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancelUpload] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { // TODO cancel the attachment encryption if it is in progress. @@ -2983,9 +3023,9 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac NSString *downloadId = roomBubbleTableViewCell.bubbleData.attachment.downloadId; if ([MXMediaManager existingDownloaderWithIdentifier:downloadId]) { - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancelDownload] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancelDownload] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; @@ -3003,9 +3043,9 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac } } - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n showDetails] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n showDetails] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; @@ -3019,9 +3059,9 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac }]]; } - [currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] - style:UIAlertActionStyleCancel - handler:^(UIAlertAction * action) { + [actionSheet addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n cancel] + style:UIAlertActionStyleCancel + handler:^(UIAlertAction * action) { typeof(self) self = weakSelf; self->currentAlert = nil; @@ -3032,15 +3072,12 @@ - (void)dataSource:(MXKDataSource *)dataSource didRecognizeAction:(NSString *)ac }]]; // Do not display empty action sheet - if (currentAlert.actions.count > 1) + if (actionSheet.actions.count > 1) { - [currentAlert popoverPresentationController].sourceView = roomBubbleTableViewCell; - [currentAlert popoverPresentationController].sourceRect = roomBubbleTableViewCell.bounds; - [self presentViewController:currentAlert animated:YES completion:nil]; - } - else - { - currentAlert = nil; + [actionSheet popoverPresentationController].sourceView = roomBubbleTableViewCell; + [actionSheet popoverPresentationController].sourceRect = roomBubbleTableViewCell.bounds; + [self presentViewController:actionSheet animated:YES completion:nil]; + currentAlert = actionSheet; } } } @@ -3521,14 +3558,20 @@ - (void)handleTypingNotification:(BOOL)typing lastTypingDate = nil; } + MXWeakify(self); + // Send typing notification to server [roomDataSource.room sendTypingNotification:typing timeout:notificationTimeoutMS success:^{ + + MXStrongifyAndReturnIfNil(self); // Reset last typing date self->lastTypingDate = nil; } failure:^(NSError *error) { + MXStrongifyAndReturnIfNil(self); + MXLogDebug(@"[MXKRoomVC] Failed to send typing notification (%d)", typing); // Cancel timer (if any) @@ -3635,7 +3678,47 @@ - (void)showAttachmentInCell:(UITableViewCell*)cell [self stopActivityIndicator]; + MXWeakify(self); void(^viewAttachment)(void) = ^() { + + MXStrongifyAndReturnIfNil(self); + + if (![self canPreviewFileAttachment:selectedAttachment withLocalFileURL:fileURL]) + { + // When we don't support showing a preview for a file, show a share + // sheet if allowed, otherwise display an error to inform the user. + if (self.allowActionsInDocumentPreview) + { + UIActivityViewController *shareSheet = [[UIActivityViewController alloc] initWithActivityItems:@[fileURL] + applicationActivities:nil]; + MXWeakify(self); + shareSheet.completionWithItemsHandler = ^(UIActivityType activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) { + MXStrongifyAndReturnIfNil(self); + [selectedAttachment onShareEnded]; + self->currentSharedAttachment = nil; + }; + + self->currentSharedAttachment = selectedAttachment; + [self presentViewController:shareSheet animated:YES completion:nil]; + } + else + { + UIAlertController *alert = [UIAlertController alertControllerWithTitle:MatrixKitL10n.attachmentUnsupportedPreviewTitle + message:MatrixKitL10n.attachmentUnsupportedPreviewMessage + preferredStyle:UIAlertControllerStyleAlert]; + MXWeakify(self); + [alert addAction:[UIAlertAction actionWithTitle:MatrixKitL10n.ok style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { + MXStrongifyAndReturnIfNil(self); + [selectedAttachment onShareEnded]; + self->currentAlert = nil; + }]]; + + [self presentViewController:alert animated:YES completion:nil]; + self->currentAlert = alert; + } + + return; + } if (self.allowActionsInDocumentPreview) { @@ -3673,11 +3756,13 @@ - (void)showAttachmentInCell:(UITableViewCell*)cell [self->currentAlert dismissViewControllerAnimated:NO completion:nil]; __weak typeof(self) weakSelf = self; - self->currentAlert = [UIAlertController alertControllerWithTitle:@"" message:[MatrixKitL10n attachmentE2eKeysFilePrompt] preferredStyle:UIAlertControllerStyleAlert]; + UIAlertController *keysPrompt = [UIAlertController alertControllerWithTitle:@"" + message:[MatrixKitL10n attachmentE2eKeysFilePrompt] + preferredStyle:UIAlertControllerStyleAlert]; - [self->currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n view] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [keysPrompt addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n view] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { // View file content if (weakSelf) @@ -3690,9 +3775,9 @@ - (void)showAttachmentInCell:(UITableViewCell*)cell }]]; - [self->currentAlert addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n attachmentE2eKeysImport] - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { + [keysPrompt addAction:[UIAlertAction actionWithTitle:[MatrixKitL10n attachmentE2eKeysImport] + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { if (weakSelf) { @@ -3716,7 +3801,8 @@ - (void)showAttachmentInCell:(UITableViewCell*)cell }]]; - [self presentViewController:self->currentAlert animated:YES completion:nil]; + [self presentViewController:keysPrompt animated:YES completion:nil]; + self->currentAlert = keysPrompt; } else { @@ -3743,6 +3829,35 @@ - (void)showAttachmentInCell:(UITableViewCell*)cell } } +- (BOOL)canPreviewFileAttachment:(MXKAttachment *)attachment withLocalFileURL:(NSURL *)localFileURL +{ + // Sanity check. + if (![NSFileManager.defaultManager isReadableFileAtPath:localFileURL.path]) + { + return NO; + } + + if (UIDevice.currentDevice.systemVersion.floatValue >= 13) + { + return YES; + } + + MXKUTI *attachmentUTI = attachment.uti; + MXKUTI *fileUTI = [[MXKUTI alloc] initWithLocalFileURL:localFileURL]; + if (!attachmentUTI || !fileUTI) + { + return NO; + } + + NSArray *unsupportedUTIs = @[MXKUTI.html, MXKUTI.xml, MXKUTI.svg]; + if ([attachmentUTI conformsToAnyOf:unsupportedUTIs] || [fileUTI conformsToAnyOf:unsupportedUTIs]) + { + return NO; + } + + return YES; +} + #pragma mark - MXKAttachmentsViewControllerDelegate - (BOOL)attachmentsViewController:(MXKAttachmentsViewController*)attachmentsViewController paginateAttachmentBefore:(NSString*)eventId diff --git a/MatrixKit/Generated/Strings.swift b/MatrixKit/Generated/Strings.swift index 7f4279e3e..e5c1e7f31 100644 --- a/MatrixKit/Generated/Strings.swift +++ b/MatrixKit/Generated/Strings.swift @@ -159,6 +159,14 @@ public class MatrixKitL10n: NSObject { public static func attachmentSmallWithResolution(_ p1: String, _ p2: String) -> String { return MatrixKitL10n.tr("attachment_small_with_resolution", p1, p2) } + /// This file type is not supported. + public static var attachmentUnsupportedPreviewMessage: String { + return MatrixKitL10n.tr("attachment_unsupported_preview_message") + } + /// Unable to preview + public static var attachmentUnsupportedPreviewTitle: String { + return MatrixKitL10n.tr("attachment_unsupported_preview_title") + } /// Invalid username public static var authInvalidUserName: String { return MatrixKitL10n.tr("auth_invalid_user_name") diff --git a/MatrixKit/MatrixKitVersion.m b/MatrixKit/MatrixKitVersion.m index 7e9e79525..1ba29cf68 100644 --- a/MatrixKit/MatrixKitVersion.m +++ b/MatrixKit/MatrixKitVersion.m @@ -16,4 +16,4 @@ #import -NSString *const MatrixKitVersion = @"0.16.9"; +NSString *const MatrixKitVersion = @"0.16.10"; diff --git a/MatrixKit/Models/Group/MXKGroupCellDataStoring.h b/MatrixKit/Models/Group/MXKGroupCellDataStoring.h index f6a07b3f6..9ca2bd57b 100644 --- a/MatrixKit/Models/Group/MXKGroupCellDataStoring.h +++ b/MatrixKit/Models/Group/MXKGroupCellDataStoring.h @@ -26,7 +26,7 @@ */ @protocol MXKGroupCellDataStoring -@property (nonatomic, readonly) MXKSessionGroupsDataSource *groupsDataSource; +@property (nonatomic, weak, readonly) MXKSessionGroupsDataSource *groupsDataSource; @property (nonatomic, readonly) MXGroup *group; diff --git a/MatrixKit/Models/MXKAppSettings.m b/MatrixKit/Models/MXKAppSettings.m index 7365fc8c2..22b48f831 100644 --- a/MatrixKit/Models/MXKAppSettings.m +++ b/MatrixKit/Models/MXKAppSettings.m @@ -182,6 +182,7 @@ -(instancetype)init kMXEventTypeStringRoomCreate, // Without any messages, calls or stickers an event is needed to provide a date. kMXEventTypeStringRoomEncrypted, // Show a UTD string rather than the previous message. kMXEventTypeStringRoomMessage, + kMXEventTypeStringRoomMember, kMXEventTypeStringCallInvite, kMXEventTypeStringCallAnswer, kMXEventTypeStringCallHangup, diff --git a/MatrixKit/Models/Room/MXKAttachment.h b/MatrixKit/Models/Room/MXKAttachment.h index 3e8c7b51b..07e878161 100644 --- a/MatrixKit/Models/Room/MXKAttachment.h +++ b/MatrixKit/Models/Room/MXKAttachment.h @@ -18,6 +18,8 @@ #import #import +@class MXKUTI; + NS_ASSUME_NONNULL_BEGIN extern NSString * const kMXKAttachmentErrorDomain; @@ -114,6 +116,11 @@ typedef enum : NSUInteger { */ @property (nonatomic, readonly) BOOL isEncrypted; +/** + The UTI of this attachment. + */ +@property (nonatomic, readonly, nullable) MXKUTI *uti; + /** Create a `MXKAttachment` instance for the passed event. The created instance copies the current data of the event (content, event id, sent state...). diff --git a/MatrixKit/Models/Room/MXKAttachment.m b/MatrixKit/Models/Room/MXKAttachment.m index 10355b3c4..e15fd70b3 100644 --- a/MatrixKit/Models/Room/MXKAttachment.m +++ b/MatrixKit/Models/Room/MXKAttachment.m @@ -653,6 +653,11 @@ - (void)copy:(void (^)(void))onSuccess failure:(void (^)(NSError *error))onFailu } failure:onFailure]; } +- (MXKUTI *)uti +{ + return [[MXKUTI alloc] initWithMimeType:mimetype]; +} + - (void)prepareShare:(void (^)(NSURL *fileURL))onReadyToShare failure:(void (^)(NSError *error))onFailure { MXWeakify(self); diff --git a/MatrixKit/Models/Room/MXKRoomBubbleCellData.h b/MatrixKit/Models/Room/MXKRoomBubbleCellData.h index eb64f0bea..691f092e6 100644 --- a/MatrixKit/Models/Room/MXKRoomBubbleCellData.h +++ b/MatrixKit/Models/Room/MXKRoomBubbleCellData.h @@ -34,7 +34,7 @@ /** The data source owner of this instance. */ - MXKRoomDataSource *roomDataSource; + __weak MXKRoomDataSource *roomDataSource; /** Array of bubble components. Each bubble is supposed to have at least one component. diff --git a/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m b/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m index f1dce0891..67406b8f9 100644 --- a/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m +++ b/MatrixKit/Utils/EventFormatter/MXKEventFormatter.m @@ -1944,13 +1944,6 @@ - (BOOL)session:(MXSession *)session updateRoomSummary:(MXRoomSummary *)summary MXKEventFormatterError error; NSString *lastMessageString = [self stringFromEvent:event withRoomState:roomState error:&error]; - if ([event.type isEqualToString:kMXEventTypeStringRoomCreate]) - { - // Temporarily fallback to the room joined notice when the last event is for the room's creation. - // This will be improved as part of https://github.com/vector-im/element-ios/issues/4918 - lastMessageString = MatrixKitL10n.noticeRoomJoinByYou; - } - if (0 == lastMessageString.length) { // @TODO: there is a conflict with what [defaultRoomSummaryUpdater updateRoomSummary] did :/ diff --git a/MatrixKit/Utils/MXKUTI.swift b/MatrixKit/Utils/MXKUTI.swift index aea659556..911beec65 100644 --- a/MatrixKit/Utils/MXKUTI.swift +++ b/MatrixKit/Utils/MXKUTI.swift @@ -104,6 +104,20 @@ open class MXKUTI: NSObject, RawRepresentable { public func conforms(to otherUTI: MXKUTI) -> Bool { return self.utiWrapper.conforms(to: otherUTI.utiWrapper) } + + /// Check whether the current UTI conforms to any UTIs within an array. + /// + /// - Parameter otherUTIs: UTI which to conform with. + /// - Returns: true if self conforms to any of the other UTIs. + public func conformsToAny(of otherUTIs: [MXKUTI]) -> Bool { + for uti in otherUTIs { + if conforms(to: uti) { + return true + } + } + + return false + } } // MARK: - Other convenients initializers @@ -169,11 +183,14 @@ extension MXKUTI { public static let image = MXKUTI(cfRawValue: kUTTypeImage)! public static let png = MXKUTI(cfRawValue: kUTTypePNG)! public static let jpeg = MXKUTI(cfRawValue: kUTTypeJPEG)! + public static let svg = MXKUTI(cfRawValue: kUTTypeScalableVectorGraphics)! public static let url = MXKUTI(cfRawValue: kUTTypeURL)! public static let fileUrl = MXKUTI(cfRawValue: kUTTypeFileURL)! + public static let html = MXKUTI(cfRawValue: kUTTypeHTML)! + public static let xml = MXKUTI(cfRawValue: kUTTypeXML)! } -// MARK: - Convenients static methods +// MARK: - Convenience static methods extension MXKUTI { public static func mimeType(from fileExtension: String) -> String? { diff --git a/MatrixKit/Views/Authentication/MXKAuthInputsView.h b/MatrixKit/Views/Authentication/MXKAuthInputsView.h index 8131d4c0a..c71b022ae 100644 --- a/MatrixKit/Views/Authentication/MXKAuthInputsView.h +++ b/MatrixKit/Views/Authentication/MXKAuthInputsView.h @@ -122,7 +122,7 @@ typedef enum { /** The view delegate. */ -@property (nonatomic) id delegate; +@property (nonatomic, weak) id delegate; /** The current authentication type (`MXKAuthenticationTypeLogin` by default). diff --git a/MatrixKit/Views/DeviceView/MXKDeviceView.h b/MatrixKit/Views/DeviceView/MXKDeviceView.h index a729b1470..9e69cc1a7 100644 --- a/MatrixKit/Views/DeviceView/MXKDeviceView.h +++ b/MatrixKit/Views/DeviceView/MXKDeviceView.h @@ -69,7 +69,7 @@ /** The delegate. */ -@property (nonatomic) id delegate; +@property (nonatomic, weak) id delegate; /** The default text color in the text view. [UIColor blackColor] by default. diff --git a/MatrixKit/Views/EncryptionInfoView/MXKEncryptionInfoView.h b/MatrixKit/Views/EncryptionInfoView/MXKEncryptionInfoView.h index e55a7fdbe..80afc81e1 100644 --- a/MatrixKit/Views/EncryptionInfoView/MXKEncryptionInfoView.h +++ b/MatrixKit/Views/EncryptionInfoView/MXKEncryptionInfoView.h @@ -48,7 +48,7 @@ @property (weak, nonatomic) IBOutlet UIButton *blockButton; @property (weak, nonatomic) IBOutlet UIButton *confirmVerifyButton; -@property (nonatomic) id delegate; +@property (nonatomic, weak) id delegate; /** Initialise an `MXKEncryptionInfoView` instance based on an encrypted event diff --git a/MatrixKit/Views/MXKRoomCreationView.h b/MatrixKit/Views/MXKRoomCreationView.h index 46d296194..f269dbe87 100644 --- a/MatrixKit/Views/MXKRoomCreationView.h +++ b/MatrixKit/Views/MXKRoomCreationView.h @@ -68,7 +68,7 @@ /** The delegate. */ -@property (nonatomic) id delegate; +@property (nonatomic, weak) id delegate; /** Hide room name field (NO by default). diff --git a/MatrixKit/Views/RoomTitle/MXKRoomTitleView.m b/MatrixKit/Views/RoomTitle/MXKRoomTitleView.m index 243950124..5ea74fc37 100644 --- a/MatrixKit/Views/RoomTitle/MXKRoomTitleView.m +++ b/MatrixKit/Views/RoomTitle/MXKRoomTitleView.m @@ -28,7 +28,7 @@ @interface MXKRoomTitleView () { // Observer kMXRoomSummaryDidChangeNotification to keep updated the room name. - id mxRoomSummaryDidChangeObserver; + __weak id mxRoomSummaryDidChangeObserver; } @end @@ -96,6 +96,12 @@ - (void)destroy { self.delegate = nil; self.mxRoom = nil; + + if (mxRoomSummaryDidChangeObserver) + { + [NSNotificationCenter.defaultCenter removeObserver:mxRoomSummaryDidChangeObserver]; + mxRoomSummaryDidChangeObserver = nil; + } } - (void)dismissKeyboard @@ -120,9 +126,13 @@ - (void)setMxRoom:(MXRoom *)mxRoom if (mxRoom) { + MXWeakify(self); + // Register a listener to handle the room name change mxRoomSummaryDidChangeObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kMXRoomSummaryDidChangeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) { + MXStrongifyAndReturnIfNil(self); + // Check whether the text field is editing before refreshing title view if (!self.isEditing) { diff --git a/Podfile b/Podfile index 189fd1cbb..d7cb4ce03 100644 --- a/Podfile +++ b/Podfile @@ -8,7 +8,7 @@ abstract_target 'MatrixKitSamplePods' do # Different flavours of pods to Matrix SDK # The tagged version on which this version of MatrixKit has been built - pod 'MatrixSDK', '= 0.20.9' + pod 'MatrixSDK', '= 0.20.10' # The lastest release available on the CocoaPods repository #pod 'MatrixSDK' diff --git a/Podfile.lock b/Podfile.lock index 53ea062fc..d377ff7b2 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -39,9 +39,9 @@ PODS: - JSQSystemSoundPlayer (2.0.1) - libbase58 (0.1.4) - libPhoneNumber-iOS (0.9.15) - - MatrixSDK (0.20.9): - - MatrixSDK/Core (= 0.20.9) - - MatrixSDK/Core (0.20.9): + - 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) @@ -65,7 +65,7 @@ DEPENDENCIES: - HPGrowingTextView (~> 1.1) - JSQMessagesViewController (~> 7.3.5) - libPhoneNumber-iOS (~> 0.9.13) - - MatrixSDK (= 0.20.9) + - MatrixSDK (= 0.20.10) - SwiftGen (~> 6.3) SPEC REPOS: @@ -97,12 +97,12 @@ SPEC CHECKSUMS: JSQSystemSoundPlayer: c5850e77a4363ffd374cd851154b9af93264ed8d libbase58: 7c040313537b8c44b6e2d15586af8e21f7354efd libPhoneNumber-iOS: 0a32a9525cf8744fe02c5206eb30d571e38f7d75 - MatrixSDK: 9e312e3874027bf9eab61be7d0779102f8bd323a + MatrixSDK: 0e2ed8fc6f004cac4b4ab46f038a86fe49ce4007 OLMKit: 9fb4799c4a044dd2c06bda31ec31a12191ad30b5 Realm: b6027801398f3743fc222f096faa85281b506e6c SwiftGen: a6d22010845f08fe18fbdf3a07a8e380fd22e0ea SwiftyBeaver: 84069991dd5dca07d7069100985badaca7f0ce82 -PODFILE CHECKSUM: d9157cfcdbe95d4c55d08cfdfb27286e2bb643e0 +PODFILE CHECKSUM: 52ecdadffcff0d873e111bf272eddb813796523e -COCOAPODS: 1.10.1 +COCOAPODS: 1.11.2 diff --git a/README.rst b/README.rst index d8f74596b..214d0c904 100644 --- a/README.rst +++ b/README.rst @@ -1,3 +1,12 @@ +Deprecated +========= + +The MatrixKit will no longer be supported, the code will be merged into `Element iOS +`_ repository. + +Please avoid to create issues or PR in this repository, report them to `Element iOS +`_ instead. + MatrixKit =========