mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Handle notifications properly when a call is happening. (#3276)
This commit is contained in:
@@ -128,6 +128,7 @@ private struct CallView: UIViewRepresentable {
|
||||
contentViewController: pictureInPictureViewController))
|
||||
pictureInPictureController.delegate = self
|
||||
self.pictureInPictureController = pictureInPictureController
|
||||
viewModelContext.send(viewAction: .pictureInPictureIsAvailable(pictureInPictureController))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,6 +223,18 @@ private struct CallView: UIViewRepresentable {
|
||||
}
|
||||
}
|
||||
|
||||
nonisolated func pictureInPictureControllerDidStartPictureInPicture(_ pictureInPictureController: AVPictureInPictureController) {
|
||||
Task { @MainActor in
|
||||
// Double check that the controller is definitely showing a page that supports picture in picture.
|
||||
// This is necessary as it doesn't get checked when backgrounding the app or tapping a notification.
|
||||
guard case .success(true) = await webViewCanEnterPictureInPicture() else {
|
||||
MXLog.error("Picture in picture started on a webpage that doesn't support it. Ending the call.")
|
||||
viewModelContext?.send(viewAction: .endCall)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nonisolated func pictureInPictureControllerWillStopPictureInPicture(_ pictureInPictureController: AVPictureInPictureController) {
|
||||
Task { await viewModelContext?.send(viewAction: .pictureInPictureWillStop) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user