Skip to content

Commit

Permalink
Manual update for Linux and Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Nov 26, 2021
1 parent 8d80e63 commit 51c0575
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 40 deletions.
4 changes: 2 additions & 2 deletions app/application/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ <h5 class="mx-3 flex flex-row m-0 font-bold build-content text-center">You are r

<p class="mx-3 flex flex-row relative top-3">
New Authme version available. Please update your app!
<button type="button" onclick="downloadUpdate()" class="mr-2 ml-3 py-1 px-3 relative -top-2.5 bg-white hover:bg-transparent text-black border-2 border-white hover:text-white cursor-pointer transition ease-in duration-200 text-center text-base font-bold rounded-full">
<button type="button" onclick="manualUpdate()" class="mr-2 ml-3 py-1 px-3 relative -top-2.5 bg-white hover:bg-transparent text-black border-2 border-white hover:text-white cursor-pointer transition ease-in duration-200 text-center text-base font-bold rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1" height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
</svg>
Download update
Manual update
</button>
<button type="button" onclick="releaseNotes()" class="py-1 px-3 relative -top-2.5 bg-white hover:bg-transparent text-black border-2 border-white hover:text-white cursor-pointer transition ease-in duration-200 text-center text-base font-bold rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1" height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor">
Expand Down
24 changes: 14 additions & 10 deletions app/application/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -824,16 +824,6 @@ const quickCopy = (key) => {
}
}

// ? release notes
const releaseNotes = () => {
ipc.send("release_notes")
}

// ? download update
const downloadUpdate = () => {
ipc.send("download_update")
}

// ? rate
const rateAuthme = () => {
ipc.send("rate_authme")
Expand Down Expand Up @@ -889,3 +879,17 @@ window.addEventListener("click", (event) => {
dropdown_state = false
}
})

/**
* Display release notes
*/
const releaseNotes = () => {
ipc.send("releaseNotes")
}

/**
* Download manual update
*/
const manualUpdate = () => {
ipc.send("manualUpdate")
}
4 changes: 2 additions & 2 deletions app/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ <h5 class="mx-3 flex flex-row m-0 font-bold build-content text-center">You are r

<p class="mx-3 flex flex-row relative top-3">
New Authme version available. Please update your app!
<button type="button" onclick="downloadUpdate()" class="mr-2 ml-3 py-1 px-3 relative -top-2.5 bg-white hover:bg-transparent text-black border-2 border-white hover:text-white cursor-pointer transition ease-in duration-200 text-center text-base font-bold rounded-full">
<button type="button" onclick="manualUpdate()" class="mr-2 ml-3 py-1 px-3 relative -top-2.5 bg-white hover:bg-transparent text-black border-2 border-white hover:text-white cursor-pointer transition ease-in duration-200 text-center text-base font-bold rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1" height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
</svg>
Download update
Manual update
</button>
<button type="button" onclick="releaseNotes()" class="py-1 px-3 relative -top-2.5 bg-white hover:bg-transparent text-black border-2 border-white hover:text-white cursor-pointer transition ease-in duration-200 text-center text-base font-bold rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1" height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor">
Expand Down
24 changes: 14 additions & 10 deletions app/settings/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,16 +559,6 @@ const save = () => {
fs.writeFileSync(path.join(folder_path, "settings", "settings.json"), JSON.stringify(settings, null, "\t"))
}

// ? release notes
const releaseNotes = () => {
ipc.send("release_notes")
}

// ? download update
const downloadUpdate = () => {
ipc.send("download_update")
}

// ? rate
const rateAuthme = () => {
ipc.send("rate_authme")
Expand Down Expand Up @@ -858,3 +848,17 @@ window.addEventListener("click", (event) => {
dropdown_state = false
}
})

/**
* Display release notes
*/
const releaseNotes = () => {
ipc.send("releaseNotes")
}

/**
* Download manual update
*/
const manualUpdate = () => {
ipc.send("manualUpdate")
}
42 changes: 26 additions & 16 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ if (number.startsWith("alpha")) {
pre_release = true
}

/**
* Get platform
*/
let platform

if (process.platform === "win32") {
platform = "windows"
} else if (process.platform === "darwin") {
platform = "mac"
} else {
platform = "linux"
}

// ? remote module
remote.initialize()

Expand Down Expand Up @@ -566,7 +579,9 @@ const createWindow = () => {
window_export.setContentProtection(true)
window_edit.setContentProtection(true)

// ? check for auto update
/**
* Check for manual update
*/
window_application.on("show", () => {
const api = () => {
axios
Expand All @@ -579,18 +594,13 @@ const createWindow = () => {
window_settings.webContents.executeJavaScript("showUpdate()")
})

new Notification({
title: "Authme Update",
body: `Update available: Authme ${res.data.tag_name}`,
}).show()

logger.log("Auto update found!")
logger.log("Manual update found!")
} else {
logger.log("No auto update found!")
logger.log("No manual update found!")
}
})
.catch((error) => {
logger.error("Error during auto update", error.stack)
logger.error("Error during manual update", error.stack)
})
}

Expand All @@ -603,7 +613,7 @@ const createWindow = () => {
reload = true
}

if (update_seen == false) {
if (update_seen == false && platform !== "windows") {
api()

update_seen = true
Expand Down Expand Up @@ -981,18 +991,18 @@ ipc.on("offline", () => {
}
})

ipc.on("release_notes", () => {
/**
* Display release notes
*/
ipc.on("releaseNotes", () => {
releaseNotes()
})

ipc.on("download_update", () => {
ipc.on("manualUpdate", () => {
axios
.get("https://api.levminer.com/api/v1/authme/releases")
.then((res) => {
if (res.data.tag_name > tag_name && res.data.tag_name != undefined && res.data.prerelease != true) {
const notes = markdown.convert(res.data.body).split("\n").slice(4).join("\n").split("Bug")[0]
const message = `Update available: Authme ${res.data.tag_name}\n\nYou currently running: Authme ${tag_name}\n\nNotable changes:\n\n${notes}Check out release note for all changes.`

dialog
.showMessageBox({
title: "Authme",
Expand All @@ -1001,7 +1011,7 @@ ipc.on("download_update", () => {
cancelId: 1,
noLink: true,
type: "info",
message: message,
message: `Update available: Authme ${res.data.tag_name} \n\nDo you want to download it? \n\nYou currently running: Authme ${tag_name}`,
})
.then((result) => {
if (result.response === 0) {
Expand Down

0 comments on commit 51c0575

Please sign in to comment.