Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure tab state is torn down on window close #3364

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ final class ActiveDomainPublisher {
private var activeWindowControllerCancellable: AnyCancellable?
private var activeTabViewModelCancellable: AnyCancellable?
private var activeTabContentCancellable: AnyCancellable?
private var unregisterWindowControllerCancellable: AnyCancellable?

@MainActor private weak var activeWindowController: MainWindowController? {
didSet {
Expand All @@ -47,6 +48,7 @@ final class ActiveDomainPublisher {

Task { @MainActor in
subscribeToKeyWindowControllerChanges()
subscribeToUnregisteringWindowController()
}
}

Expand Down Expand Up @@ -76,6 +78,16 @@ final class ActiveDomainPublisher {
.assign(to: \.activeDomain, onWeaklyHeld: self)
}

@MainActor
private func subscribeToUnregisteringWindowController() {
unregisterWindowControllerCancellable = windowControllersManager.didUnregisterWindowController.sink { [weak self] in
guard let self else { return }
if self.activeWindowController == $0 {
self.activeWindowController = nil
}
}
}

private func domain(from tabContent: Tab.TabContent) -> String? {
if case .url(let url, _, _) = tabContent {

Expand Down
Loading