Merge branch 'master' into develop

This commit is contained in:
Andy Uhnak
2022-03-14 16:26:07 +00:00
12 changed files with 141 additions and 38 deletions
+70 -8
View File
@@ -568,7 +568,9 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
isAppeared = NO;
[VoiceMessageMediaServiceProvider.sharedProvider pauseAllServices];
[self stopActivityIndicator];
// Stop the loading indicator even if the session is still in progress
[self stopLoadingUserIndicator];
}
- (void)viewDidAppear:(BOOL)animated
@@ -938,10 +940,14 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
self.updateRoomReadMarker = NO;
}
#pragma mark - Loading indicators
- (BOOL)providesCustomActivityIndicator {
return [self.delegate roomViewControllerCanDelegateUserIndicators:self];
}
// Override of a legacy method to determine whether to use a newer implementation instead.
// Will be removed in the future https://github.com/vector-im/element-ios/issues/5608
- (void)startActivityIndicator {
if ([self providesCustomActivityIndicator]) {
[self.delegate roomViewControllerDidStartLoading:self];
@@ -950,6 +956,8 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
}
}
// Override of a legacy method to determine whether to use a newer implementation instead.
// Will be removed in the future https://github.com/vector-im/element-ios/issues/5608
- (void)stopActivityIndicator
{
if (notificationTaskProfile)
@@ -959,14 +967,22 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
notificationTaskProfile = nil;
}
if ([self providesCustomActivityIndicator]) {
// The legacy super implementation of `stopActivityIndicator` contains a number of checks grouped under `canStopActivityIndicator`
// to determine whether the indicator can be stopped or not (and the method should thus rather be called `stopActivityIndicatorIfPossible`).
// Since the newer indicators are not calling super implementation, the check for `canStopActivityIndicator` has to be performed manually.
if ([self canStopActivityIndicator]) {
[self.delegate roomViewControllerDidStopLoading:self];
[self stopLoadingUserIndicator];
}
} else {
[super stopActivityIndicator];
}
}
- (void)stopLoadingUserIndicator
{
[self.delegate roomViewControllerDidStopLoading:self];
}
- (void)displayRoom:(MXKRoomDataSource *)dataSource
{
// Remove potential preview Data
@@ -4964,10 +4980,32 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
}
else if (tappedView == previewHeader.leftButton)
{
[self declineRoomInvitation];
[self presentDeclineOptionsFromView:tappedView];
}
}
- (void)presentDeclineOptionsFromView:(UIView *)view
{
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:[VectorL10n roomPreviewDeclineInvitationOptions]
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
[actionSheet addAction:[UIAlertAction actionWithTitle:[VectorL10n decline]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
[self declineRoomInvitation];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:[VectorL10n ignoreUser]
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction * _Nonnull action) {
[self ignoreInviteSender];
}]];
[actionSheet addAction:[UIAlertAction actionWithTitle:[VectorL10n cancel]
style:UIAlertActionStyleCancel
handler:nil]];
actionSheet.popoverPresentationController.sourceView = view;
[self presentViewController:actionSheet animated:YES completion:nil];
}
- (void)declineRoomInvitation
{
// 'Decline' button has been pressed
@@ -4978,16 +5016,15 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
else
{
[self startActivityIndicator];
MXWeakify(self);
[self.roomDataSource.room leave:^{
MXStrongifyAndReturnIfNil(self);
[self stopActivityIndicator];
// We remove the current view controller.
// Pop to homes view controller
[[AppDelegate theDelegate] restoreInitialDisplay:^{}];
[self popToHomeViewController];
} failure:^(NSError *error) {
MXStrongifyAndReturnIfNil(self);
[self stopActivityIndicator];
MXLogDebug(@"[RoomVC] Failed to reject an invited room (%@) failed", self.roomDataSource.room.roomId);
@@ -4996,6 +5033,31 @@ const NSTimeInterval kResizeComposerAnimationDuration = .05;
}
}
- (void)ignoreInviteSender
{
[self startActivityIndicator];
MXWeakify(self);
[self.roomDataSource.room ignoreInviteSender:^{
MXStrongifyAndReturnIfNil(self);
[self stopActivityIndicator];
[self popToHomeViewController];
} failure:^(NSError *error) {
MXStrongifyAndReturnIfNil(self);
[self stopActivityIndicator];
MXLogDebug(@"[RoomVC] Failed to ignore inviter in room (%@)", self.roomDataSource.room.roomId);
}];
}
- (void)popToHomeViewController
{
// We remove the current view controller.
// Pop to homes view controller
[[AppDelegate theDelegate] restoreInitialDisplay:^{}];
}
#pragma mark - Typing management
- (void)removeTypingNotificationsListener