Skip to content

Commit

Permalink
Add VerCmp
Browse files Browse the repository at this point in the history
  • Loading branch information
SaifAqqad committed Jan 1, 2022
1 parent 7c374a2 commit 3e9a598
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/Lib/WinUtils.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,10 @@ util_toString(obj){
output_str:= SubStr(output_str, 1, -2) . " "
output_str .= isArray? "]": "}"
return output_str
}

util_VerCmp(V1, V2) { ; VerCmp() for Windows by SKAN on D35T/D37L @ tiny.cc/vercmp
Return ( ( V1 := Format("{:04X}{:04X}{:04X}{:04X}", StrSplit(V1 . "...", ".",, 5)*) )
< ( V2 := Format("{:04X}{:04X}{:04X}{:04X}", StrSplit(V2 . "...", ".",, 5)*) ) )
? -1 : ( V2<V1 ) ? 1 : 0
}
2 changes: 1 addition & 1 deletion src/UI/config/UI.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ UI_checkForUpdates(neutron:=""){
if(latestVersion){
about_obj.doc.getElementById("latest_version").innerText:= latestVersion
refreshButton.classList.add("push-right")
if(latestVersion != A_Version){
if(util_VerCmp(latestVersion, A_Version) = 1){
about_obj.doc.getElementById("update_button").classList.remove("is-hidden")
}
}
Expand Down
11 changes: 7 additions & 4 deletions src/Updater.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Updater {
this.logError("Scoop update failed")
return -1
}
arg_installPath.= "..\current"
arg_installPath.= "\..\current"
this.loggerFunc.call("Scoop update successful", 1)
return 0
}
Expand All @@ -81,9 +81,12 @@ class Updater {
return
}
latestVersion:= this.getLatestVersion()
if(latestVersion && latestVersion != A_Version){
if(isBackground)
TrayTip, MicMute, % "An Update for MicMute is available, click 'Check for updates' in the tray menu to update"
if(latestVersion && util_VerCmp(latestVersion, A_Version) = 1){
if(isBackground){
tray_defaults()
TrayTip, MicMute, % "A new version of MicMute is available, click 'Check for updates' in the tray menu to update"
onUpdateState(mic_controllers[1])
}
return latestVersion
}
}
Expand Down

0 comments on commit 3e9a598

Please sign in to comment.