Skip to content
Merged
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
2 changes: 2 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
* [*] 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]
* [*] Fix an issue with "Speed up your site" section not refreshing (fails silently) [#23966]

25.6
-----
Expand Down
4 changes: 2 additions & 2 deletions WordPress.xcworkspace/xcshareddata/swiftpm/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions WordPress/Classes/Models/Blog/BlogSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ open class BlogSettings: NSManagedObject {

/// Jetpack Setting: lazy load images.
///
@available(*, deprecated)
@NSManaged var jetpackLazyLoadImages: Bool

// MARK: - Discussion
Expand Down
24 changes: 0 additions & 24 deletions WordPress/Classes/Services/BlogJetpackSettingsService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -235,7 +212,6 @@ private extension BlogJetpackSettingsService {
}

func updateJetpackModulesSettings(_ settings: BlogSettings, remoteSettings: RemoteBlogJetpackModulesSettings) {
settings.jetpackLazyLoadImages = remoteSettings.lazyLoadImages
settings.jetpackServeImagesFromOurServers = remoteSettings.serveImagesFromOurServers
}

Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Utility/SharedStrings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -32,6 +33,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)
Expand All @@ -40,6 +42,7 @@ open class JetpackSpeedUpSiteSettingsViewController: UITableViewController {

open override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

reloadViewModel()
refreshSettings()
}
Expand All @@ -51,34 +54,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")
)
])
}

Expand All @@ -92,36 +79,25 @@ open class JetpackSpeedUpSiteSettingsViewController: UITableViewController {

self.service.updateJetpackServeImagesFromOurServersModuleSettingForBlog(self.blog,
success: {},
failure: { [weak self] (_) in
failure: { [weak self] _ in
self?.refreshSettingsAfterSavingError()
})
}
}

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() {
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() {
Expand Down