4
0
mirror of https://github.com/AltarikMC/Launcher synced 2024-11-22 06:19:50 +01:00

Fix updater (well I think too)

This commit is contained in:
Quentin Legot 2022-10-13 21:55:09 +02:00
parent f9142e9094
commit 7d2eeb9e69

View File

@ -56,25 +56,31 @@ class Updater {
win.loadFile('src/client/login.html')
})
} else {
fetch(feed).then(response => {
this.searchUpdateLinux(win, showNotification)
}
}
searchUpdateLinux(win, showNotification) {
const url = 'https://api.github.com/repos/AltarikMc/Launcher/releases/latest'
fetch(url).then(response => {
if(response.status === 200) {
response.json().then(json => {
win.webContents.send("please-download-update", { url: json.url} )
})
if(json.tag_name !== pkg.version) {
let asset = json.assets.filter(el => el.browser_download_url.inludes(".zip"))
if(asset.length ===1) {
let downloadUrl = asset[0].browser_download_url
win.webContents.send("please-download-update", { url: downloadUrl} )
} else {
if(response.status === 204) {
this.logger.info("update not available")
win.loadFile('src/client/login.html')
this.displayError(win, showNotification, "Can't find right asset in last update")
}
}
}).catch(err => this.displayError(win, showNotification, err)
)
} else {
this.displayError(win, showNotification, "Server return " + response.status + " http code")
this.displayError(win, showNotification, "Server unavailable")
}
}
}).catch(err => {
this.displayError(win, showNotification, err)
})
}
}).catch(err => this.displayError(win, showNotification, err))
}
displayError(win, showNotification, errorMessage) {