mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-28 09:38:56 +01:00
Update version check to use releases from gh api instead of tags, add 5 minute buffer between checking for new releases
This commit is contained in:
parent
8942dca31d
commit
1a23001955
@ -485,6 +485,25 @@ export default {
|
||||
},
|
||||
resize() {
|
||||
this.$store.commit('globals/updateWindowSize', { width: window.innerWidth, height: window.innerHeight })
|
||||
},
|
||||
checkVersionUpdate() {
|
||||
// Version check is only run if time since last check was 5 minutes
|
||||
const VERSION_CHECK_BUFF = 1000 * 60 * 5 // 5 minutes
|
||||
var lastVerCheck = localStorage.getItem('lastVerCheck') || 0
|
||||
if (Date.now() - Number(lastVerCheck) > VERSION_CHECK_BUFF) {
|
||||
this.$store
|
||||
.dispatch('checkForUpdate')
|
||||
.then((res) => {
|
||||
localStorage.setItem('lastVerCheck', Date.now())
|
||||
if (res && res.hasUpdate) this.showUpdateToast(res)
|
||||
})
|
||||
.catch((err) => console.error(err))
|
||||
|
||||
if (this.$route.query.error) {
|
||||
this.$toast.error(this.$route.query.error)
|
||||
this.$router.replace(this.$route.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeMount() {
|
||||
@ -503,17 +522,7 @@ export default {
|
||||
this.$store.commit('setExperimentalFeatures', true)
|
||||
}
|
||||
|
||||
this.$store
|
||||
.dispatch('checkForUpdate')
|
||||
.then((res) => {
|
||||
if (res && res.hasUpdate) this.showUpdateToast(res)
|
||||
})
|
||||
.catch((err) => console.error(err))
|
||||
|
||||
if (this.$route.query.error) {
|
||||
this.$toast.error(this.$route.query.error)
|
||||
this.$router.replace(this.$route.path)
|
||||
}
|
||||
this.checkVersionUpdate()
|
||||
},
|
||||
beforeDestroy() {
|
||||
window.removeEventListener('resize', this.resize)
|
||||
|
@ -33,11 +33,12 @@ export async function checkForUpdate() {
|
||||
return
|
||||
}
|
||||
var largestVer = null
|
||||
await axios.get(`https://api.github.com/repos/advplyr/audiobookshelf/tags`).then((res) => {
|
||||
var tags = res.data
|
||||
if (tags && tags.length) {
|
||||
tags.forEach((tag) => {
|
||||
var verObj = parseSemver(tag.name)
|
||||
await axios.get(`https://api.github.com/repos/advplyr/audiobookshelf/releases`).then((res) => {
|
||||
var releases = res.data
|
||||
if (releases && releases.length) {
|
||||
releases.forEach((release) => {
|
||||
var tagName = release.tag_name
|
||||
var verObj = parseSemver(tagName)
|
||||
if (verObj) {
|
||||
if (!largestVer || largestVer.total < verObj.total) {
|
||||
largestVer = verObj
|
||||
@ -50,6 +51,7 @@ export async function checkForUpdate() {
|
||||
console.error('No valid version tags to compare with')
|
||||
return
|
||||
}
|
||||
|
||||
return {
|
||||
hasUpdate: largestVer.total > currVerObj.total,
|
||||
latestVersion: largestVer.version,
|
||||
|
Loading…
Reference in New Issue
Block a user