mirror of
https://github.com/AltarikMC/Launcher
synced 2024-11-21 06:09:51 +01:00
feat: add reloading button on chapter selection panel, refactor: remove loading chapters file from filesystem, fix: Luanhcer was periodically fetching for the chapter declaration online, do it one time at loading now
This commit is contained in:
parent
39bbff1fdb
commit
ede3c6bf62
@ -37,7 +37,7 @@ app = vue.createApp({
|
|||||||
position: 'topRight',
|
position: 'topRight',
|
||||||
resetOnHover: true
|
resetOnHover: true
|
||||||
})
|
})
|
||||||
setInterval(() => {
|
setTimeout(() => {
|
||||||
ipcRenderer.send('pageReady')
|
ipcRenderer.send('pageReady')
|
||||||
}, 500)
|
}, 500)
|
||||||
},
|
},
|
||||||
@ -98,11 +98,20 @@ app = vue.createApp({
|
|||||||
this.displayCredits = 'block'
|
this.displayCredits = 'block'
|
||||||
},
|
},
|
||||||
updateModsInformations (content) {
|
updateModsInformations (content) {
|
||||||
|
if(content === null) {
|
||||||
|
this.modsInformations = []
|
||||||
|
} else {
|
||||||
this.modsInformations = content
|
this.modsInformations = content
|
||||||
|
}
|
||||||
},
|
},
|
||||||
getModsInformations () {
|
getModsInformations () {
|
||||||
return this.modsInformations
|
return this.modsInformations
|
||||||
},
|
},
|
||||||
|
reloadChapters() {
|
||||||
|
this.updateModsInformations(null)
|
||||||
|
this.modsInformationsLoaded = true
|
||||||
|
ipcRenderer.send('pageReady')
|
||||||
|
},
|
||||||
showInfo (title, body) {
|
showInfo (title, body) {
|
||||||
iziToast.info({
|
iziToast.info({
|
||||||
title,
|
title,
|
||||||
|
@ -71,7 +71,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
|
|||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<div id="sidebar">
|
<div id="sidebar">
|
||||||
<h2>Chapitres</h2>
|
<h2>Chapitres <i v-if="modsInformations.length !== 0 || modsInformationsLoaded === false" v-on:click="reloadChapters()" class="reload-chapter material-icons">sync</i></h2>
|
||||||
<div id="sidebar-content" @change="modsInformations">
|
<div id="sidebar-content" @change="modsInformations">
|
||||||
<div v-if="modsInformationsLoaded === false">Une erreur est survenue lors de la récupération des informations, vérifiez votre connexion internet puis cliquez sur réessayez</div>
|
<div v-if="modsInformationsLoaded === false">Une erreur est survenue lors de la récupération des informations, vérifiez votre connexion internet puis cliquez sur réessayez</div>
|
||||||
<div v-for="(item, index) in modsInformations" v-else-if="modsInformations.length !== 0" v-on:click="changeSelectedChapter(index)" :class="{ selected: isSelected(index) }">
|
<div v-for="(item, index) in modsInformations" v-else-if="modsInformations.length !== 0" v-on:click="changeSelectedChapter(index)" :class="{ selected: isSelected(index) }">
|
||||||
|
@ -145,39 +145,23 @@ export default class Minecraft {
|
|||||||
fs.writeFileSync(file, JSON.stringify(data))
|
fs.writeFileSync(file, JSON.stringify(data))
|
||||||
event.sender.send('modsInformations', this.extractModsInformations(data))
|
event.sender.send('modsInformations', this.extractModsInformations(data))
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
event.sender.send('modsInformations', this.extractModsFromFileSystem())
|
event.sender.send('modsInformations', null)
|
||||||
logger.warn(err)
|
logger.warn(err)
|
||||||
logger.warn('An error occured while trying to connect to server')
|
logger.warn('An error occured while trying to connect to server')
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
logger.warn('Unable to connect to server')
|
logger.warn('Unable to connect to server')
|
||||||
logger.warn(response.status)
|
logger.warn(response.status)
|
||||||
event.sender.send('modsInformations', this.extractModsFromFileSystem())
|
logger.warn(this.modsInformationsEndpoint)
|
||||||
|
event.sender.send('modsInformations', null)
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
logger.warn('Unable to connect to server')
|
logger.warn('Unable to connect to server')
|
||||||
logger.warn(err)
|
logger.warn(err)
|
||||||
event.sender.send('modsInformations', this.extractModsFromFileSystem())
|
event.sender.send('modsInformations', null)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
extractModsFromFileSystem () {
|
|
||||||
const filepath = join(this.localappdata, 'altarik-launcher/data/launcher.json')
|
|
||||||
if (fs.existsSync(filepath)) {
|
|
||||||
const content = fs.readFileSync(filepath)
|
|
||||||
if (content !== null) {
|
|
||||||
this.showNotification('Impossible de récupérer certaines informations en ligne', 'utilisation des dernières données récupérées', 'warning')
|
|
||||||
return this.extractModsInformations(JSON.parse(content))
|
|
||||||
} else {
|
|
||||||
this.showNotification('Impossible de récupérer certaines informations en ligne', 'Veuillez réessayez en cliquant sur le bouton', 'warning')
|
|
||||||
logger.error('Unable to get chapters informations from server or filesystem')
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extractModsInformations (json) {
|
extractModsInformations (json) {
|
||||||
this.modsList = json.chapters
|
this.modsList = json.chapters
|
||||||
return this.modsList
|
return this.modsList
|
||||||
|
Loading…
Reference in New Issue
Block a user