Skip to content

Fix Site Switcher screen not dismissing after adding self-hosted site #24273

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

Open
wants to merge 11 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
25.9
-----
* [*] Site Switcher screen now properly dismisses after successfully adding a self-hosted site. [#24273]

* [*] Updated site display logic in sidebar to prioritize showing the currently selected site on iPad. [#24277]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import WordPressUI

final class SiteSwitcherViewController: UIHostingController<SiteSwitcherView>, UIPopoverPresentationControllerDelegate {
private let viewModel: BlogListViewModel
private var signinObserver: NSObjectProtocol?

init(configuration: BlogListConfiguration = .defaultConfig,
addSiteAction: @escaping ((AddSiteMenuViewModel.Selection) -> Void),
Expand All @@ -28,6 +29,14 @@ final class SiteSwitcherViewController: UIHostingController<SiteSwitcherView>, U
if #available(iOS 17, *) {
AppTips.SitePickerTip().invalidate(reason: .actionPerformed)
}

// Add observer for sign-in completion notification
let notificationName = NSNotification.Name(WordPressAuthenticationManager.WPSigninDidFinishNotification)
signinObserver = NotificationCenter.default.addObserver(forName: notificationName, object: nil, queue: nil) { [weak self] _ in
DispatchQueue.main.async {
self?.presentingViewController?.dismiss(animated: true)
}
}
}

@objc private func buttonCloseTapped() {
Expand Down