mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
RoomVC: Add a delegate, factorize and reduce usage of AppDelegate.
This commit is contained in:
parent
7adab0477c
commit
6abab61531
2 changed files with 313 additions and 83 deletions
|
@ -28,41 +28,48 @@
|
|||
#import "UIViewController+RiotSearch.h"
|
||||
|
||||
@class BadgeLabel;
|
||||
@protocol RoomViewControllerDelegate;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
Notification string used to indicate call tile tapped in a room. Notification object will be the `RoomBubbleCellData` object.
|
||||
*/
|
||||
extern NSNotificationName const RoomCallTileTappedNotification;
|
||||
extern NSNotificationName const _Nonnull RoomCallTileTappedNotification;
|
||||
|
||||
/**
|
||||
Notification string used to indicate group call tile tapped in a room. Notification object will be the `RoomBubbleCellData` object.
|
||||
*/
|
||||
extern NSNotificationName const RoomGroupCallTileTappedNotification;
|
||||
extern NSNotificationName const _Nonnull RoomGroupCallTileTappedNotification;
|
||||
|
||||
@interface RoomViewController : MXKRoomViewController
|
||||
|
||||
|
||||
// The delegate for the view controller.
|
||||
@property (weak, nonatomic, nullable) id<RoomViewControllerDelegate> delegate;
|
||||
|
||||
// The preview header
|
||||
@property (weak, nonatomic) IBOutlet UIView *previewHeaderContainer;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *previewHeaderContainerHeightConstraint;
|
||||
@property (weak, nonatomic, nullable) IBOutlet UIView *previewHeaderContainer;
|
||||
@property (weak, nonatomic, nullable) IBOutlet NSLayoutConstraint *previewHeaderContainerHeightConstraint;
|
||||
|
||||
// The jump to last unread banner
|
||||
@property (weak, nonatomic) IBOutlet UIView *jumpToLastUnreadBannerContainer;
|
||||
@property (weak, nonatomic) IBOutlet UIView *jumpToLastUnreadBanner;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *jumpToLastUnreadImageView;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *jumpToLastUnreadButton;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *jumpToLastUnreadLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *resetReadMarkerButton;
|
||||
@property (weak, nonatomic) IBOutlet UIView *inputBackgroundView;
|
||||
@property (weak, nonatomic) IBOutlet UIButton *scrollToBottomButton;
|
||||
@property (weak, nonatomic) IBOutlet BadgeLabel *scrollToBottomBadgeLabel;
|
||||
@property (weak, nonatomic, nullable) IBOutlet UIView *jumpToLastUnreadBannerContainer;
|
||||
@property (weak, nonatomic, nullable) IBOutlet UIView *jumpToLastUnreadBanner;
|
||||
@property (weak, nonatomic, nullable) IBOutlet UIImageView *jumpToLastUnreadImageView;
|
||||
@property (weak, nonatomic, nullable) IBOutlet UIButton *jumpToLastUnreadButton;
|
||||
@property (weak, nonatomic, nullable) IBOutlet UILabel *jumpToLastUnreadLabel;
|
||||
@property (weak, nonatomic, nullable) IBOutlet UIButton *resetReadMarkerButton;
|
||||
@property (weak, nonatomic, nullable) IBOutlet UIView *inputBackgroundView;
|
||||
@property (weak, nonatomic, nullable) IBOutlet UIButton *scrollToBottomButton;
|
||||
@property (weak, nonatomic, nullable) IBOutlet BadgeLabel *scrollToBottomBadgeLabel;
|
||||
|
||||
// Remove Jitsi widget container
|
||||
@property (weak, nonatomic) IBOutlet UIView *removeJitsiWidgetContainer;
|
||||
@property (weak, nonatomic, nullable) IBOutlet UIView *removeJitsiWidgetContainer;
|
||||
|
||||
/**
|
||||
Preview data for a room invitation received by email, or a link to a room.
|
||||
*/
|
||||
@property (nonatomic, readonly) RoomPreviewData *roomPreviewData;
|
||||
@property (nonatomic, readonly, nullable) RoomPreviewData *roomPreviewData;
|
||||
|
||||
/**
|
||||
Tell whether a badge must be added next to the chevron (back button) showing number of unread rooms.
|
||||
|
@ -77,7 +84,7 @@ extern NSNotificationName const RoomGroupCallTileTappedNotification;
|
|||
|
||||
@param roomPreviewData the data for the room preview.
|
||||
*/
|
||||
- (void)displayRoomPreview:(RoomPreviewData*)roomPreviewData;
|
||||
- (void)displayRoomPreview:(nonnull RoomPreviewData*)roomPreviewData;
|
||||
|
||||
/**
|
||||
Action used to handle some buttons.
|
||||
|
@ -86,5 +93,100 @@ extern NSNotificationName const RoomGroupCallTileTappedNotification;
|
|||
|
||||
- (IBAction)scrollToBottomAction:(id)sender;
|
||||
|
||||
/**
|
||||
Creates and returns a new `RoomViewController` object.
|
||||
|
||||
@return An initialized `RoomViewController` object.
|
||||
*/
|
||||
+ (nonnull instancetype)instantiate;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
`RoomViewController` delegate.
|
||||
*/
|
||||
@protocol RoomViewControllerDelegate <NSObject>
|
||||
|
||||
/**
|
||||
Tells the delegate that the user wants to open the room details (members, files, settings).
|
||||
|
||||
@param roomViewController the `RoomViewController` instance.
|
||||
*/
|
||||
- (void)roomViewControllerShowRoomDetails:(nonnull RoomViewController *)roomViewController;
|
||||
|
||||
/**
|
||||
Tells the delegate that the user wants to display the details of a room member.
|
||||
|
||||
@param roomViewController the `RoomViewController` instance.
|
||||
@param roomMember the selected member
|
||||
*/
|
||||
- (void)roomViewController:(nonnull RoomViewController *)roomViewController
|
||||
showMemberDetails:(nonnull MXRoomMember *)roomMember;
|
||||
|
||||
/**
|
||||
Tells the delegate that the user wants to display another room.
|
||||
|
||||
@param roomViewController the `RoomViewController` instance.
|
||||
@param roomID the selected roomId
|
||||
*/
|
||||
- (void)roomViewController:(nonnull RoomViewController *)roomViewController
|
||||
showRoomWithId:(nonnull NSString *)roomID;
|
||||
|
||||
/**
|
||||
Tells the delegate that the user wants to start a direct chat with a user.
|
||||
|
||||
@param roomViewController the `RoomViewController` instance.
|
||||
@param userId the selected user id
|
||||
@param completion Blocks called when the chat is created.
|
||||
*/
|
||||
- (void)roomViewController:(nonnull RoomViewController *)roomViewController
|
||||
startChatWithUserId:(NSString*)userId
|
||||
completion:(void (^)(void))completion;
|
||||
|
||||
/**
|
||||
Tells the delegate that the user wants to show complete security screen.
|
||||
|
||||
@param roomViewController the `RoomViewController` instance.
|
||||
@param session The selected Matrix session.
|
||||
*/
|
||||
- (void)roomViewController:(nonnull RoomViewController *)roomViewController showCompleteSecurityForSession:(MXSession*)session;
|
||||
|
||||
/**
|
||||
Tells the delegate that the user leaved the room.
|
||||
|
||||
@param roomViewController the `RoomViewController` instance.
|
||||
*/
|
||||
- (void)roomViewControllerDidLeaveRoom:(nonnull RoomViewController *)roomViewController;
|
||||
|
||||
/**
|
||||
Tells the delegate that the user wants to cancel the room preview.
|
||||
|
||||
@param roomViewController the `RoomViewController` instance.
|
||||
*/
|
||||
- (void)roomViewControllerPreviewDidTapCancel:(nonnull RoomViewController *)roomViewController;
|
||||
|
||||
/**
|
||||
Handle the fragment of a universal link.
|
||||
|
||||
@param roomViewController the `RoomViewController` instance.
|
||||
@param fragment the fragment part of the universal link.
|
||||
@param universalLinkURL the unprocessed the universal link URL (optional).
|
||||
@return true to indicate that the fragment has been handled, or false when the fragment is not supported.
|
||||
*/
|
||||
- (BOOL)roomViewController:(nonnull RoomViewController *)roomViewController
|
||||
handleUniversalLinkFragment:(nonnull NSString*)fragment
|
||||
fromURL:(nullable NSURL*)universalLinkURL;
|
||||
|
||||
/**
|
||||
Process universal link.
|
||||
|
||||
@param roomViewController the `RoomViewController` instance.
|
||||
@param universalLinkURL the unprocessed the universal link URL (optional).
|
||||
@return YES in case of processing success.
|
||||
*/
|
||||
- (BOOL)roomViewController:(nonnull RoomViewController *)roomViewController
|
||||
handleUniversalLinkURL:(NSURL*)universalLinkURL;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -261,6 +261,12 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
bundle:[NSBundle bundleForClass:self.class]];
|
||||
}
|
||||
|
||||
+ (instancetype)instantiate
|
||||
{
|
||||
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
|
||||
return [storyboard instantiateViewControllerWithIdentifier:@"RoomViewControllerStoryboardId"];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil
|
||||
|
@ -656,7 +662,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
self.keyboardHeight = MAX(self.keyboardHeight, 0);
|
||||
|
||||
if (hasJitsiCall &&
|
||||
![[AppDelegate theDelegate].callPresenter.jitsiVC.widget.roomId isEqualToString:self.roomDataSource.roomId])
|
||||
!self.isRoomHavingAJitsiCall)
|
||||
{
|
||||
// the room had a Jitsi call before, but not now
|
||||
hasJitsiCall = NO;
|
||||
|
@ -691,9 +697,8 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
[[NSNotificationCenter defaultCenter] removeObserver:mxEventDidDecryptNotificationObserver];
|
||||
mxEventDidDecryptNotificationObserver = nil;
|
||||
}
|
||||
|
||||
JitsiViewController *jitsiVC = [AppDelegate theDelegate].callPresenter.jitsiVC;
|
||||
if ([jitsiVC.widget.roomId isEqualToString:self.roomDataSource.roomId])
|
||||
|
||||
if (self.isRoomHavingAJitsiCall)
|
||||
{
|
||||
hasJitsiCall = YES;
|
||||
[self reloadBubblesTable:YES];
|
||||
|
@ -1081,7 +1086,14 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
|
||||
[super leaveRoomOnEvent:event];
|
||||
|
||||
[[LegacyAppDelegate theDelegate] restoreInitialDisplay:nil];
|
||||
if (self.delegate)
|
||||
{
|
||||
[self.delegate roomViewControllerDidLeaveRoom:self];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[AppDelegate theDelegate] restoreInitialDisplay:nil];
|
||||
}
|
||||
}
|
||||
|
||||
// Set the input toolbar according to the current display
|
||||
|
@ -1196,15 +1208,14 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
{
|
||||
// TODO: /join command does not support via parameters yet
|
||||
[self.mainSession joinRoom:roomAlias viaServers:nil success:^(MXRoom *room) {
|
||||
|
||||
// Show the room
|
||||
[[AppDelegate theDelegate] showRoom:room.roomId andEventId:nil withMatrixSession:self.mainSession];
|
||||
|
||||
[self showRoomWithId:room.roomId];
|
||||
|
||||
} failure:^(NSError *error) {
|
||||
|
||||
MXLogDebug(@"[RoomVC] Join roomAlias (%@) failed", roomAlias);
|
||||
//Alert user
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
[self showError:error];
|
||||
|
||||
}];
|
||||
}
|
||||
|
@ -1548,8 +1559,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
// video call button for Jitsi call
|
||||
if (self.isCallActive)
|
||||
{
|
||||
JitsiViewController *jitsiVC = [AppDelegate theDelegate].callPresenter.jitsiVC;
|
||||
if ([jitsiVC.widget.roomId isEqualToString:self.roomDataSource.roomId])
|
||||
if (self.isRoomHavingAJitsiCall)
|
||||
{
|
||||
// show a disabled call button
|
||||
UIBarButtonItem *item = [self videoCallBarButtonItem];
|
||||
|
@ -1945,7 +1955,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
} failure:^(NSError * _Nonnull error) {
|
||||
|
||||
MXLogDebug(@"[RoomVC] Cannot display widget %@", widget);
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
[self showError:error];
|
||||
}];
|
||||
}
|
||||
else
|
||||
|
@ -2004,6 +2014,125 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
self.documentPickerPresenter = documentPickerPresenter;
|
||||
}
|
||||
|
||||
- (void)showRoomWithId:(NSString*)roomId
|
||||
{
|
||||
if (self.delegate)
|
||||
{
|
||||
[self.delegate roomViewController:self showRoomWithId:roomId];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[AppDelegate theDelegate] showRoom:roomId andEventId:nil withMatrixSession:self.roomDataSource.mxSession];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)leaveRoom
|
||||
{
|
||||
[self startActivityIndicator];
|
||||
|
||||
[self.roomDataSource.room leave:^{
|
||||
|
||||
[self stopActivityIndicator];
|
||||
|
||||
// We remove the current view controller.
|
||||
if (self.delegate)
|
||||
{
|
||||
[self.delegate roomViewControllerDidLeaveRoom:self];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[AppDelegate theDelegate] restoreInitialDisplay:^{}];
|
||||
}
|
||||
|
||||
} failure:^(NSError *error) {
|
||||
|
||||
[self stopActivityIndicator];
|
||||
MXLogDebug(@"[RoomVC] Failed to reject an invited room (%@) failed", self.roomDataSource.room.roomId);
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)roomPreviewDidTapCancelAction
|
||||
{
|
||||
// Decline this invitation = leave this page
|
||||
if (self.delegate)
|
||||
{
|
||||
[self.delegate roomViewControllerPreviewDidTapCancel:self];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[AppDelegate theDelegate] restoreInitialDisplay:^{}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)startChatWithUserId:(NSString *)userId completion:(void (^)(void))completion
|
||||
{
|
||||
if (self.delegate)
|
||||
{
|
||||
[self.delegate roomViewController:self startChatWithUserId:userId completion:completion];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[AppDelegate theDelegate] createDirectChatWithUserId:userId completion:completion];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showError:(NSError*)error
|
||||
{
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
}
|
||||
|
||||
- (UIAlertController*)showAlertWithTitle:(NSString*)title message:(NSString*)message
|
||||
{
|
||||
return [[AppDelegate theDelegate] showAlertWithTitle:title message:message];
|
||||
}
|
||||
|
||||
- (BOOL)handleUniversalLinkURL:(NSURL*)universalLinkURL
|
||||
{
|
||||
if (self.delegate)
|
||||
{
|
||||
return [self.delegate roomViewController:self handleUniversalLinkURL:universalLinkURL];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [[AppDelegate theDelegate] handleUniversalLinkURL:universalLinkURL];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)handleUniversalLinkFragment:(NSString*)fragment fromURL:(NSURL*)universalLinkURL
|
||||
{
|
||||
if (self.delegate)
|
||||
{
|
||||
return [self.delegate roomViewController:self handleUniversalLinkFragment:fragment fromURL:universalLinkURL];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [[AppDelegate theDelegate] handleUniversalLinkFragment:fragment fromURL:universalLinkURL];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Jitsi
|
||||
|
||||
- (void)showJitsiCallWithWidget:(Widget*)widget
|
||||
{
|
||||
[[AppDelegate theDelegate].callPresenter displayJitsiCallWithWidget:widget];
|
||||
}
|
||||
|
||||
- (void)endActiveJitsiCall
|
||||
{
|
||||
[[AppDelegate theDelegate].callPresenter endActiveJitsiCall];
|
||||
}
|
||||
|
||||
- (BOOL)isRoomHavingAJitsiCall
|
||||
{
|
||||
return [self isRoomHavingAJitsiCallForWidgetId:self.roomDataSource.roomId];
|
||||
}
|
||||
|
||||
- (BOOL)isRoomHavingAJitsiCallForWidgetId:(NSString*)widgetId
|
||||
{
|
||||
return [[AppDelegate theDelegate].callPresenter.jitsiVC.widget.roomId isEqualToString:widgetId];
|
||||
}
|
||||
|
||||
#pragma mark - Dialpad
|
||||
|
||||
- (void)openDialpad
|
||||
|
@ -2546,7 +2675,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
if (predecessorRoomId)
|
||||
{
|
||||
// Show predecessor room
|
||||
[[AppDelegate theDelegate] showRoom:predecessorRoomId andEventId:nil withMatrixSession:self.mainSession];
|
||||
[self showRoomWithId:predecessorRoomId];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2622,7 +2751,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
[roomDataSource acceptVerificationRequestForEventId:eventId success:^{
|
||||
|
||||
} failure:^(NSError *error) {
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
[self showError:error];
|
||||
}];
|
||||
}
|
||||
else if ([actionIdentifier isEqualToString:kMXKRoomBubbleCellKeyVerificationIncomingRequestDeclinePressed])
|
||||
|
@ -2634,7 +2763,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
[roomDataSource declineVerificationRequestForEventId:eventId success:^{
|
||||
|
||||
} failure:^(NSError *error) {
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
[self showError:error];
|
||||
}];
|
||||
}
|
||||
else if ([actionIdentifier isEqualToString:kMXKRoomBubbleCellTapOnAttachmentView])
|
||||
|
@ -2764,7 +2893,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
Widget *jitsiWidget = [self->customizedRoomDataSource jitsiWidget];
|
||||
if (jitsiWidget)
|
||||
{
|
||||
[[AppDelegate theDelegate].callPresenter displayJitsiCallWithWidget:jitsiWidget];
|
||||
[self showJitsiCallWithWidget:jitsiWidget];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2780,7 +2909,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
}
|
||||
else if ([actionIdentifier isEqualToString:RoomGroupCallStatusBubbleCell.leaveAction])
|
||||
{
|
||||
[[AppDelegate theDelegate].callPresenter endActiveJitsiCall];
|
||||
[self endActiveJitsiCall];
|
||||
[self reloadBubblesTable:YES];
|
||||
}
|
||||
else if ([actionIdentifier isEqualToString:RoomGroupCallStatusBubbleCell.declineAction])
|
||||
|
@ -3004,7 +3133,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
[self stopActivityIndicator];
|
||||
|
||||
//Alert user
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
[self showError:error];
|
||||
|
||||
}];
|
||||
|
||||
|
@ -3091,7 +3220,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
} failure:^(NSError *error) {
|
||||
|
||||
//Alert user
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
[self showError:error];
|
||||
|
||||
}];
|
||||
|
||||
|
@ -3165,7 +3294,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
|
||||
MXLogDebug(@"[RoomVC] Redact event (%@) failed", selectedEvent.eventId);
|
||||
//Alert user
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
[self showError:error];
|
||||
|
||||
}];
|
||||
}
|
||||
|
@ -3316,7 +3445,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
|
||||
MXLogDebug(@"[RoomVC] Ignore user (%@) failed", selectedEvent.sender);
|
||||
//Alert user
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
[self showError:error];
|
||||
|
||||
}];
|
||||
}
|
||||
|
@ -3342,7 +3471,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
|
||||
MXLogDebug(@"[RoomVC] Report event (%@) failed", selectedEvent.eventId);
|
||||
//Alert user
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
[self showError:error];
|
||||
|
||||
}];
|
||||
}
|
||||
|
@ -3441,7 +3570,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
{
|
||||
shouldDoAction = NO;
|
||||
|
||||
[[AppDelegate theDelegate] handleUniversalLinkURL:url];
|
||||
[self handleUniversalLinkURL:url];
|
||||
}
|
||||
// Open a detail screen about the clicked user
|
||||
else if ([MXTools isMatrixUserIdentifier:absoluteURLString])
|
||||
|
@ -3480,7 +3609,8 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
|
||||
// Open the room or preview it
|
||||
NSString *fragment = [NSString stringWithFormat:@"/room/%@", [MXTools encodeURIComponent:roomIdOrAlias]];
|
||||
[[AppDelegate theDelegate] handleUniversalLinkFragment:fragment fromURL:url];
|
||||
|
||||
[self handleUniversalLinkFragment:fragment fromURL:url];
|
||||
}
|
||||
// Preview the clicked group
|
||||
else if ([MXTools isMatrixGroupIdentifier:absoluteURLString])
|
||||
|
@ -3489,7 +3619,8 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
|
||||
// Open the group or preview it
|
||||
NSString *fragment = [NSString stringWithFormat:@"/group/%@", [MXTools encodeURIComponent:absoluteURLString]];
|
||||
[[AppDelegate theDelegate] handleUniversalLinkFragment:fragment fromURL:url];
|
||||
|
||||
[self handleUniversalLinkFragment:fragment fromURL:url];
|
||||
}
|
||||
else if ([absoluteURLString hasPrefix:EventFormatterOnReRequestKeysLinkAction])
|
||||
{
|
||||
|
@ -3645,8 +3776,8 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
|
||||
- (void)showUnableToOpenLinkErrorAlert
|
||||
{
|
||||
[[AppDelegate theDelegate] showAlertWithTitle:[NSBundle mxk_localizedStringForKey:@"error"]
|
||||
message:NSLocalizedStringFromTable(@"room_message_unable_open_link_error_message", @"Vector", nil)];
|
||||
[self showAlertWithTitle:[NSBundle mxk_localizedStringForKey:@"error"]
|
||||
message:NSLocalizedStringFromTable(@"room_message_unable_open_link_error_message", @"Vector", nil)];
|
||||
}
|
||||
|
||||
- (void)editEventContentWithId:(NSString*)eventId
|
||||
|
@ -3838,7 +3969,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
if (jitsiWidget)
|
||||
{
|
||||
// If there is already a Jitsi call, join it
|
||||
[[AppDelegate theDelegate].callPresenter displayJitsiCallWithWidget:jitsiWidget];
|
||||
[self showJitsiCallWithWidget:jitsiWidget];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3865,7 +3996,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
MXStrongifyAndReturnIfNil(self);
|
||||
[self stopActivityIndicator];
|
||||
|
||||
[[AppDelegate theDelegate].callPresenter displayJitsiCallWithWidget:jitsiWidget];
|
||||
[self showJitsiCallWithWidget:jitsiWidget];
|
||||
}
|
||||
failure:^(NSError *error)
|
||||
{
|
||||
|
@ -3907,9 +4038,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
{
|
||||
[callInRoom hangup];
|
||||
}
|
||||
else if ([[AppDelegate theDelegate].callPresenter.jitsiVC.widget.roomId isEqualToString:self.roomDataSource.roomId])
|
||||
else if (self.isRoomHavingAJitsiCall)
|
||||
{
|
||||
[[AppDelegate theDelegate].callPresenter endActiveJitsiCall];
|
||||
[self endActiveJitsiCall];
|
||||
[self reloadBubblesTable:YES];
|
||||
}
|
||||
|
||||
|
@ -3969,7 +4100,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
|
||||
- (void)roomMemberDetailsViewController:(MXKRoomMemberDetailsViewController *)roomMemberDetailsViewController startChatWithMemberId:(NSString *)matrixId completion:(void (^)(void))completion
|
||||
{
|
||||
[[AppDelegate theDelegate] createDirectChatWithUserId:matrixId completion:completion];
|
||||
[self startChatWithUserId:matrixId completion:completion];
|
||||
}
|
||||
|
||||
- (void)roomMemberDetailsViewController:(MXKRoomMemberDetailsViewController *)roomMemberDetailsViewController mention:(MXRoomMember*)member
|
||||
|
@ -4264,27 +4395,11 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
// 'Decline' button has been pressed
|
||||
if (roomPreviewData)
|
||||
{
|
||||
// Decline this invitation = leave this page
|
||||
[[AppDelegate theDelegate] restoreInitialDisplay:^{}];
|
||||
[self roomPreviewDidTapCancelAction];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self startActivityIndicator];
|
||||
|
||||
[self.roomDataSource.room leave:^{
|
||||
|
||||
[self stopActivityIndicator];
|
||||
|
||||
// We remove the current view controller.
|
||||
// Pop to homes view controller
|
||||
[[AppDelegate theDelegate] restoreInitialDisplay:^{}];
|
||||
|
||||
} failure:^(NSError *error) {
|
||||
|
||||
[self stopActivityIndicator];
|
||||
MXLogDebug(@"[RoomVC] Failed to reject an invited room (%@) failed", self.roomDataSource.room.roomId);
|
||||
|
||||
}];
|
||||
[self leaveRoom];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4527,7 +4642,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
}
|
||||
|
||||
// Alert user
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
[self showError:error];
|
||||
}
|
||||
|
||||
- (NSUInteger)widgetsCount:(BOOL)includeUserWidgets
|
||||
|
@ -4587,7 +4702,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
if ([self.roomDataSource.mxSession roomWithRoomId:replacementRoomId])
|
||||
{
|
||||
// Open the room if it is already joined
|
||||
[[AppDelegate theDelegate] showRoom:replacementRoomId andEventId:nil withMatrixSession:self.roomDataSource.mxSession];
|
||||
[self showRoomWithId:replacementRoomId];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4602,15 +4717,15 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
[self startActivityIndicator];
|
||||
[self.roomDataSource.mxSession joinRoom:replacementRoomId viaServers:@[viaSenderServer] success:^(MXRoom *room) {
|
||||
[self stopActivityIndicator];
|
||||
|
||||
[[AppDelegate theDelegate] showRoom:replacementRoomId andEventId:nil withMatrixSession:self.roomDataSource.mxSession];
|
||||
|
||||
[self showRoomWithId:replacementRoomId];
|
||||
|
||||
} failure:^(NSError *error) {
|
||||
[self stopActivityIndicator];
|
||||
|
||||
MXLogDebug(@"[RoomVC] Failed to join an upgraded room. Error: %@",
|
||||
error);
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
[self showError:error];
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
@ -5299,7 +5414,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
|
||||
MXLogDebug(@"[RoomVC] Invite %@ failed", participantId);
|
||||
// Alert user
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
[self showError:error];
|
||||
|
||||
}];
|
||||
}
|
||||
|
@ -5334,11 +5449,11 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
&& error.code == MXRestClientErrorMissingIdentityServer)
|
||||
{
|
||||
NSString *message = [NSBundle mxk_localizedStringForKey:@"error_invite_3pid_with_no_identity_server"];
|
||||
[[AppDelegate theDelegate] showAlertWithTitle:message message:nil];
|
||||
[self showAlertWithTitle:message message:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
[self showError:error];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
@ -5353,7 +5468,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
|
||||
MXLogDebug(@"[RoomVC] Invite %@ failed", participantId);
|
||||
// Alert user
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
[self showError:error];
|
||||
|
||||
}];
|
||||
}
|
||||
|
@ -5451,10 +5566,16 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
|
||||
- (void)showSettingsSecurityScreen
|
||||
{
|
||||
[[AppDelegate theDelegate] presentCompleteSecurityForSession: self.mainSession];
|
||||
if (self.delegate)
|
||||
{
|
||||
[self.delegate roomViewController:self showCompleteSecurityForSession:self.mainSession];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[AppDelegate theDelegate] presentCompleteSecurityForSession: self.mainSession];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark Tombstone event
|
||||
|
||||
- (void)listenTombstoneEventNotifications
|
||||
|
@ -5815,7 +5936,7 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
[self stopActivityIndicator];
|
||||
|
||||
//Alert user
|
||||
[[AppDelegate theDelegate] showErrorAsAlert:error];
|
||||
[self showError:error];
|
||||
}];
|
||||
|
||||
// Start animation in case of download during attachment preparing
|
||||
|
@ -5995,8 +6116,8 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
{
|
||||
MXLogDebug(@"[MXKRoomViewController] File upload using MIME type %@ is not supported.", mimeType);
|
||||
|
||||
[[AppDelegate theDelegate] showAlertWithTitle:NSLocalizedStringFromTable(@"file_upload_error_title", @"Vector", nil)
|
||||
message:NSLocalizedStringFromTable(@"file_upload_error_unsupported_file_type_message", @"Vector", nil)];
|
||||
[self showAlertWithTitle:NSLocalizedStringFromTable(@"file_upload_error_title", @"Vector", nil)
|
||||
message:NSLocalizedStringFromTable(@"file_upload_error_unsupported_file_type_message", @"Vector", nil)];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6150,7 +6271,14 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
|
||||
- (void)roomInfoCoordinatorBridgePresenterDelegateDidLeaveRoom:(RoomInfoCoordinatorBridgePresenter *)coordinatorBridgePresenter
|
||||
{
|
||||
[[LegacyAppDelegate theDelegate] restoreInitialDisplay:nil];
|
||||
if (self.delegate)
|
||||
{
|
||||
[self.delegate roomViewControllerDidLeaveRoom:self];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[AppDelegate theDelegate] restoreInitialDisplay:nil];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - RemoveJitsiWidgetViewDelegate
|
||||
|
@ -6175,9 +6303,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
|
|||
self.removeJitsiWidgetView.delegate = nil;
|
||||
|
||||
// end active call if exists
|
||||
if ([[AppDelegate theDelegate].callPresenter.jitsiVC.widget.widgetId isEqualToString:jitsiWidget.widgetId])
|
||||
if ([self isRoomHavingAJitsiCallForWidgetId:jitsiWidget.widgetId])
|
||||
{
|
||||
[[AppDelegate theDelegate].callPresenter endActiveJitsiCall];
|
||||
[self endActiveJitsiCall];
|
||||
}
|
||||
} failure:^(NSError *error) {
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
|
|
Loading…
Reference in a new issue