Skip to content

Commit

Permalink
Showing of update alert in case the macOS is not supported anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasstrba committed Aug 17, 2023
1 parent f84e781 commit 96fd7e2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
8 changes: 8 additions & 0 deletions DuckDuckGo/AppDelegate/UpdateController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ final class UpdateController: NSObject {
}

func checkForUpdates(_ sender: Any!) {
if !SupportedOSChecker.isCurrentOsSupported {
showNotSupportedInfo()
}

NSApp.windows.forEach {
if let controller = $0.windowController, "\(type(of: controller))" == "SUUpdateAlert" {
$0.orderFrontRegardless()
Expand Down Expand Up @@ -65,6 +69,10 @@ final class UpdateController: NSObject {
#endif
}

private func showNotSupportedInfo() {
NSAlert.osNotSupported().runModal()
}

}

extension UpdateController: SPUStandardUserDriverDelegate {
Expand Down
8 changes: 8 additions & 0 deletions DuckDuckGo/Common/Extensions/NSAlertExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ extension NSAlert {
return alert
}

static func osNotSupported() -> NSAlert {
let alert = NSAlert()
alert.messageText = UserText.unsupportedDeviceInfoAlertHeader
alert.informativeText = UserText.aboutUnsupportedDeviceInfo1(version: "\(ProcessInfo.processInfo.operatingSystemVersion)")
alert.alertStyle = .warning
return alert
}

@discardableResult
func runModal() async -> NSApplication.ModalResponse {
await withCheckedContinuation { continuation in
Expand Down
9 changes: 5 additions & 4 deletions DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,11 @@ struct UserText {
static func aboutUnsupportedDeviceInfo1(version: String) -> String {
return String(format: NSLocalizedString("preferences.about.unsupported-device-info1", value: "DuckDuckGo no longer supports macOS version %@. You will no longer receive feature or security updates.", comment: ""), version)
}
static let aboutUnsupportedDeviceInfo2Part1 = NSLocalizedString("preferences.about.unsupported-device-info2-part1", value: "If possible, you can ", comment: "Second paragraph of unsupported device info - part 1")
static let aboutUnsupportedDeviceInfo2Part2 = NSLocalizedString("preferences.about.unsupported-device-info2-part2", value: "update to a macOS version of 11.3", comment: "Second paragraph of unsupported device info - part 2")
static let aboutUnsupportedDeviceInfo2Part3 = NSLocalizedString("preferences.about.unsupported-device-info2-part3", value: " or greater to", comment: "Second paragraph of unsupported device info - part 3")
static let aboutUnsupportedDeviceInfo2Part4 = NSLocalizedString("preferences.about.unsupported-device-info2-part3", value: "continue to receive updates.", comment: "Second paragraph of unsupported device info - part 4")
static let aboutUnsupportedDeviceInfo2Part1 = NSLocalizedString("preferences.about.unsupported-device-info2-part1", value: "If possible, you can ", comment: "Second paragraph of unsupported device info - sentence part 1")
static let aboutUnsupportedDeviceInfo2Part2 = NSLocalizedString("preferences.about.unsupported-device-info2-part2", value: "update to a macOS version of 11.4", comment: "Second paragraph of unsupported device info - sentence part 2 (underlined)")
static let aboutUnsupportedDeviceInfo2Part3 = NSLocalizedString("preferences.about.unsupported-device-info2-part3", value: " or greater to", comment: "Second paragraph of unsupported device info - sentence part 3")
static let aboutUnsupportedDeviceInfo2Part4 = NSLocalizedString("preferences.about.unsupported-device-info2-part3", value: "continue to receive updates.", comment: "Second paragraph of unsupported device info - sentence part 4")
static let unsupportedDeviceInfoAlertHeader = NSLocalizedString("unsupported.device.info.alert.header", value: "Your version of macOS is no longer supported.", comment: "")


static func moreAt(url: String) -> String {
Expand Down
6 changes: 1 addition & 5 deletions DuckDuckGo/Preferences/View/PreferencesAboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ extension Preferences {
struct UnsupportedDeviceInfoBox: View {

static let appleSupportURL = URL(string: "https://support.apple.com/en-us/HT211238")!
let osVersion: String = {
let version = ProcessInfo.processInfo.operatingSystemVersion
return "\(version.majorVersion).\(version.minorVersion).\(version.patchVersion)"
}()

var wide: Bool

Expand All @@ -110,7 +106,7 @@ extension Preferences {
.frame(width: 16, height: 16)
.padding(.trailing, 4)
VStack(alignment: .leading, spacing: 12) {
Text(UserText.aboutUnsupportedDeviceInfo1(version: osVersion))
Text(UserText.aboutUnsupportedDeviceInfo1(version: "\(ProcessInfo.processInfo.operatingSystemVersion)"))
if wide {
VStack(alignment: .leading, spacing: 0) {
HStack(alignment: .center, spacing: 0) {
Expand Down

0 comments on commit 96fd7e2

Please sign in to comment.