From 944363c06995196f68a57997973b11eac93d7d59 Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Fri, 5 Aug 2022 01:12:59 +0200 Subject: feat: handle release notes fetching with no internet When release notes (either Northstar or Viper) fetching fails, if cache contains data, we display it even if it's outdated; if cache is empty, we display an error message in place of release notes. --- src/app/launcher.js | 14 +++++++++----- src/extras/requests.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/app/launcher.js b/src/app/launcher.js index fbeb703..e1dbbe0 100644 --- a/src/app/launcher.js +++ b/src/app/launcher.js @@ -26,13 +26,17 @@ function page(page) { function formatRelease(notes) { let content = ""; - for (let release of notes) { - if (release.prerelease) {continue} - content += "# " + release.name + "\n\n" + release.body + "\n\n\n"; + if (notes.length === 1) { + content = notes[0]; + } else { + for (let release of notes) { + if (release.prerelease) {continue} + content += "# " + release.name + "\n\n" + release.body + "\n\n\n"; + } + + content = content.replaceAll(/\@(\S+)/g, `@$1`); } - content = content.replaceAll(/\@(\S+)/g, `@$1`); - return markdown(content, { breaks: true }); diff --git a/src/extras/requests.js b/src/extras/requests.js index 16b1330..c609da3 100644 --- a/src/extras/requests.js +++ b/src/extras/requests.js @@ -103,6 +103,20 @@ async function getNsReleaseNotes() { _saveCache(cache); resolve( cache[NORTHSTAR_RELEASE_NOTES_KEY]["body"] ); }); + }) + + // When GitHub cannot be reached (when user doesn't have Internet + // access for instance), we return latest cache content even if + // it's not up-to-date, or display an error message if cache + // is empty. + .on('error', () => { + if ( cache[NORTHSTAR_RELEASE_NOTES_KEY] ) { + console.warn("Couldn't fetch Northstar release notes, returning data from cache."); + resolve( cache[NORTHSTAR_RELEASE_NOTES_KEY]["body"] ); + } else { + console.error("Couldn't fetch Northstar release notes, cache is empty."); + resolve( ["Couldn't fetch Northstar release notes.\nTry again later!"] ); + } }); } }); @@ -140,6 +154,20 @@ async function getVpReleaseNotes() { _saveCache(cache); resolve( cache[VIPER_RELEASE_NOTES_KEY]["body"] ); }); + }) + + // When GitHub cannot be reached (when user doesn't have Internet + // access for instance), we return latest cache content even if + // it's not up-to-date, or display an error message if cache + // is empty. + .on('error', () => { + if ( cache[VIPER_RELEASE_NOTES_KEY] ) { + console.warn("Couldn't fetch Viper release notes, returning data from cache."); + resolve( cache[VIPER_RELEASE_NOTES_KEY]["body"] ); + } else { + console.error("Couldn't fetch Viper release notes, cache is empty."); + resolve( ["Couldn't fetch Viper release notes.\nTry again later!"] ); + } }); } }); -- cgit v1.2.3 From c4e77a0f19804c94bc21c6d90dd3c49a37d4d5cb Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Sat, 6 Aug 2022 22:46:41 +0200 Subject: feat: getLatestNsVersion returns false if no Internet --- src/extras/requests.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/extras/requests.js b/src/extras/requests.js index c609da3..6066e90 100644 --- a/src/extras/requests.js +++ b/src/extras/requests.js @@ -58,6 +58,11 @@ async function getLatestNsVersion() { _saveCache(cache); resolve( cache[NORTHSTAR_LATEST_RELEASE_KEY]["body"]["tag_name"] ); }); + }) + + .on('error', () => { + console.error('Failed to get latest Northstar version.'); + resolve( false ); }); } }); -- cgit v1.2.3 From 64fb444ad72bdba342a7345644a5b55d94c7f696 Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Sat, 6 Aug 2022 22:47:27 +0200 Subject: feat: prevent Northstar update and update download link text if no Internet --- src/app/main.js | 1 + src/lang/en.json | 1 + src/lang/fr.json | 1 + src/utils.js | 5 +++++ 4 files changed, 8 insertions(+) diff --git a/src/app/main.js b/src/app/main.js index 9fb3191..4288d1d 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -122,6 +122,7 @@ ipcRenderer.on("ns-update-event", (event, key) => { console.log(lang(key)); switch(key) { case "cli.update.uptodate.short": + case "cli.update.noInternet": setButtons(true); playNsBtn.innerText = lang("gui.launch"); break; diff --git a/src/lang/en.json b/src/lang/en.json index 8cece10..9817a70 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -22,6 +22,7 @@ "cli.update.finished": "Installation/Update finished!", "cli.update.uptodate": "Latest version (%s) is already installed, skipping update.", "cli.update.uptodate.short": "Up-to-date", + "cli.update.noInternet": "No Internet connection", "cli.autoupdates.checking": "Checking for Northstar updates...", "cli.autoupdates.available": "Northstar update available!", diff --git a/src/lang/fr.json b/src/lang/fr.json index 1fde982..9d45e1a 100644 --- a/src/lang/fr.json +++ b/src/lang/fr.json @@ -22,6 +22,7 @@ "cli.update.finished": "Mise à jour terminée !", "cli.update.uptodate": "La dernière version (%s) est déjà installée.", "cli.update.uptodate.short": "Votre client est à jour", + "cli.update.noInternet": "Pas de connexion Internet", "cli.autoupdates.checking": "Vérifications des mises à jour de Northstar...", "cli.autoupdates.available": "Une mise à jour de Northstar est disponible !", diff --git a/src/utils.js b/src/utils.js index e8d14cc..b5978b6 100644 --- a/src/utils.js +++ b/src/utils.js @@ -155,6 +155,7 @@ function handleNorthstarUpdating() { async function _checkForUpdates() { let localVersion = getNSVersion(); let distantVersion = await requests.getLatestNsVersion(); + if (distantVersion == false) return; console.log(lang("cli.autoupdates.checking")); // Checks if NS is outdated @@ -361,6 +362,10 @@ async function update() { const latestAvailableVersion = await requests.getLatestNsVersion(); console.log(latestAvailableVersion) + if (latestAvailableVersion == false) { + ipcMain.emit("ns-update-event", "cli.update.noInternet"); + return; + } // Makes sure it is not already the latest version if (version === latestAvailableVersion) { -- cgit v1.2.3 From 26034ec3475a61682a17c95cb2bffdbc9e52af54 Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Sat, 6 Aug 2022 23:13:24 +0200 Subject: feat: display a toast message if no Internet at launch --- src/app/browser.js | 11 +++++++++++ src/app/main.js | 7 ++++++- src/index.js | 1 + src/lang/en.json | 3 +++ src/lang/fr.json | 3 +++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/app/browser.js b/src/app/browser.js index 4b9f2e3..b1576a9 100644 --- a/src/app/browser.js +++ b/src/app/browser.js @@ -391,6 +391,17 @@ ipcRenderer.on("failed-mod", (event, modname) => { }) }) +ipcRenderer.on("no-internet", (event, modname) => { + console.log('yo') + setButtons(true); + new Toast({ + timeout: 10000, + scheme: "error", + title: lang("gui.toast.noInternet.title"), + description: lang("gui.toast.noInternet.desc") + }) +}) + ipcRenderer.on("installed-mod", (event, mod) => { setButtons(true); Browser.setbutton(mod.name, lang("gui.browser.reinstall")); diff --git a/src/app/main.js b/src/app/main.js index 4288d1d..163c63d 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -1,6 +1,6 @@ const fs = require("fs"); const path = require("path"); -const { ipcRenderer, shell } = require("electron"); +const { ipcRenderer, shell, ipcMain } = require("electron"); const lang = require("../lang"); var modsobj = {}; @@ -62,6 +62,11 @@ if (fs.existsSync("viper.json")) { setpath(); } + +// Show a toast message if no Internet connection has been detected. +if (!navigator.onLine) + ipcRenderer.send("no-internet"); + function exit() {ipcRenderer.send("exit")} function update() {ipcRenderer.send("update")} diff --git a/src/index.js b/src/index.js index 148e30a..e01a635 100644 --- a/src/index.js +++ b/src/index.js @@ -71,6 +71,7 @@ function start() { ipcMain.on("removed-mod", (event, modname) => {send("removed-mod", modname)}); ipcMain.on("gui-getmods", (event, ...args) => {send("mods", utils.mods.list())}); ipcMain.on("installed-mod", (event, modname) => {send("installed-mod", modname)}); + ipcMain.on("no-internet", () => {send("no-internet")}); // install calls ipcMain.on("install-from-path", (event, path) => {utils.mods.install(path)}); diff --git a/src/lang/en.json b/src/lang/en.json index 9817a70..d48b3b6 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -139,6 +139,9 @@ "gui.toast.desc.malformed": "has an incorrect folder structure, if you're the developer, you should fix this.", "gui.toast.desc.failed": "An unknown error occurred while trying to install the mod. This may be the author's fault, and it may also be Viper's fault.", + "gui.toast.noInternet.title": "No Internet", + "gui.toast.noInternet.desc": "Viper may not work properly.", + "viper.menu.main": "Viper", "viper.menu.release": "Release Notes", "viper.menu.info": "Extras", diff --git a/src/lang/fr.json b/src/lang/fr.json index 9d45e1a..cd4e4dc 100644 --- a/src/lang/fr.json +++ b/src/lang/fr.json @@ -139,6 +139,9 @@ "gui.toast.desc.malformed": "a une structure de dossier incorrecte ; si vous êtes son développeur, vous devriez réparer ça.", "gui.toast.desc.failed": "Une erreur inconnue est survenue lors de l'installation du mod. Cela peut être du ressort de l'auteur du mod ou de Viper.", + "gui.toast.noInternet.title": "Pas de connexion Internet", + "gui.toast.noInternet.desc": "Viper ne fonctionnera pas correctement tant que la connexion n'est pas rétablie.", + "viper.menu.main": "Viper", "viper.menu.release": "Notes de mises à jour", "viper.menu.info": "Informations", -- cgit v1.2.3 From 77f7e6fe85c243371c676ec4d4f60de8920d938d Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Sat, 6 Aug 2022 23:26:46 +0200 Subject: feat: translate "impossible to fetch release notes" messages --- src/extras/requests.js | 5 +++-- src/lang/en.json | 5 ++++- src/lang/fr.json | 5 ++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/extras/requests.js b/src/extras/requests.js index 6066e90..7509e9e 100644 --- a/src/extras/requests.js +++ b/src/extras/requests.js @@ -2,6 +2,7 @@ const { app } = require("electron"); const path = require("path"); const fs = require("fs"); const { https } = require("follow-redirects"); +const lang = require("../lang"); // all requests results are stored in this file @@ -120,7 +121,7 @@ async function getNsReleaseNotes() { resolve( cache[NORTHSTAR_RELEASE_NOTES_KEY]["body"] ); } else { console.error("Couldn't fetch Northstar release notes, cache is empty."); - resolve( ["Couldn't fetch Northstar release notes.\nTry again later!"] ); + resolve( [lang("request.northstar.noReleaseNotes")] ); } }); } @@ -171,7 +172,7 @@ async function getVpReleaseNotes() { resolve( cache[VIPER_RELEASE_NOTES_KEY]["body"] ); } else { console.error("Couldn't fetch Viper release notes, cache is empty."); - resolve( ["Couldn't fetch Viper release notes.\nTry again later!"] ); + resolve( [lang("request.viper.noReleaseNotes")] ); } }); } diff --git a/src/lang/en.json b/src/lang/en.json index d48b3b6..51093fa 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -161,5 +161,8 @@ "general.missingpath": "Game location could not be found automatically! Please select it manually!", "general.notinstalled": "Northstar is not installed!", "general.launching": "Launching", - "general.invalidconfig": "Your config file is improperly formatted, if it's been manually edited, please validate that everything is typed correctly.\n\nIf you did not manually edit the config file, it is recommended to simply reset the config.\n\nTo reset your config file simply click \"Ok\" below.\n\nMore details:\n" + "general.invalidconfig": "Your config file is improperly formatted, if it's been manually edited, please validate that everything is typed correctly.\n\nIf you did not manually edit the config file, it is recommended to simply reset the config.\n\nTo reset your config file simply click \"Ok\" below.\n\nMore details:\n", + + "request.viper.noReleaseNotes": "Couldn't fetch Viper release notes.\nTry again later!", + "request.northstar.noReleaseNotes": "Couldn't fetch Northstar release notes.\nTry again later!" } diff --git a/src/lang/fr.json b/src/lang/fr.json index cd4e4dc..4f819b4 100644 --- a/src/lang/fr.json +++ b/src/lang/fr.json @@ -161,5 +161,8 @@ "general.missingpath": "Le chemin du client n'a pu être trouvé automatiquement, merci de le sélectionner manuellement.", "general.notinstalled": "Northstar n'est pas installé !", "general.launching": "Lancement", - "general.invalidconfig": "Votre fichier de configuration n'est pas formaté correctement ; si vous l'avez manuellement édité, veuillez vérifier son contenu.\n\nSinon, il est recommandé de remettre la configuration à zéro.\n\nPour cela, cliquez sur le bouton \"Ok\" en-dessous de ce message.\n\nPlus d'informations :\n" + "general.invalidconfig": "Votre fichier de configuration n'est pas formaté correctement ; si vous l'avez manuellement édité, veuillez vérifier son contenu.\n\nSinon, il est recommandé de remettre la configuration à zéro.\n\nPour cela, cliquez sur le bouton \"Ok\" en-dessous de ce message.\n\nPlus d'informations :\n", + + "request.viper.noReleaseNotes": "Impossible de récupérer les notes de mises à jour de Viper.\nVeuillez réessayer plus tard.", + "request.northstar.noReleaseNotes": "Impossible de récupérer les notes de mises à jour de Northstar.\nVeuillez réessayer plus tard." } -- cgit v1.2.3 From 3a8875a24cf66ff4fd6b39cfb9ce2314191f34f4 Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Sun, 7 Aug 2022 11:22:21 +0200 Subject: feat: add German translation Co-authored-by: GeckoEidechse --- src/lang/de.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lang/de.json b/src/lang/de.json index 2657d67..f8f2d63 100644 --- a/src/lang/de.json +++ b/src/lang/de.json @@ -22,6 +22,7 @@ "cli.update.finished": "Installation/Aktualisierung abeschlossen!", "cli.update.uptodate": "Installation ist bereits auf dem neusten Stand (%s), aktualisieren wird übersprungen.", "cli.update.uptodate.short": "Auf dem neusten stand", + "cli.update.noInternet": "Keine Internetverbindung", "cli.autoupdates.checking": "Überprüfe Northstar auf Updates...", "cli.autoupdates.available": "Ein Update für Northstar wurde gefunden!", @@ -137,6 +138,9 @@ "gui.toast.desc.malformed": "hat eine fehlerhafte Ordnerstruktur, falls du der Entwickler bist, solltest du dies beheben.", "gui.toast.desc.failed": "Ein unbekannter Fehler ist aufgetaucht beim Installieren, die Schuld kann beim Autor liegen oder bei Viper selbst!", + "gui.toast.noInternet.title": "Kein Internet", + "gui.toast.noInternet.desc": "Viper funktioniert möglicherweise nicht korrekt", + "viper.menu.main": "Viper", "viper.menu.release": "Release Notes", "viper.menu.info": "Extras", @@ -156,5 +160,8 @@ "general.missingpath": "Installationspfad konnte nicht automatisch gefunden werden, bitte setze diesen manuell!", "general.notinstalled": "Northstar ist nicht installiert!", "general.launching": "Starte!", - "general.invalidconfig": "Deine Konfigurationsdatei ist nicht richtig formatiert, falls diese manuell verändert wurde bitte stelle sicher das alles korrekt ist.\n\nFalls du diese nicht manuell verändert hast, ist es empfohlen diese zurückzusetzen!\n\nUm sie zurückzusetzen drücke einfach auf \"Ok\".\n\nWeitere Informationen:\n" + "general.invalidconfig": "Deine Konfigurationsdatei ist nicht richtig formatiert, falls diese manuell verändert wurde bitte stelle sicher das alles korrekt ist.\n\nFalls du diese nicht manuell verändert hast, ist es empfohlen diese zurückzusetzen!\n\nUm sie zurückzusetzen drücke einfach auf \"Ok\".\n\nWeitere Informationen:\n", + + "request.viper.noReleaseNotes": "Viper Release Notes konnten nicht geladen werden.\nVersuche es erneut später!", + "request.northstar.noReleaseNotes": "Northstar Release Notes konnten nicht geladen werden.\nVersuche es erneut später!" } -- cgit v1.2.3 From d124f8165f2fa690269c28770b35103eb2791a70 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Sun, 7 Aug 2022 18:34:19 +0200 Subject: added: contributor list "embed" --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index d8790dd..40dc221 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,10 @@ Keep in mind building all Linux builds may take a while on some systems as packa ## Credits + + + + **Logo:** Imply#9781
**Viper Background:** [Uber Panzerhund](https://www.reddit.com/r/titanfall/comments/fwuh2x/take_to_the_skies)
**Titanfall+Northstar Logo:** [Aftonstjarma](https://www.steamgriddb.com/logo/47851) -- cgit v1.2.3 From f36176a3649a082c99afef552a87559632536e16 Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Sun, 7 Aug 2022 21:40:27 +0200 Subject: fix: lint --- src/app/browser.js | 1 - src/app/main.js | 3 ++- src/utils.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/browser.js b/src/app/browser.js index b1576a9..db68d31 100644 --- a/src/app/browser.js +++ b/src/app/browser.js @@ -392,7 +392,6 @@ ipcRenderer.on("failed-mod", (event, modname) => { }) ipcRenderer.on("no-internet", (event, modname) => { - console.log('yo') setButtons(true); new Toast({ timeout: 10000, diff --git a/src/app/main.js b/src/app/main.js index 163c63d..d6a57d6 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -64,8 +64,9 @@ if (fs.existsSync("viper.json")) { // Show a toast message if no Internet connection has been detected. -if (!navigator.onLine) +if (!navigator.onLine) { ipcRenderer.send("no-internet"); +} function exit() {ipcRenderer.send("exit")} function update() {ipcRenderer.send("update")} diff --git a/src/utils.js b/src/utils.js index b5978b6..31a2b28 100644 --- a/src/utils.js +++ b/src/utils.js @@ -155,7 +155,7 @@ function handleNorthstarUpdating() { async function _checkForUpdates() { let localVersion = getNSVersion(); let distantVersion = await requests.getLatestNsVersion(); - if (distantVersion == false) return; + if (distantVersion == false) { return; } console.log(lang("cli.autoupdates.checking")); // Checks if NS is outdated -- cgit v1.2.3 From 7d84141d4cf91b02d5219a3e0f34b55e9d9f6247 Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Mon, 8 Aug 2022 22:49:02 +0200 Subject: feat: add Spanish translation Co-authored-by: Delta <31860825+AA-Delta@users.noreply.github.com> --- src/lang/es.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lang/es.json b/src/lang/es.json index c341143..2625ffb 100644 --- a/src/lang/es.json +++ b/src/lang/es.json @@ -24,6 +24,7 @@ "cli.update.finished": "Instalación/Actualización completada!", "cli.update.uptodate": "La ultima versión (%s) ya está instalada, omitiendo actualización.", "cli.update.uptodate.short": "Está actualizado", + "cli.update.noInternet": "Sin conexión a internet", "cli.autoupdates.checking": "Buscando actualizaciones de Northstar...", "cli.autoupdates.available": "¡Actualización de Northsar disponible!", @@ -137,6 +138,9 @@ "gui.server.players": "jugadores", "gui.server.servers": "servidores", "gui.server.offline": "El servidor Master está desconectado", + + "gui.toast.noInternet.title": "Sin Internet", + "gui.toast.noInternet.desc": "Viper puede funcionar de forma incorrecta.", "viper.menu.main": "Viper", "viper.menu.release": "Notas de la versión", @@ -157,5 +161,8 @@ "general.missingpath": "¡La ruta del jueno no se ha podido encontrar automaticamente! ¡Por favor, elige la ruta manualmente!", "general.notinstalled": "¡Northstar no se ha instalado!", "general.launching": "Ejecutando", - "general.invalidconfig": "Su archivo de configuración está formateado de forma incorrecta, si ha sido editado manualmente, por favor valide que ha sido escrito correctamente. \n\nSi no ha editado manualmente el archivo de configuración, es recomendado que simplemente restaure la configuración. \n\nPara restaurar tu configuración simplemente de click en \"OK\" a continuación. \n\nMas detalles:\n" + "general.invalidconfig": "Su archivo de configuración está formateado de forma incorrecta, si ha sido editado manualmente, por favor valide que ha sido escrito correctamente. \n\nSi no ha editado manualmente el archivo de configuración, es recomendado que simplemente restaure la configuración. \n\nPara restaurar tu configuración simplemente de click en \"OK\" a continuación. \n\nMas detalles:\n", + + "request.viper.noReleaseNotes": "No se pudo encontrar las notas de lanzamiento de Viper.\n¡Intenta mas tarde!", + "request.northstar.noReleaseNotes": "No se pudo encontrar las notas de lanzamiento de Northstar.\n¡Intenta mas tarde!" } -- cgit v1.2.3