From 5879f6adcbc5b7aebfaf2b9c1f4b599e82e6fa24 Mon Sep 17 00:00:00 2001 From: kean Date: Fri, 10 Jan 2025 10:25:42 -0500 Subject: [PATCH 1/5] Remove lazy loading: --- .../Classes/Models/Blog/BlogSettings.swift | 1 + .../Services/BlogJetpackSettingsService.swift | 24 ---------- ...ackSpeedUpSiteSettingsViewController.swift | 44 ++++--------------- 3 files changed, 9 insertions(+), 60 deletions(-) diff --git a/WordPress/Classes/Models/Blog/BlogSettings.swift b/WordPress/Classes/Models/Blog/BlogSettings.swift index d07e8368719d..ff1f175d26b8 100644 --- a/WordPress/Classes/Models/Blog/BlogSettings.swift +++ b/WordPress/Classes/Models/Blog/BlogSettings.swift @@ -71,6 +71,7 @@ open class BlogSettings: NSManagedObject { /// Jetpack Setting: lazy load images. /// + @available(*, deprecated) @NSManaged var jetpackLazyLoadImages: Bool // MARK: - Discussion diff --git a/WordPress/Classes/Services/BlogJetpackSettingsService.swift b/WordPress/Classes/Services/BlogJetpackSettingsService.swift index e8a58a197868..f300c8aae2ef 100644 --- a/WordPress/Classes/Services/BlogJetpackSettingsService.swift +++ b/WordPress/Classes/Services/BlogJetpackSettingsService.swift @@ -142,29 +142,6 @@ struct BlogJetpackSettingsService { ) } - func updateJetpackLazyImagesModuleSettingForBlog(_ blog: Blog, success: @escaping () -> Void, failure: @escaping (Error?) -> Void) { - guard let blogSettings = blog.settings else { - failure(nil) - return - } - - let isActive = blogSettings.jetpackLazyLoadImages - updateJetpackModuleActiveSettingForBlog( - blog, - module: BlogJetpackSettingsServiceRemote.Keys.lazyLoadImages, - active: isActive, - success: { - self.coreDataStack.performAndSave({ context in - guard let blogSettingsInContext = Blog.lookup(withObjectID: blog.objectID, in: context)?.settings else { - return - } - blogSettingsInContext.jetpackLazyLoadImages = isActive - }, completion: success, on: .main) - }, - failure: failure - ) - } - func updateJetpackServeImagesFromOurServersModuleSettingForBlog(_ blog: Blog, success: @escaping () -> Void, failure: @escaping (Error?) -> Void) { guard let blogSettings = blog.settings else { failure(nil) @@ -235,7 +212,6 @@ private extension BlogJetpackSettingsService { } func updateJetpackModulesSettings(_ settings: BlogSettings, remoteSettings: RemoteBlogJetpackModulesSettings) { - settings.jetpackLazyLoadImages = remoteSettings.lazyLoadImages settings.jetpackServeImagesFromOurServers = remoteSettings.serveImagesFromOurServers } diff --git a/WordPress/Classes/ViewRelated/Jetpack/Jetpack Settings/JetpackSpeedUpSiteSettingsViewController.swift b/WordPress/Classes/ViewRelated/Jetpack/Jetpack Settings/JetpackSpeedUpSiteSettingsViewController.swift index 38741318ab74..a5b10d2e3233 100644 --- a/WordPress/Classes/ViewRelated/Jetpack/Jetpack Settings/JetpackSpeedUpSiteSettingsViewController.swift +++ b/WordPress/Classes/ViewRelated/Jetpack/Jetpack Settings/JetpackSpeedUpSiteSettingsViewController.swift @@ -32,6 +32,7 @@ open class JetpackSpeedUpSiteSettingsViewController: UITableViewController { open override func viewDidLoad() { super.viewDidLoad() + title = NSLocalizedString("Speed up your site", comment: "Title for the Speed up your site Settings Screen") ImmuTable.registerRows([SwitchRow.self], tableView: tableView) WPStyleGuide.configureColors(view: view, tableView: tableView) @@ -51,34 +52,18 @@ open class JetpackSpeedUpSiteSettingsViewController: UITableViewController { } func tableViewModel() -> ImmuTable { - - let serveImagesFromOurServers = SwitchRow(title: NSLocalizedString("Serve images from our servers", - comment: "Title for the Serve images from our servers setting"), - value: self.settings.jetpackServeImagesFromOurServers, - onChange: self.serveImagesFromOurServersValueChanged()) - - let lazyLoadImages = SwitchRow(title: NSLocalizedString("\"Lazy-load\" images", - comment: "Title for the lazy load images setting"), - value: self.settings.jetpackLazyLoadImages, - onChange: self.lazyLoadImagesValueChanged()) + let serveImagesFromOurServers = SwitchRow( + title: NSLocalizedString("Serve images from our servers", + comment: "Title for the Serve images from our servers setting"), + value: self.settings.jetpackServeImagesFromOurServers, + onChange: self.serveImagesFromOurServersValueChanged()) return ImmuTable(sections: [ ImmuTableSection( headerText: "", rows: [serveImagesFromOurServers], - footerText: NSLocalizedString("Jetpack will optimize your images and serve them from the server " + - "location nearest to your visitors. Using our global content delivery " + - "network will boost the loading speed of your site.", - comment: "Footer for the Serve images from our servers setting")), - - ImmuTableSection( - headerText: "", - rows: [lazyLoadImages], - footerText: NSLocalizedString("Improve your site's speed by only loading images visible on the screen. " + - "New images will load just before they scroll into view. This prevents " + - "viewers from having to download all the images on a page all at once, " + - "even ones they can't see.", - comment: "Footer for the Serve images from our servers setting")), + footerText: NSLocalizedString("Jetpack will optimize your images and serve them from the server location nearest to your visitors. Using our global content delivery network will boost the loading speed of your site.", comment: "Footer for the Serve images from our servers setting") + ) ]) } @@ -98,19 +83,6 @@ open class JetpackSpeedUpSiteSettingsViewController: UITableViewController { } } - fileprivate func lazyLoadImagesValueChanged() -> (_ newValue: Bool) -> Void { - return { [unowned self] newValue in - self.settings.jetpackLazyLoadImages = newValue - self.reloadViewModel() - WPAnalytics.trackSettingsChange("jetpack_speed_up_site", fieldName: "lazy_load_images", value: newValue as Any) - self.service.updateJetpackLazyImagesModuleSettingForBlog(self.blog, - success: {}, - failure: { [weak self] (_) in - self?.refreshSettingsAfterSavingError() - }) - } - } - // MARK: - Persistance fileprivate func refreshSettings() { From 586d9ebc53498c91ef70a5ec19bb374c220504bd Mon Sep 17 00:00:00 2001 From: kean Date: Fri, 10 Jan 2025 10:28:59 -0500 Subject: [PATCH 2/5] Add error handling --- WordPress/Classes/Utility/SharedStrings.swift | 1 + ...ackSpeedUpSiteSettingsViewController.swift | 22 +++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/WordPress/Classes/Utility/SharedStrings.swift b/WordPress/Classes/Utility/SharedStrings.swift index 32c4c32adcc8..d22a5186b5ec 100644 --- a/WordPress/Classes/Utility/SharedStrings.swift +++ b/WordPress/Classes/Utility/SharedStrings.swift @@ -23,6 +23,7 @@ enum SharedStrings { enum Error { static let generic = NSLocalizedString("shared.error.geneirc", value: "Something went wrong", comment: "A generic error message") + static let refreshFailed = NSLocalizedString("shared.error.failiedToReloadData", value: "Failed to update data", comment: "A generic error title indicating that a screen failed to fetch the latest data") } enum Reader { diff --git a/WordPress/Classes/ViewRelated/Jetpack/Jetpack Settings/JetpackSpeedUpSiteSettingsViewController.swift b/WordPress/Classes/ViewRelated/Jetpack/Jetpack Settings/JetpackSpeedUpSiteSettingsViewController.swift index a5b10d2e3233..b15d4f330b2d 100644 --- a/WordPress/Classes/ViewRelated/Jetpack/Jetpack Settings/JetpackSpeedUpSiteSettingsViewController.swift +++ b/WordPress/Classes/ViewRelated/Jetpack/Jetpack Settings/JetpackSpeedUpSiteSettingsViewController.swift @@ -24,6 +24,7 @@ open class JetpackSpeedUpSiteSettingsViewController: UITableViewController { @objc public convenience init(blog: Blog) { self.init(style: .insetGrouped) + self.blog = blog self.service = BlogJetpackSettingsService(coreDataStack: ContextManager.shared) } @@ -41,6 +42,7 @@ open class JetpackSpeedUpSiteSettingsViewController: UITableViewController { open override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + reloadViewModel() refreshSettings() } @@ -77,7 +79,7 @@ open class JetpackSpeedUpSiteSettingsViewController: UITableViewController { self.service.updateJetpackServeImagesFromOurServersModuleSettingForBlog(self.blog, success: {}, - failure: { [weak self] (_) in + failure: { [weak self] _ in self?.refreshSettingsAfterSavingError() }) } @@ -86,14 +88,16 @@ open class JetpackSpeedUpSiteSettingsViewController: UITableViewController { // MARK: - Persistance fileprivate func refreshSettings() { - service.syncJetpackModulesForBlog(blog, - success: { [weak self] in - self?.reloadViewModel() - DDLogInfo("Reloaded Speed up site settings") - }, - failure: { (error: Error?) in - DDLogError("Error while syncing blog Speed up site settings: \(String(describing: error))") - }) + service.syncJetpackModulesForBlog( + blog, + success: { [weak self] in + self?.reloadViewModel() + DDLogInfo("Reloaded Speed up site settings") + }, + failure: { (error: Error?) in + Notice(title: SharedStrings.Error.refreshFailed, message: error?.localizedDescription).post() + DDLogError("Error while syncing blog Speed up site settings: \(String(describing: error))") + }) } fileprivate func refreshSettingsAfterSavingError() { From f6837590a8ebfba42183104cb445161c0ff238b5 Mon Sep 17 00:00:00 2001 From: kean Date: Fri, 10 Jan 2025 10:33:18 -0500 Subject: [PATCH 3/5] Update release notes --- RELEASE-NOTES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 718ed2c51cec..4eb23ff6071c 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -40,6 +40,7 @@ * [*] Fix “Notification Settings” for individual posts sometimes being clipped [#23964] * [*] Add context menu (long-press) and previews for subscriptions with quick access to “Share”, “Copy Link”, “Add to Favorites”, “Notification Settings”, and “Unsubscribe” buttons in both the Subscriptions view and the Sidebar in Reader [#23964] * [*] Fix an issue with fullscreen button in reply view clipped by the notch [#23965] +* [*] Remove "Lazy Images" option that is no longer part of the Jetpack plugin [#23966] 25.6 ----- From 8d0a90035f46a541b6a8ecde6929b88706c74f70 Mon Sep 17 00:00:00 2001 From: kean Date: Fri, 10 Jan 2025 10:49:55 -0500 Subject: [PATCH 4/5] Update WordPressKit (has lazy-load fix) --- WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved b/WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved index 1f17bfb4d604..9b40119bc337 100644 --- a/WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "c6c4224bb9091cbaed87a958001b2435576248fec163dc8ce6be041f8e1da166", + "originHash" : "e25628bd63dad3b77f7c0ba1cdf36c20bd1dfaf03b083ccfc06d8806824c77df", "pins" : [ { "identity" : "alamofire", @@ -383,7 +383,7 @@ "location" : "https://github.com/wordpress-mobile/WordPressKit-iOS", "state" : { "branch" : "wpios-edition", - "revision" : "908d96a6ff4eb38217e57c03996bf1f3e9cdb114" + "revision" : "a9a057ea6fba8080c146497336951dc805409771" } }, { From 93dec0e11f7604a18a8716081b47b7974f12e132 Mon Sep 17 00:00:00 2001 From: kean Date: Fri, 10 Jan 2025 10:51:53 -0500 Subject: [PATCH 5/5] Update release notes --- RELEASE-NOTES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 4eb23ff6071c..b44c23f2a027 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -41,6 +41,7 @@ * [*] Add context menu (long-press) and previews for subscriptions with quick access to “Share”, “Copy Link”, “Add to Favorites”, “Notification Settings”, and “Unsubscribe” buttons in both the Subscriptions view and the Sidebar in Reader [#23964] * [*] Fix an issue with fullscreen button in reply view clipped by the notch [#23965] * [*] Remove "Lazy Images" option that is no longer part of the Jetpack plugin [#23966] +* [*] Fix an issue with "Speed up your site" section not refreshing (fails silently) [#23966] 25.6 -----