From f96ba4943ca3fabb34dbdb7329dc9adcf9d2e2f2 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 19 Jan 2025 21:18:29 -0800 Subject: [PATCH] Remove some no-longer-needed #available checks. --- .../Detail/DetailWebViewController.swift | 18 +------ Shared/Widget/WidgetDataEncoder.swift | 52 +++++++++---------- 2 files changed, 26 insertions(+), 44 deletions(-) diff --git a/Mac/MainWindow/Detail/DetailWebViewController.swift b/Mac/MainWindow/Detail/DetailWebViewController.swift index 91700cd9e..67f7877b8 100644 --- a/Mac/MainWindow/Detail/DetailWebViewController.swift +++ b/Mac/MainWindow/Detail/DetailWebViewController.swift @@ -94,19 +94,6 @@ final class DetailWebViewController: NSViewController { view = webView - // Use the safe area layout guides if they are available. - if #available(OSX 11.0, *) { - // These constraints have been removed as they were unsatisfiable after removing NSBox. - } else { - let constraints = [ - webView.topAnchor.constraint(equalTo: view.topAnchor), - webView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - webView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - webView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - ] - NSLayoutConstraint.activate(constraints) - } - // Hide the web view until the first reload (navigation) is complete (plus some delay) to avoid the awful white flash that happens on the initial display in dark mode. // See bug #901. webView.isHidden = true @@ -318,10 +305,7 @@ private extension DetailWebViewController { } func fetchScrollInfo(_ completion: @escaping (ScrollInfo?) -> Void) { - var javascriptString = "var x = {contentHeight: document.body.scrollHeight, offsetY: document.body.scrollTop}; x" - if #available(macOS 10.15, *) { - javascriptString = "var x = {contentHeight: document.body.scrollHeight, offsetY: window.pageYOffset}; x" - } + let javascriptString = "var x = {contentHeight: document.body.scrollHeight, offsetY: window.pageYOffset}; x" webView.evaluateJavaScript(javascriptString) { (info, error) in guard let info = info as? [String: Any] else { diff --git a/Shared/Widget/WidgetDataEncoder.swift b/Shared/Widget/WidgetDataEncoder.swift index 4d7c6ebb5..63fc704a3 100644 --- a/Shared/Widget/WidgetDataEncoder.swift +++ b/Shared/Widget/WidgetDataEncoder.swift @@ -34,35 +34,33 @@ public final class WidgetDataEncoder { } func encode() { - if #available(iOS 14, *) { - isRunning = true - - flushSharedContainer() - os_log(.debug, log: log, "Starting encoding widget data.") - - DispatchQueue.main.async { - self.encodeWidgetData() { latestData in - guard let latestData = latestData else { - self.isRunning = false - return - } - - let encodedData = try? JSONEncoder().encode(latestData) - - os_log(.debug, log: self.log, "Finished encoding widget data.") - - if self.fileExists() { - try? FileManager.default.removeItem(at: self.dataURL!) - os_log(.debug, log: self.log, "Removed widget data from container.") - } - - if FileManager.default.createFile(atPath: self.dataURL!.path, contents: encodedData, attributes: nil) { - os_log(.debug, log: self.log, "Wrote widget data to container.") - WidgetCenter.shared.reloadAllTimelines() - } - + isRunning = true + + flushSharedContainer() + os_log(.debug, log: log, "Starting encoding widget data.") + + DispatchQueue.main.async { + self.encodeWidgetData() { latestData in + guard let latestData = latestData else { self.isRunning = false + return } + + let encodedData = try? JSONEncoder().encode(latestData) + + os_log(.debug, log: self.log, "Finished encoding widget data.") + + if self.fileExists() { + try? FileManager.default.removeItem(at: self.dataURL!) + os_log(.debug, log: self.log, "Removed widget data from container.") + } + + if FileManager.default.createFile(atPath: self.dataURL!.path, contents: encodedData, attributes: nil) { + os_log(.debug, log: self.log, "Wrote widget data to container.") + WidgetCenter.shared.reloadAllTimelines() + } + + self.isRunning = false } } }