Skip to content

Commit ea2b03e

Browse files
committed
Fix crash when user drag window to be compact when user has a modal controller in classroom.
1 parent 7da4995 commit ea2b03e

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

Flat/Launch/SceneManager.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © 2023 agora.io. All rights reserved.
77
//
88

9-
import Foundation
9+
import UIKit
1010

1111
private func randomForegroundWindow() -> UIWindow? {
1212
let connectedWindowScenes = UIApplication.shared.connectedScenes
@@ -51,9 +51,15 @@ class SceneManager {
5151
}
5252

5353
func updateWindowSceneTrait(_ windowScene: UIWindowScene) {
54-
let top = UIApplication.shared.topWith(windowScene: windowScene)
55-
if top is ClassRoomViewController || top is MixReplayViewController { // Dont reconfig when top is classroom or replay
56-
return
54+
var top: UIViewController? = UIApplication.shared.topWith(windowScene: windowScene)
55+
func shouldPreserve(_ vc: UIViewController) -> Bool {
56+
return vc is ClassRoomViewController || vc is MixReplayViewController
57+
}
58+
while let i = top {
59+
if shouldPreserve(i) { // Dont reconfig when top is classroom or replay
60+
return
61+
}
62+
top = i.presentingViewController
5763
}
5864
// To avoid the viewcontroller replace complex, only config the root viewcontroller now.
5965
config(windowScene: windowScene, user: AuthStore.shared.user)

Flat/Modules/Base/MainSplitViewController.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,6 @@ class MainSplitViewController: UISplitViewController, UISplitViewControllerDeleg
6363

6464
weak var detailUpdateDelegate: MainSplitViewControllerDetailUpdateDelegate?
6565

66-
override func viewDidAppear(_ animated: Bool) {
67-
super.viewDidAppear(animated)
68-
if canShowDetail {
69-
// Show detail for device support split
70-
if viewControllers.count == 1 {
71-
show(emptyDetailController)
72-
}
73-
}
74-
}
75-
7666
override func viewDidLoad() {
7767
super.viewDidLoad()
7868
delegate = self

0 commit comments

Comments
 (0)