mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-16 10:58:16 +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() {
|
resize() {
|
||||||
this.$store.commit('globals/updateWindowSize', { width: window.innerWidth, height: window.innerHeight })
|
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() {
|
beforeMount() {
|
||||||
@ -503,17 +522,7 @@ export default {
|
|||||||
this.$store.commit('setExperimentalFeatures', true)
|
this.$store.commit('setExperimentalFeatures', true)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$store
|
this.checkVersionUpdate()
|
||||||
.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)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
window.removeEventListener('resize', this.resize)
|
window.removeEventListener('resize', this.resize)
|
||||||
|
@ -33,11 +33,12 @@ export async function checkForUpdate() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
var largestVer = null
|
var largestVer = null
|
||||||
await axios.get(`https://api.github.com/repos/advplyr/audiobookshelf/tags`).then((res) => {
|
await axios.get(`https://api.github.com/repos/advplyr/audiobookshelf/releases`).then((res) => {
|
||||||
var tags = res.data
|
var releases = res.data
|
||||||
if (tags && tags.length) {
|
if (releases && releases.length) {
|
||||||
tags.forEach((tag) => {
|
releases.forEach((release) => {
|
||||||
var verObj = parseSemver(tag.name)
|
var tagName = release.tag_name
|
||||||
|
var verObj = parseSemver(tagName)
|
||||||
if (verObj) {
|
if (verObj) {
|
||||||
if (!largestVer || largestVer.total < verObj.total) {
|
if (!largestVer || largestVer.total < verObj.total) {
|
||||||
largestVer = verObj
|
largestVer = verObj
|
||||||
@ -50,6 +51,7 @@ export async function checkForUpdate() {
|
|||||||
console.error('No valid version tags to compare with')
|
console.error('No valid version tags to compare with')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hasUpdate: largestVer.total > currVerObj.total,
|
hasUpdate: largestVer.total > currVerObj.total,
|
||||||
latestVersion: largestVer.version,
|
latestVersion: largestVer.version,
|
||||||
|
Loading…
Reference in New Issue
Block a user