update function and settings option

This commit is contained in:
SpikeHD 2022-04-22 14:42:16 -07:00
parent b555457e5b
commit bbccfd83d4
3 changed files with 29 additions and 3 deletions

View File

@ -1,5 +1,5 @@
{
"applicationId": "js.grassclipper.app",
"version": "0.4.6",
"resourcesURL": "https://github.com/Grasscutters/GrassClipper/releases/latest/download/manifest.json"
"resourcesURL": "https://github.com/Grasscutters/GrassClipper/releases/latest/download/resources.neu"
}

View File

@ -50,9 +50,9 @@
<div class="settingsRow">
<div class="settingSection">
<span class="settingLabel">Update</span>
<button class="smolBtn disabled" onclick="checkForUpdatesAndShow()" disabled>Update</button>
<button class="smolBtn disabled" onclick="updateResources()" id="updateBtn" disabled>Update</button>
</div>
<span class="settingSubtitle">
<span class="settingSubtitle" id="updateSubtitle">
Checking for updates...
</span>
</div>

View File

@ -10,6 +10,9 @@ document.addEventListener('DOMContentLoaded', async () => {
setBackgroundImage();
displayGenshinFolder();
// Set title version
document.querySelector('#version').innerHTML = NL_APPVERSION
const config = await getCfg()
const ipArr = await getFavIps()
@ -349,6 +352,9 @@ async function openSettings() {
const killSwitch = document.querySelector('#killswitchOption')
killSwitch.checked = config.enableKillswitch
// Check for updates
checkForUpdatesAndShow()
}
async function closeSettings() {
@ -385,6 +391,26 @@ async function runInstallScript() {
closeFirstTimePopup()
}
async function updateResources() {
}
async function checkForUpdatesAndShow() {
const updateBtn = document.querySelector('#updateBtn')
const subtitle = document.querySelector('#updateSubtitle')
const url = 'https://github.com/Grasscutters/GrassClipper/releases/latest/download/'
const manifest = await Neutralino.updater.checkForUpdates(url)
// Version mismatch? Update!
if (manifest?.version !== NL_APPVERSION) {
subtitle.innerHTML = "New update available!"
updateBtn.classList.remove('disabled')
} else {
subtitle.innerHTML = "You are on the latest version! :)"
updateBtn.classList.add('disabled')
}
}
/**
* Set the game folder by opening a folder picker
*/