Skip to content

Commit

Permalink
Improved some updater scaling UI, and actually checking each version …
Browse files Browse the repository at this point in the history
…in the version to not "update" to "old" version. And bumped version number
  • Loading branch information
VilleOlof committed Apr 28, 2023
1 parent 2328ea0 commit 26bcaf4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion AppSettings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"PluginID": "com.villeolof.toolbox",
"Version": "1.0.1",
"Version": "1.0.2",
"DataCollection": true,
"Debug": false,
"DisableShortcut-Keybind": "F1",
Expand Down
6 changes: 3 additions & 3 deletions src/Components/Update.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let showPopup: boolean = false;
let updateInfo: Updater.UpdateReturn;
onMount(async () => {
updateInfo = await Updater.CheckForUpdate();
showPopup = updateInfo.updateAvailable;
Expand Down Expand Up @@ -52,8 +52,8 @@
}
.popup-content {
width: 35%;
height: 35%;
width: 30rem;
height: 20rem;
display: flex;
flex-direction: column;
Expand Down
15 changes: 14 additions & 1 deletion src/Lib/Updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,25 @@ export namespace Updater {
const localVersion: string = AppSettings.GetSetting("Version");

return {
updateAvailable: githubVersion !== localVersion,
updateAvailable: CheckVersionNumbers(githubVersion, localVersion),
remoteVersion: githubVersion,
localVersion: localVersion
};
}

function CheckVersionNumbers(newVersion: string, oldVersion: string): boolean {
const newVersionNumbers: string[] = newVersion.split('.');
const oldVersionNumbers: string[] = oldVersion.split('.');

for (let i = 0; i < newVersionNumbers.length; i++) {
if (parseInt(newVersionNumbers[i]) > parseInt(oldVersionNumbers[i])) {
return true;
}
}

return false;
}

export function DownloadUpdate(): void {
const curlCommand: ChildProcess = Common.ExecuteCommand(`curl.exe -L ${RepoZIPUrl} -o "${root}../Toolbox.zip"`, `${root}../`);
curlCommand.stdout.on('data', (data) => {
Expand Down

0 comments on commit 26bcaf4

Please sign in to comment.