4
0
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:
Quentin Legot 2024-08-31 17:13:36 +02:00
parent 39bbff1fdb
commit ede3c6bf62
4 changed files with 4764 additions and 6275 deletions

View File

@ -37,7 +37,7 @@ app = vue.createApp({
position: 'topRight',
resetOnHover: true
})
setInterval(() => {
setTimeout(() => {
ipcRenderer.send('pageReady')
}, 500)
},
@ -98,11 +98,20 @@ app = vue.createApp({
this.displayCredits = 'block'
},
updateModsInformations (content) {
this.modsInformations = content
if(content === null) {
this.modsInformations = []
} else {
this.modsInformations = content
}
},
getModsInformations () {
return this.modsInformations
},
reloadChapters() {
this.updateModsInformations(null)
this.modsInformationsLoaded = true
ipcRenderer.send('pageReady')
},
showInfo (title, body) {
iziToast.info({
title,

View File

@ -71,7 +71,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
</div>
<div id="content">
<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 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) }">

View File

@ -145,39 +145,23 @@ export default class Minecraft {
fs.writeFileSync(file, JSON.stringify(data))
event.sender.send('modsInformations', this.extractModsInformations(data))
}).catch(err => {
event.sender.send('modsInformations', this.extractModsFromFileSystem())
event.sender.send('modsInformations', null)
logger.warn(err)
logger.warn('An error occured while trying to connect to server')
})
} else {
logger.warn('Unable to connect to server')
logger.warn(response.status)
event.sender.send('modsInformations', this.extractModsFromFileSystem())
logger.warn(this.modsInformationsEndpoint)
event.sender.send('modsInformations', null)
}
}).catch(err => {
logger.warn('Unable to connect to server')
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) {
this.modsList = json.chapters
return this.modsList

11000
yarn.lock

File diff suppressed because it is too large Load Diff