mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 20:10:08 +02:00
👌 Improved updater
This commit is contained in:
@ -1515,7 +1515,7 @@
|
|||||||
C41C1B4422B0098000E7CF16 /* Debug */ = {
|
C41C1B4422B0098000E7CF16 /* Debug */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconDev;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = phpmon/phpmon.entitlements;
|
CODE_SIGN_ENTITLEMENTS = phpmon/phpmon.entitlements;
|
||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
@ -1541,7 +1541,7 @@
|
|||||||
C41C1B4522B0098000E7CF16 /* Release */ = {
|
C41C1B4522B0098000E7CF16 /* Release */ = {
|
||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIconDev;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = phpmon/phpmon.entitlements;
|
CODE_SIGN_ENTITLEMENTS = phpmon/phpmon.entitlements;
|
||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
@ -76,19 +76,50 @@ class AppUpdateChecker {
|
|||||||
_ onlineVersion: AppVersion,
|
_ onlineVersion: AppVersion,
|
||||||
_ background: Bool
|
_ background: Bool
|
||||||
) {
|
) {
|
||||||
switch onlineVersion.comparable.versionCompare(currentVersion.comparable) {
|
switch onlineVersion.version.versionCompare(currentVersion.version) {
|
||||||
case .orderedAscending:
|
case .orderedAscending:
|
||||||
Log.info("You are running a newer version of PHP Monitor.")
|
Log.info("You are running a newer version of PHP Monitor "
|
||||||
|
+ "(\(currentVersion.computerReadable) > \(onlineVersion.computerReadable)).")
|
||||||
if !background { notifyVersionDoesNotNeedUpgrade() }
|
if !background { notifyVersionDoesNotNeedUpgrade() }
|
||||||
case .orderedDescending:
|
case .orderedDescending:
|
||||||
Log.info("There is a newer version (\(onlineVersion)) available!")
|
Log.info("There is a newer version (\(onlineVersion)) available! "
|
||||||
|
+ "(\(onlineVersion.computerReadable) > \(currentVersion.computerReadable))")
|
||||||
notifyAboutNewerVersion(version: onlineVersion)
|
notifyAboutNewerVersion(version: onlineVersion)
|
||||||
case .orderedSame:
|
case .orderedSame:
|
||||||
Log.info("The installed version (\(currentVersion)) matches the latest release (\(onlineVersion)).")
|
// Check if the build number differs
|
||||||
|
if currentVersion.build != nil
|
||||||
|
&& onlineVersion.build != nil
|
||||||
|
&& buildDiffers(currentVersion, onlineVersion, background) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the build number does not differ... it's the same release
|
||||||
|
Log.info("The installed version (\(currentVersion.computerReadable)) matches the latest release "
|
||||||
|
+ "(\(onlineVersion.computerReadable)).")
|
||||||
if !background { notifyVersionDoesNotNeedUpgrade() }
|
if !background { notifyVersionDoesNotNeedUpgrade() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static func buildDiffers(
|
||||||
|
_ currentVersion: AppVersion,
|
||||||
|
_ onlineVersion: AppVersion,
|
||||||
|
_ background: Bool
|
||||||
|
) -> Bool {
|
||||||
|
if Int(onlineVersion.build!)! > Int(currentVersion.build!)! {
|
||||||
|
Log.info("There is a newer build of PHP Monitor available! "
|
||||||
|
+ "(\(onlineVersion.computerReadable) > \(currentVersion.computerReadable))")
|
||||||
|
notifyAboutNewerVersion(version: onlineVersion)
|
||||||
|
return true
|
||||||
|
} else if Int(onlineVersion.build!)! < Int(currentVersion.build!)! {
|
||||||
|
Log.info("You are running a newer build of PHP Monitor "
|
||||||
|
+ "(\(currentVersion.computerReadable) > \(onlineVersion.computerReadable)).")
|
||||||
|
if !background { notifyVersionDoesNotNeedUpgrade() }
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
private static func notifyVersionDoesNotNeedUpgrade() {
|
private static func notifyVersionDoesNotNeedUpgrade() {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
BetterAlert().withInformation(
|
BetterAlert().withInformation(
|
||||||
|
@ -64,17 +64,17 @@ class AppVersion {
|
|||||||
|
|
||||||
public static func fromCurrentVersion() -> AppVersion {
|
public static func fromCurrentVersion() -> AppVersion {
|
||||||
return AppVersion(
|
return AppVersion(
|
||||||
version: App.shortVersion,
|
version: VersionExtractor.from(App.shortVersion)!,
|
||||||
build: App.bundleVersion
|
build: App.bundleVersion
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
var humanReadable: String {
|
var computerReadable: String {
|
||||||
return "\(version) (\(build ?? "0"))"
|
return "\(version)_\(build ?? "???")"
|
||||||
}
|
}
|
||||||
|
|
||||||
var comparable: String {
|
var humanReadable: String {
|
||||||
return "\(version).\(build ?? "0")"
|
return "\(version) (\(build ?? "???"))"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user