diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index c16e0c5e245c..c28c0c8c604f 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -1,5 +1,6 @@ 19.9 ----- +* [*] Site Settings: we fixed an issue that prevented the site title to be updated when it changed in Site Settings [#18543] * [*] Media Picker: Fixed an issue where the empty state view was being displayed incorrectly. [#18471] 19.8 diff --git a/WordPress/Classes/ViewRelated/Blog/Site Picker/SitePickerViewController.swift b/WordPress/Classes/ViewRelated/Blog/Site Picker/SitePickerViewController.swift index e1c1c5fa1077..1be43acc569a 100644 --- a/WordPress/Classes/ViewRelated/Blog/Site Picker/SitePickerViewController.swift +++ b/WordPress/Classes/ViewRelated/Blog/Site Picker/SitePickerViewController.swift @@ -45,6 +45,7 @@ final class SitePickerViewController: UIViewController { super.viewDidLoad() setupHeaderView() startObservingQuickStart() + startObservingTitleChanges() } deinit { @@ -57,6 +58,15 @@ final class SitePickerViewController: UIViewController { view.addSubview(blogDetailHeaderView) view.pinSubviewToAllEdges(blogDetailHeaderView) } + + private func startObservingTitleChanges() { + NotificationCenter.default.addObserver(forName: NSNotification.Name.WPBlogUpdated, + object: nil, + queue: .main) { [weak self] _ in + + self?.updateTitles() + } + } } // MARK: - BlogDetailHeaderViewDelegate @@ -191,7 +201,6 @@ extension SitePickerViewController { silentlyForBlog: blog) blogService.updateSettings(for: blog, success: { [weak self] in - NotificationCenter.default.post(name: NSNotification.Name.WPBlogUpdated, object: nil) let notice = Notice(title: title, message: SiteTitleStrings.titleChangeSuccessfulMessage, @@ -199,14 +208,7 @@ extension SitePickerViewController { ActionDispatcher.global.dispatch(NoticeAction.post(notice)) self?.blogDetailHeaderView.setTitleLoading(false) - self?.blogDetailHeaderView.refreshSiteTitle() - - guard let parent = self?.parent as? MySiteViewController else { - return - } - - parent.updateNavigationTitle(for: blog) - + NotificationCenter.default.post(name: NSNotification.Name.WPBlogUpdated, object: nil) }, failure: { [weak self] error in self?.blog.settings?.name = existingBlogTitle self?.blogDetailHeaderView.setTitleLoading(false) @@ -219,6 +221,16 @@ extension SitePickerViewController { }) } + /// Updates site title and navigation bar title + private func updateTitles() { + blogDetailHeaderView.refreshSiteTitle() + + guard let parent = parent as? MySiteViewController else { + return + } + parent.updateNavigationTitle(for: blog) + } + private func showViewSite() { WPAppAnalytics.track(.openedViewSite, withProperties: [WPAppAnalyticsKeyTapSource: "link"], with: blog)