diff --git a/Riot/Managers/Call/CallPresenter.swift b/Riot/Managers/Call/CallPresenter.swift index 9e7b97569..242338dc2 100644 --- a/Riot/Managers/Call/CallPresenter.swift +++ b/Riot/Managers/Call/CallPresenter.swift @@ -49,7 +49,7 @@ class CallPresenter: NSObject { updateOnHoldCall() } } - private weak var inBarCallVC: CallViewController? + private weak var inBarCallVC: UIViewController? private weak var pipCallVC: CallViewController? private weak var pipGroupCallVC: JitsiViewController? private var uiOperationQueue: OperationQueue = .main @@ -59,19 +59,21 @@ class CallPresenter: NSObject { private var widgetEventsListener: Any? /// Jitsi calls map. Keys are CallKit call UUIDs, values are corresponding widgets. private var jitsiCalls: [UUID: Widget] = [:] + /// The current Jitsi view controller being displayed. + private(set) var jitsiVC: JitsiViewController? #endif private var isCallKitEnabled: Bool { MXCallKitAdapter.callKitAvailable() && MXKAppSettings.standard()?.isCallKitEnabled == true } - private var activeCallVC: CallViewController? { + private var activeCallVC: UIViewController? { return callVCs.values.filter { (callVC) -> Bool in guard let call = callVC.mxCall else { return false } return !call.isOnHold - }.first + }.first ?? jitsiVC } private var onHoldCallVCs: [CallViewController] { @@ -123,17 +125,50 @@ class CallPresenter: NSObject { } /// Method to be called when the call status bar is tapped. - /// - Returns: If the user interaction handled or not - func callStatusBarButtonTapped() -> Bool { - if let callVC = inBarCallVC ?? activeCallVC { + func callStatusBarButtonTapped() { + if let callVC = (inBarCallVC ?? activeCallVC) as? CallViewController { dismissCallBar(for: callVC) presentCallVC(callVC) - return true + return + } + if let jitsiVC = jitsiVC { + dismissCallBar(for: jitsiVC) + presentGroupCallVC(jitsiVC) } - return false } - func startJitsiCall(withWidget widget: Widget) { + // MARK - Group Calls + + /// Open the Jitsi view controller from a widget. + /// - Parameter widget: the jitsi widget + func displayJitsiCall(withWidget widget: Widget) { + #if canImport(JitsiMeetSDK) + if jitsiVC == nil { + jitsiVC = JitsiViewController() + jitsiVC?.openWidget(widget, withVideo: true, success: { [weak self] in + guard let self = self else { return } + if let jitsiVC = self.jitsiVC { + jitsiVC.delegate = self + self.presentGroupCallVC(jitsiVC) + self.startJitsiCall(withWidget: widget) + } + }, failure: { [weak self] (error) in + guard let self = self else { return } + self.jitsiVC = nil + AppDelegate.theDelegate().showAlert(withTitle: nil, + message: VectorL10n.callJitsiError) + }) + } else { + AppDelegate.theDelegate().showAlert(withTitle: nil, message: + VectorL10n.callAlreadyDisplayed) + } + #else + AppDelegate.theDelegate().showAlert(withTitle: nil, + message: Bundle.mxk_localizedString(forKey: "not_supported_yet")) + #endif + } + + private func startJitsiCall(withWidget widget: Widget) { if self.jitsiCalls.first(where: { $0.value.widgetId == widget.widgetId })?.key != nil { // this Jitsi call is already managed by this class, no need to report the call again return @@ -168,12 +203,27 @@ class CallPresenter: NSObject { } } - func endJitsiCall(withWidget widget: Widget) { + func endActiveJitsiCall() { + guard let widget = jitsiVC?.widget else { + // there is no active Jitsi call + return + } guard let uuid = self.jitsiCalls.first(where: { $0.value.widgetId == widget.widgetId })?.key else { // this Jitsi call is not managed by this class return } + if let inBarCallVC = inBarCallVC { + dismissCallBar(for: inBarCallVC) + } + + if let jitsiVC = jitsiVC { + dismissGroupCallVC(jitsiVC) + jitsiVC.hangup() + } + + jitsiVC = nil + let endCallAction = CXEndCallAction(call: uuid) let transaction = CXTransaction(action: endCallAction) JMCallKitProxy.request(transaction) { (error) in @@ -204,7 +254,7 @@ class CallPresenter: NSObject { return } - if let jitsiVC = AppDelegate.theDelegate().jitsiViewController, + if let jitsiVC = jitsiVC, jitsiVC.widget.widgetId == widget.widgetId { // this is already the Jitsi call we have atm return @@ -268,9 +318,6 @@ class CallPresenter: NSObject { } private func shouldHandleCall(_ call: MXCall) -> Bool { - if let delegate = delegate, !delegate.callPresenter(self, shouldHandleNewCall: call) { - return false - } return callVCs.count < maximumNumberOfConcurrentCalls } @@ -341,7 +388,7 @@ class CallPresenter: NSObject { } @objc private func callTimerFired(_ timer: Timer) { - guard let inBarCallVC = inBarCallVC else { + guard let inBarCallVC = inBarCallVC as? CallViewController else { return } guard let call = inBarCallVC.mxCall else { @@ -565,7 +612,7 @@ class CallPresenter: NSObject { NSLog("[CallService] groupCallTileTapped: for call: \(widget.widgetId)") - guard let jitsiVC = AppDelegate.theDelegate().jitsiViewController, + guard let jitsiVC = jitsiVC, jitsiVC.widget.widgetId == widget.widgetId else { return } @@ -648,14 +695,18 @@ class CallPresenter: NSObject { // MARK: - Call Bar - private func presentCallBar(for callVC: CallViewController?, isUpdateOnly: Bool = false, completion: (() -> Void)? = nil) { - NSLog("[CallService] presentCallBar: call: \(String(describing: callVC?.mxCall?.callId))") + private func presentCallBar(for callVC: UIViewController?, isUpdateOnly: Bool = false, completion: (() -> Void)? = nil) { + if let callVC = callVC as? CallViewController { + NSLog("[CallService] presentCallBar: call: \(String(describing: callVC.mxCall?.callId))") + } else if let callVC = callVC as? JitsiViewController { + NSLog("[CallService] presentCallBar: call: \(callVC.widget.widgetId)") + } let activeCallVC = self.activeCallVC let operation = CallBarPresentOperation(presenter: self, activeCallVC: activeCallVC, numberOfPausedCalls: numberOfPausedCalls) { [weak self] in // active calls are more prior to paused ones. - // So, if user taps the bar when we have one active and one paused calls, we navigate to the active one. + // So, if user taps the bar when we have one active and one paused call, we navigate to the active one. if !isUpdateOnly { self?.inBarCallVC = activeCallVC ?? callVC } @@ -664,8 +715,12 @@ class CallPresenter: NSObject { uiOperationQueue.addOperation(operation) } - private func dismissCallBar(for callVC: CallViewController, completion: (() -> Void)? = nil) { - NSLog("[CallService] dismissCallBar: call: \(String(describing: callVC.mxCall?.callId))") + private func dismissCallBar(for callVC: UIViewController, completion: (() -> Void)? = nil) { + if let callVC = callVC as? CallViewController { + NSLog("[CallService] dismissCallBar: call: \(String(describing: callVC.mxCall?.callId))") + } else if let callVC = callVC as? JitsiViewController { + NSLog("[CallService] dismissCallBar: call: \(callVC.widget.widgetId)") + } let operation = CallBarDismissOperation(presenter: self) { [weak self] in if callVC == self?.inBarCallVC { @@ -703,6 +758,21 @@ class CallPresenter: NSObject { uiOperationQueue.addOperation(operation) } + private func dismissGroupCallVC(_ callVC: JitsiViewController, completion: (() -> Void)? = nil) { + NSLog("[CallService] dismissGroupCallVC: call: \(callVC.widget.widgetId)") + + // do not use PiP transitions here, as we really want to dismiss the screen + callVC.transitioningDelegate = nil + + let operation = GroupCallVCDismissOperation(presenter: self, callVC: callVC) { [weak self] in + if callVC == self?.presentedGroupCallVC { + self?.presentedGroupCallVC = nil + } + completion?() + } + uiOperationQueue.addOperation(operation) + } + } // MARK: - MXKCallViewControllerDelegate @@ -814,7 +884,7 @@ extension CallPresenter: JMCallKitListener { return } - AppDelegate.theDelegate().displayJitsiViewController(with: widget, andVideo: true) + displayJitsiCall(withWidget: widget) } func performEndCall(UUID: UUID) { @@ -822,10 +892,10 @@ extension CallPresenter: JMCallKitListener { return } - if let jitsiVC = AppDelegate.theDelegate().jitsiViewController, jitsiVC.widget.widgetId == widget.widgetId { + if let jitsiVC = jitsiVC, jitsiVC.widget.widgetId == widget.widgetId { // hangup an active call - jitsiVC.hangup() - AppDelegate.theDelegate().jitsiViewController(jitsiVC, dismissViewJitsiController: nil) + dismissGroupCallVC(jitsiVC) + endActiveJitsiCall() } else { // decline incoming call JitsiService.shared.declineWidget(withId: widget.widgetId) @@ -837,7 +907,7 @@ extension CallPresenter: JMCallKitListener { return } - if let jitsiVC = AppDelegate.theDelegate().jitsiViewController, jitsiVC.widget.widgetId == widget.widgetId { + if let jitsiVC = jitsiVC, jitsiVC.widget.widgetId == widget.widgetId { // mute the active Jitsi call jitsiVC.setAudioMuted(isMuted) } @@ -860,4 +930,24 @@ extension CallPresenter: JMCallKitListener { } } + +// MARK - JitsiViewControllerDelegate + +extension CallPresenter: JitsiViewControllerDelegate { + + func jitsiViewController(_ jitsiViewController: JitsiViewController!, dismissViewJitsiController completion: (() -> Void)!) { + if jitsiViewController == jitsiVC { + endActiveJitsiCall() + } + } + + func jitsiViewController(_ jitsiViewController: JitsiViewController!, goBackToApp completion: (() -> Void)!) { + if jitsiViewController == jitsiVC { + dismissGroupCallVC(jitsiViewController) + self.presentCallBar(for: jitsiViewController, completion: completion) + } + } + +} + #endif diff --git a/Riot/Managers/Call/CallPresenterDelegate.swift b/Riot/Managers/Call/CallPresenterDelegate.swift index 8a0882395..d8b3f06ac 100644 --- a/Riot/Managers/Call/CallPresenterDelegate.swift +++ b/Riot/Managers/Call/CallPresenterDelegate.swift @@ -18,10 +18,6 @@ import Foundation @objc protocol CallPresenterDelegate: class { - // New call - func callPresenter(_ presenter: CallPresenter, - shouldHandleNewCall call: MXCall) -> Bool - // Call screens func callPresenter(_ presenter: CallPresenter, presentCallViewController viewController: CallViewController, @@ -32,7 +28,7 @@ protocol CallPresenterDelegate: class { // Call Bar func callPresenter(_ presenter: CallPresenter, - presentCallBarFor activeCallViewController: CallViewController?, + presentCallBarFor activeCallViewController: UIViewController?, numberOfPausedCalls: UInt, completion:(() -> Void)?) func callPresenter(_ presenter: CallPresenter, @@ -51,4 +47,7 @@ protocol CallPresenterDelegate: class { func callPresenter(_ presenter: CallPresenter, presentGroupCallViewController viewController: JitsiViewController, completion:(() -> Void)?) + func callPresenter(_ presenter: CallPresenter, + dismissGroupCallViewController viewController: JitsiViewController, + completion:(() -> Void)?) } diff --git a/Riot/Managers/Call/Operations/CallBarPresentOperation.swift b/Riot/Managers/Call/Operations/CallBarPresentOperation.swift index 8e2eb610a..68a89d3f2 100644 --- a/Riot/Managers/Call/Operations/CallBarPresentOperation.swift +++ b/Riot/Managers/Call/Operations/CallBarPresentOperation.swift @@ -19,12 +19,12 @@ import Foundation class CallBarPresentOperation: AsyncOperation { private var presenter: CallPresenter - private var activeCallVC: CallViewController? + private var activeCallVC: UIViewController? private var numberOfPausedCalls: UInt private var completion: (() -> Void)? init(presenter: CallPresenter, - activeCallVC: CallViewController?, + activeCallVC: UIViewController?, numberOfPausedCalls: UInt, completion: (() -> Void)? = nil) { self.presenter = presenter diff --git a/Riot/Managers/Call/Operations/GroupCallVCDismissOperation.swift b/Riot/Managers/Call/Operations/GroupCallVCDismissOperation.swift new file mode 100644 index 000000000..a19402c3e --- /dev/null +++ b/Riot/Managers/Call/Operations/GroupCallVCDismissOperation.swift @@ -0,0 +1,40 @@ +// +// Copyright 2020 New Vector Ltd +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import Foundation + +class GroupCallVCDismissOperation: AsyncOperation { + + private var presenter: CallPresenter + private var callVC: JitsiViewController + private var completion: (() -> Void)? + + init(presenter: CallPresenter, + callVC: JitsiViewController, + completion: (() -> Void)? = nil) { + self.presenter = presenter + self.callVC = callVC + self.completion = completion + } + + override func main() { + presenter.delegate?.callPresenter(presenter, dismissGroupCallViewController: callVC, completion: { + self.finish() + self.completion?() + }) + } + +} diff --git a/Riot/Modules/Application/LegacyAppDelegate.h b/Riot/Modules/Application/LegacyAppDelegate.h index 2be16699a..1cea08e0d 100644 --- a/Riot/Modules/Application/LegacyAppDelegate.h +++ b/Riot/Modules/Application/LegacyAppDelegate.h @@ -55,8 +55,8 @@ extern NSString *const AppDelegateUniversalLinkDidChangeNotification; @interface LegacyAppDelegate : UIResponder < UIApplicationDelegate, UISplitViewControllerDelegate, -UINavigationControllerDelegate, -JitsiViewControllerDelegate> +UINavigationControllerDelegate +> { // background sync management void (^_completionHandler)(UIBackgroundFetchResult); @@ -224,21 +224,6 @@ JitsiViewControllerDelegate> */ - (BOOL)handleUniversalLinkFragment:(NSString*)fragment; -#pragma mark - Jitsi call - -/** - Open the Jitsi view controller from a widget. - - @param jitsiWidget the jitsi widget. - @param video to indicate voice or video call. - */ -- (void)displayJitsiViewControllerWithWidget:(Widget*)jitsiWidget andVideo:(BOOL)video; - -/** - The current Jitsi view controller being displayed. - */ -@property (nonatomic, strong, readonly) JitsiViewController *jitsiViewController; - #pragma mark - Call status handling /** diff --git a/Riot/Modules/Application/LegacyAppDelegate.m b/Riot/Modules/Application/LegacyAppDelegate.m index 68d19fb04..23ac99ac7 100644 --- a/Riot/Modules/Application/LegacyAppDelegate.m +++ b/Riot/Modules/Application/LegacyAppDelegate.m @@ -225,7 +225,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni @property (nonatomic, strong) PushNotificationStore *pushNotificationStore; @property (nonatomic, strong) LocalAuthenticationService *localAuthenticationService; @property (nonatomic, strong, readwrite) CallPresenter *callPresenter; -@property (nonatomic, strong, readwrite) JitsiViewController *jitsiViewController; @property (nonatomic, strong) MajorUpdateManager *majorUpdateManager; @@ -3005,86 +3004,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni } } -#pragma mark - Jitsi call - -- (void)displayJitsiViewControllerWithWidget:(Widget*)jitsiWidget andVideo:(BOOL)video -{ -#ifdef CALL_STACK_JINGLE - if (!_jitsiViewController) - { - _jitsiViewController = [JitsiViewController jitsiViewController]; - - MXWeakify(self); - [_jitsiViewController openWidget:jitsiWidget withVideo:video success:^{ - MXStrongifyAndReturnIfNil(self); - self.jitsiViewController.delegate = self; - [self presentJitsiViewController:nil]; - - [self.callPresenter startJitsiCallWithWidget:jitsiWidget]; - - } failure:^(NSError *error) { - MXStrongifyAndReturnIfNil(self); - self.jitsiViewController = nil; - - [self showAlertWithTitle:nil message:NSLocalizedStringFromTable(@"call_jitsi_error", @"Vector", nil)]; - }]; - } - else - { - [self showAlertWithTitle:nil message:NSLocalizedStringFromTable(@"call_already_displayed", @"Vector", nil)]; - } -#else - [self showAlertWithTitle:nil message:[NSBundle mxk_localizedStringForKey:@"not_supported_yet"]]; -#endif -} - -- (void)presentJitsiViewController:(void (^)(void))completion -{ - [self removeCallStatusBar]; - - if (_jitsiViewController) - { - if (@available(iOS 13.0, *)) - { - _jitsiViewController.modalPresentationStyle = UIModalPresentationFullScreen; - } - - [self presentViewController:_jitsiViewController animated:YES completion:completion]; - } -} - -- (void)jitsiViewController:(JitsiViewController *)jitsiViewController dismissViewJitsiController:(void (^)(void))completion -{ - if (jitsiViewController == _jitsiViewController) - { - [_callPresenter endJitsiCallWithWidget:_jitsiViewController.widget]; - - [_jitsiViewController dismissViewControllerAnimated:YES completion:completion]; - _jitsiViewController = nil; - - [self removeCallStatusBar]; - } -} - -- (void)jitsiViewController:(JitsiViewController *)jitsiViewController goBackToApp:(void (^)(void))completion -{ - if (jitsiViewController == _jitsiViewController) - { - [_jitsiViewController dismissViewControllerAnimated:YES completion:^{ - - MXRoom *room = [self.jitsiViewController.widget.mxSession roomWithRoomId:self.jitsiViewController.widget.roomId]; - NSString *btnTitle = [NSString stringWithFormat:NSLocalizedStringFromTable(@"active_call_details", @"Vector", nil), room.summary.displayname]; - [self updateCallStatusBar:btnTitle]; - - if (completion) - { - completion(); - } - }]; - } -} - - #pragma mark - Native Widget Permission - (void)checkPermissionForNativeWidget:(Widget*)widget fromUrl:(NSURL*)url completion:(void (^)(BOOL granted))completion @@ -4449,12 +4368,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni #pragma mark - CallPresenterDelegate -- (BOOL)callPresenter:(CallPresenter *)presenter shouldHandleNewCall:(MXCall *)call -{ - // Ignore the call if a call is already in progress - return _jitsiViewController == nil; -} - - (void)callPresenter:(CallPresenter *)presenter presentCallViewController:(CallViewController *)viewController completion:(void (^)(void))completion { if (@available(iOS 13.0, *)) @@ -4493,26 +4406,39 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni } } -- (void)callPresenter:(CallPresenter *)presenter presentCallBarFor:(CallViewController *)activeCallViewController numberOfPausedCalls:(NSUInteger)numberOfPausedCalls completion:(void (^)(void))completion +- (void)callPresenter:(CallPresenter *)presenter presentCallBarFor:(UIViewController *)activeCallViewController numberOfPausedCalls:(NSUInteger)numberOfPausedCalls completion:(void (^)(void))completion { NSString *btnTitle; if (activeCallViewController) { + NSString *callStatus = @""; + if ([activeCallViewController isKindOfClass:[CallViewController class]]) + { + CallViewController *activeCallVC = (CallViewController *)activeCallViewController; + callStatus = activeCallVC.callStatusLabel.text; + } + else if ([activeCallViewController isKindOfClass:[JitsiViewController class]]) + { + JitsiViewController *jitsiVC = (JitsiViewController *)activeCallViewController; + MXRoom *room = [jitsiVC.widget.mxSession roomWithRoomId:jitsiVC.widget.roomId]; + callStatus = room.summary.displayname; + } + if (numberOfPausedCalls == 0) { // only one active - btnTitle = [NSString stringWithFormat:NSLocalizedStringFromTable(@"callbar_only_single_active", @"Vector", nil), activeCallViewController.callStatusLabel.text]; + btnTitle = [NSString stringWithFormat:NSLocalizedStringFromTable(@"callbar_only_single_active", @"Vector", nil), callStatus]; } else if (numberOfPausedCalls == 1) { // one active and one paused - btnTitle = [NSString stringWithFormat:NSLocalizedStringFromTable(@"callbar_active_and_single_paused", @"Vector", nil), activeCallViewController.callStatusLabel.text]; + btnTitle = [NSString stringWithFormat:NSLocalizedStringFromTable(@"callbar_active_and_single_paused", @"Vector", nil), callStatus]; } else { // one active and multiple paused - btnTitle = [NSString stringWithFormat:NSLocalizedStringFromTable(@"callbar_active_and_multiple_paused", @"Vector", nil), activeCallViewController.callStatusLabel.text, @(numberOfPausedCalls)]; + btnTitle = [NSString stringWithFormat:NSLocalizedStringFromTable(@"callbar_active_and_multiple_paused", @"Vector", nil), callStatus, @(numberOfPausedCalls)]; } } else @@ -4584,18 +4510,34 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni [self presentViewController:viewController animated:YES completion:completion]; } +- (void)callPresenter:(CallPresenter *)presenter dismissGroupCallViewController:(JitsiViewController *)viewController completion:(void (^)(void))completion +{ + // Check whether the call view controller is actually presented + if (viewController.presentingViewController) + { + [viewController.presentingViewController dismissViewControllerAnimated:YES completion:^{ + + if (completion) + { + completion(); + } + + }]; + } + else + { + if (completion) + { + completion(); + } + } +} + #pragma mark - CallBarDelegate - (void)callBarDidTapReturnButton:(CallBar *)callBar { - if ([_callPresenter callStatusBarButtonTapped]) - { - return; - } - else if (_jitsiViewController) - { - [self presentJitsiViewController:nil]; - } + [_callPresenter callStatusBarButtonTapped]; } #pragma mark - Authentication diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index 35521115f..2af9f5287 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -606,7 +606,7 @@ NSNotificationName const RoomGroupCallTileTappedNotification = @"RoomGroupCallTi self.keyboardHeight = MAX(self.keyboardHeight, 0); if (hasJitsiCall && - ![[AppDelegate theDelegate].jitsiViewController.widget.roomId isEqualToString:self.roomDataSource.roomId]) + ![[AppDelegate theDelegate].callPresenter.jitsiVC.widget.roomId isEqualToString:self.roomDataSource.roomId]) { // the room had a Jitsi call before, but not now hasJitsiCall = NO; @@ -642,7 +642,7 @@ NSNotificationName const RoomGroupCallTileTappedNotification = @"RoomGroupCallTi mxEventDidDecryptNotificationObserver = nil; } - JitsiViewController *jitsiVC = [AppDelegate theDelegate].jitsiViewController; + JitsiViewController *jitsiVC = [AppDelegate theDelegate].callPresenter.jitsiVC; if ([jitsiVC.widget.roomId isEqualToString:self.roomDataSource.roomId]) { hasJitsiCall = YES; @@ -1477,7 +1477,7 @@ NSNotificationName const RoomGroupCallTileTappedNotification = @"RoomGroupCallTi // conference call in the current room MXCall *callInRoom = [self.roomDataSource.mxSession.callManager callInRoom:self.roomDataSource.roomId]; if ((callInRoom && callInRoom.state != MXCallStateEnded) - || [[AppDelegate theDelegate].jitsiViewController.widget.roomId isEqualToString:self.roomDataSource.roomId]) + || [[AppDelegate theDelegate].callPresenter.jitsiVC.widget.roomId isEqualToString:self.roomDataSource.roomId]) { roomInputToolbarView.activeCall = YES; } @@ -2466,7 +2466,7 @@ NSNotificationName const RoomGroupCallTileTappedNotification = @"RoomGroupCallTi Widget *jitsiWidget = [self->customizedRoomDataSource jitsiWidget]; if (jitsiWidget) { - [[AppDelegate theDelegate] displayJitsiViewControllerWithWidget:jitsiWidget andVideo:YES]; + [[AppDelegate theDelegate].callPresenter displayJitsiCallWithWidget:jitsiWidget]; } } else @@ -3612,7 +3612,7 @@ NSNotificationName const RoomGroupCallTileTappedNotification = @"RoomGroupCallTi Widget *jitsiWidget = [customizedRoomDataSource jitsiWidget]; if (jitsiWidget) { - [[AppDelegate theDelegate] displayJitsiViewControllerWithWidget:jitsiWidget andVideo:video]; + [[AppDelegate theDelegate].callPresenter displayJitsiCallWithWidget:jitsiWidget]; } // If enabled, create the conf using jitsi widget and open it directly @@ -3630,7 +3630,7 @@ NSNotificationName const RoomGroupCallTileTappedNotification = @"RoomGroupCallTi typeof(self) self = weakSelf; [self stopActivityIndicator]; - [[AppDelegate theDelegate] displayJitsiViewControllerWithWidget:jitsiWidget andVideo:video]; + [[AppDelegate theDelegate].callPresenter displayJitsiCallWithWidget:jitsiWidget]; } } failure:^(NSError *error) @@ -3704,9 +3704,10 @@ NSNotificationName const RoomGroupCallTileTappedNotification = @"RoomGroupCallTi { [callInRoom hangup]; } - else if ([[AppDelegate theDelegate].jitsiViewController.widget.roomId isEqualToString:self.roomDataSource.roomId]) + else if ([[AppDelegate theDelegate].callPresenter.jitsiVC.widget.roomId isEqualToString:self.roomDataSource.roomId]) { - [[AppDelegate theDelegate].jitsiViewController hangup]; + [[AppDelegate theDelegate].callPresenter endActiveJitsiCall]; + [self reloadBubblesTable:YES]; } [self refreshActivitiesViewDisplay]; @@ -4442,7 +4443,7 @@ NSNotificationName const RoomGroupCallTileTappedNotification = @"RoomGroupCallTi // The room has an active jitsi widget // Show it in the banner if the user is not already in LegacyAppDelegate *appDelegate = [AppDelegate theDelegate]; - if ([appDelegate.jitsiViewController.widget.widgetId isEqualToString:jitsiWidget.widgetId]) + if ([appDelegate.callPresenter.jitsiVC.widget.widgetId isEqualToString:jitsiWidget.widgetId]) { if ([self checkUnsentMessages] == NO) { @@ -4469,7 +4470,7 @@ NSNotificationName const RoomGroupCallTileTappedNotification = @"RoomGroupCallTi if (granted) { // Present the Jitsi view controller - [appDelegate displayJitsiViewControllerWithWidget:jitsiWidget andVideo:video]; + [appDelegate.callPresenter displayJitsiCallWithWidget:jitsiWidget]; } else { diff --git a/Riot/Modules/Room/Views/BubbleCells/Call/Group/RoomGroupCallStatusBubbleCell.swift b/Riot/Modules/Room/Views/BubbleCells/Call/Group/RoomGroupCallStatusBubbleCell.swift index e067b7614..8fd32d508 100644 --- a/Riot/Modules/Room/Views/BubbleCells/Call/Group/RoomGroupCallStatusBubbleCell.swift +++ b/Riot/Modules/Room/Views/BubbleCells/Call/Group/RoomGroupCallStatusBubbleCell.swift @@ -83,7 +83,7 @@ class RoomGroupCallStatusBubbleCell: RoomBaseCallBubbleCell { private var isJoined: Bool { return widgetId != nil && - AppDelegate.theDelegate().jitsiViewController?.widget.widgetId == widgetId + AppDelegate.theDelegate().callPresenter.jitsiVC?.widget.widgetId == widgetId } private var actionUserInfo: [AnyHashable: Any]? {