|
|
@@ -947,9 +947,55 @@ private extension ViewController {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- guard let url = URL(string: "https://meet.google.com/new") else { return }
|
|
|
- openInDefaultBrowser(url: url)
|
|
|
- consumeNonPremiumJoinTrialIfNeeded()
|
|
|
+ // Meet blocks WKWebView. To support instant-stop recording we must create a real Meet space (with meeting code)
|
|
|
+ // before launching the user's browser.
|
|
|
+ guard hasGoogleSessionAvailable() else {
|
|
|
+ showSimpleAlert(
|
|
|
+ title: "Connect Google to start Instant Meeting",
|
|
|
+ message: "To auto-stop recording when the meeting ends, connect your Google account first."
|
|
|
+ )
|
|
|
+ guard let fallbackURL = URL(string: "https://meet.google.com/new") else { return }
|
|
|
+ openInDefaultBrowser(url: fallbackURL)
|
|
|
+ consumeNonPremiumJoinTrialIfNeeded()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ let title = "Instant Meeting"
|
|
|
+ let consentChoice = requestMeetingRecordingConsent(title: title)
|
|
|
+ if consentChoice == .dismissed { return }
|
|
|
+
|
|
|
+ meetingRecordingMonitorTask?.cancel()
|
|
|
+ meetingRecordingMonitorTask = nil
|
|
|
+ if activeMeetingRecordingSession != nil { finishActiveMeetingRecording(cancelMonitoring: false) }
|
|
|
+
|
|
|
+ Task { [weak self] in
|
|
|
+ guard let self else { return }
|
|
|
+ do {
|
|
|
+ let now = Date()
|
|
|
+ let end = now.addingTimeInterval(60 * 60) // 1h placeholder; Meet lifecycle monitor will stop recording when call ends.
|
|
|
+ let token = try await self.googleOAuth.validAccessToken(presentingWindow: self.view.window)
|
|
|
+ let meeting = try await self.calendarClient.createEvent(
|
|
|
+ accessToken: token,
|
|
|
+ title: title,
|
|
|
+ description: nil,
|
|
|
+ start: now,
|
|
|
+ end: end
|
|
|
+ )
|
|
|
+
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ if consentChoice == .allowAndContinue {
|
|
|
+ // Start Meet API-based recording lifecycle monitoring using the real meeting URL (has code).
|
|
|
+ self.startAutomaticRecordingFlow(meetingTitle: title, meetingURL: meeting.meetURL)
|
|
|
+ }
|
|
|
+ self.openInDefaultBrowser(url: meeting.meetURL)
|
|
|
+ self.consumeNonPremiumJoinTrialIfNeeded()
|
|
|
+ }
|
|
|
+ } catch {
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ self.showSimpleAlert(title: "Could not create Instant Meeting", message: error.localizedDescription)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private func consumeNonPremiumJoinTrialIfNeeded() {
|