From 0ed4245f4109384598035ec759185461003110e6 Mon Sep 17 00:00:00 2001 From: Ariel Juodziukynas Date: Fri, 16 Sep 2022 23:41:00 -0300 Subject: [PATCH 1/4] Move to use beta instead of main --- public/locales/az/translation.json | 6 + public/locales/be/translation.json | 6 + public/locales/bg/translation.json | 6 + public/locales/bs/translation.json | 6 + public/locales/ca/translation.json | 6 + public/locales/cs/translation.json | 6 + public/locales/de/translation.json | 6 + public/locales/el/translation.json | 6 + public/locales/en/translation.json | 6 + public/locales/es/translation.json | 6 + public/locales/et/translation.json | 6 + public/locales/eu/translation.json | 6 + public/locales/fa/translation.json | 6 + public/locales/fi/translation.json | 6 + public/locales/fr/translation.json | 6 + public/locales/gl/translation.json | 6 + public/locales/hr/translation.json | 6 + public/locales/hu/translation.json | 6 + public/locales/id/translation.json | 6 + public/locales/it/translation.json | 6 + public/locales/ja/translation.json | 6 + public/locales/ko/translation.json | 6 + public/locales/ml/translation.json | 6 + public/locales/nb_NO/translation.json | 6 + public/locales/nl/translation.json | 6 + public/locales/pl/translation.json | 6 + public/locales/pt/translation.json | 6 + public/locales/pt_BR/translation.json | 6 + public/locales/ro/translation.json | 6 + public/locales/ru/translation.json | 6 + public/locales/sk/translation.json | 6 + public/locales/sv/translation.json | 6 + public/locales/ta/translation.json | 6 + public/locales/tr/translation.json | 6 + public/locales/uk/translation.json | 6 + public/locales/vi/translation.json | 6 + public/locales/zh_Hans/translation.json | 6 + public/locales/zh_Hant/translation.json | 6 + src/backend/anticheat/utils.ts | 27 ++-- src/backend/gog/library.ts | 3 +- src/backend/gog/setup.ts | 3 +- src/backend/gog/user.ts | 3 +- src/backend/launcher.ts | 2 +- src/backend/legendary/games.ts | 3 +- src/backend/legendary/library.ts | 2 +- src/backend/logger/logger.ts | 3 +- src/backend/main.ts | 33 +++-- src/backend/online_monitor.ts | 129 ++++++++++++++++++ src/backend/tools.ts | 8 +- src/backend/utils.ts | 34 +---- src/common/types.ts | 2 + src/frontend/App.css | 13 +- src/frontend/App.tsx | 3 +- .../components/UI/OfflineMessage/index.css | 36 +++++ .../components/UI/OfflineMessage/index.tsx | 53 +++++++ src/frontend/components/UI/index.tsx | 1 + src/frontend/helpers/onlineMonitor.ts | 11 ++ src/frontend/index.tsx | 3 + src/frontend/state/ContextProvider.tsx | 3 +- src/frontend/state/GlobalState.tsx | 15 +- src/frontend/types.ts | 3 +- 61 files changed, 546 insertions(+), 75 deletions(-) create mode 100644 src/backend/online_monitor.ts create mode 100644 src/frontend/components/UI/OfflineMessage/index.css create mode 100644 src/frontend/components/UI/OfflineMessage/index.tsx create mode 100644 src/frontend/helpers/onlineMonitor.ts diff --git a/public/locales/az/translation.json b/public/locales/az/translation.json index dc2a26a004..31d66654df 100644 --- a/public/locales/az/translation.json +++ b/public/locales/az/translation.json @@ -324,6 +324,12 @@ "started": "Yeniləmə Başladı" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Dəyişən adı", diff --git a/public/locales/be/translation.json b/public/locales/be/translation.json index 6bc0b47f61..da2ce5944c 100644 --- a/public/locales/be/translation.json +++ b/public/locales/be/translation.json @@ -324,6 +324,12 @@ "started": "Update Started" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/bg/translation.json b/public/locales/bg/translation.json index c540f4a365..661fed0c88 100644 --- a/public/locales/bg/translation.json +++ b/public/locales/bg/translation.json @@ -324,6 +324,12 @@ "started": "Обновяването е започнато" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/bs/translation.json b/public/locales/bs/translation.json index 53cd08ed04..422410cf24 100644 --- a/public/locales/bs/translation.json +++ b/public/locales/bs/translation.json @@ -324,6 +324,12 @@ "started": "Ažuriranje započeto" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Ime varijable", diff --git a/public/locales/ca/translation.json b/public/locales/ca/translation.json index d0b99b5629..7dbe871f8e 100644 --- a/public/locales/ca/translation.json +++ b/public/locales/ca/translation.json @@ -324,6 +324,12 @@ "started": "S'ha iniciat l'actualització" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/cs/translation.json b/public/locales/cs/translation.json index f8f7f71f70..87fee15aa5 100644 --- a/public/locales/cs/translation.json +++ b/public/locales/cs/translation.json @@ -324,6 +324,12 @@ "started": "Aktualizace zahájena" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index 6a3973e2e3..df5919f618 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -324,6 +324,12 @@ "started": "Update gestartet" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/el/translation.json b/public/locales/el/translation.json index 7f6e01697d..960554affd 100644 --- a/public/locales/el/translation.json +++ b/public/locales/el/translation.json @@ -324,6 +324,12 @@ "started": "Έναρξη Ενημέρωσης" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 64b50dd811..eaf58a007c 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -324,6 +324,12 @@ "started": "Update Started" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/es/translation.json b/public/locales/es/translation.json index dd239c5333..c84fbd759c 100644 --- a/public/locales/es/translation.json +++ b/public/locales/es/translation.json @@ -324,6 +324,12 @@ "started": "Actualización iniciada" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Nombre de la variable", diff --git a/public/locales/et/translation.json b/public/locales/et/translation.json index fda7ea8133..74c09ead48 100644 --- a/public/locales/et/translation.json +++ b/public/locales/et/translation.json @@ -324,6 +324,12 @@ "started": "Uuendamine algas" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/eu/translation.json b/public/locales/eu/translation.json index 71d5a5e2a6..c282d400d7 100644 --- a/public/locales/eu/translation.json +++ b/public/locales/eu/translation.json @@ -324,6 +324,12 @@ "started": "Eguneratzea hasi da" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Aldagaiaren izena", diff --git a/public/locales/fa/translation.json b/public/locales/fa/translation.json index 60157a8a67..75a75006bf 100644 --- a/public/locales/fa/translation.json +++ b/public/locales/fa/translation.json @@ -324,6 +324,12 @@ "started": "بهروزرسانی آغاز شد" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/fi/translation.json b/public/locales/fi/translation.json index 5a3f2daba9..94a9b85cce 100644 --- a/public/locales/fi/translation.json +++ b/public/locales/fi/translation.json @@ -324,6 +324,12 @@ "started": "Päivitys aloitettu" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/fr/translation.json b/public/locales/fr/translation.json index 7c9f4645fd..b2f80be97b 100644 --- a/public/locales/fr/translation.json +++ b/public/locales/fr/translation.json @@ -324,6 +324,12 @@ "started": "Mise à jour commencée" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/gl/translation.json b/public/locales/gl/translation.json index b33fbad589..f686c151f5 100644 --- a/public/locales/gl/translation.json +++ b/public/locales/gl/translation.json @@ -324,6 +324,12 @@ "started": "Actualización iniciada" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/hr/translation.json b/public/locales/hr/translation.json index ee38d46969..98f7997570 100644 --- a/public/locales/hr/translation.json +++ b/public/locales/hr/translation.json @@ -324,6 +324,12 @@ "started": "Update Started" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/hu/translation.json b/public/locales/hu/translation.json index 3219aefe84..713548c66e 100644 --- a/public/locales/hu/translation.json +++ b/public/locales/hu/translation.json @@ -324,6 +324,12 @@ "started": "Frissítés elindult" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/id/translation.json b/public/locales/id/translation.json index 2711a6f756..f00153a120 100644 --- a/public/locales/id/translation.json +++ b/public/locales/id/translation.json @@ -324,6 +324,12 @@ "started": "Pembaruan Dimulai" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Nama Variabel", diff --git a/public/locales/it/translation.json b/public/locales/it/translation.json index c944369a75..c42a29785b 100644 --- a/public/locales/it/translation.json +++ b/public/locales/it/translation.json @@ -324,6 +324,12 @@ "started": "Aggiornamento avviato" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/ja/translation.json b/public/locales/ja/translation.json index f9e7da9e56..491b1c9e6f 100644 --- a/public/locales/ja/translation.json +++ b/public/locales/ja/translation.json @@ -324,6 +324,12 @@ "started": "Update Started" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/ko/translation.json b/public/locales/ko/translation.json index 0e813d803a..561e00da93 100644 --- a/public/locales/ko/translation.json +++ b/public/locales/ko/translation.json @@ -324,6 +324,12 @@ "started": "업데이트 시작됨" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/ml/translation.json b/public/locales/ml/translation.json index c4eeab452b..8733e9597d 100644 --- a/public/locales/ml/translation.json +++ b/public/locales/ml/translation.json @@ -324,6 +324,12 @@ "started": "Update Started" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/nb_NO/translation.json b/public/locales/nb_NO/translation.json index 280d52ae3e..4abda0fe07 100644 --- a/public/locales/nb_NO/translation.json +++ b/public/locales/nb_NO/translation.json @@ -324,6 +324,12 @@ "started": "Oppgradering startet" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variabelnavn", diff --git a/public/locales/nl/translation.json b/public/locales/nl/translation.json index b756dbef6d..f7c637e268 100644 --- a/public/locales/nl/translation.json +++ b/public/locales/nl/translation.json @@ -324,6 +324,12 @@ "started": "Update Started" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/pl/translation.json b/public/locales/pl/translation.json index 904f4e9d4f..db34581991 100644 --- a/public/locales/pl/translation.json +++ b/public/locales/pl/translation.json @@ -324,6 +324,12 @@ "started": "Aktualizacja rozpoczęta" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/pt/translation.json b/public/locales/pt/translation.json index 09cf7eabd4..668489420a 100644 --- a/public/locales/pt/translation.json +++ b/public/locales/pt/translation.json @@ -324,6 +324,12 @@ "started": "Update Started" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/pt_BR/translation.json b/public/locales/pt_BR/translation.json index 0fdc5733f2..38b0288e72 100644 --- a/public/locales/pt_BR/translation.json +++ b/public/locales/pt_BR/translation.json @@ -324,6 +324,12 @@ "started": "Atualização iniciada" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/ro/translation.json b/public/locales/ro/translation.json index 25910cd2cd..db372eed35 100644 --- a/public/locales/ro/translation.json +++ b/public/locales/ro/translation.json @@ -324,6 +324,12 @@ "started": "Actualizarea a început" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Nume variabilă", diff --git a/public/locales/ru/translation.json b/public/locales/ru/translation.json index 53f3897258..31708f3a46 100644 --- a/public/locales/ru/translation.json +++ b/public/locales/ru/translation.json @@ -324,6 +324,12 @@ "started": "Обновление началось" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Имя переменной", diff --git a/public/locales/sk/translation.json b/public/locales/sk/translation.json index 6bc0b47f61..da2ce5944c 100644 --- a/public/locales/sk/translation.json +++ b/public/locales/sk/translation.json @@ -324,6 +324,12 @@ "started": "Update Started" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/sv/translation.json b/public/locales/sv/translation.json index a208d06c9e..d60499aa39 100644 --- a/public/locales/sv/translation.json +++ b/public/locales/sv/translation.json @@ -324,6 +324,12 @@ "started": "Uppdatering påbörjad" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/ta/translation.json b/public/locales/ta/translation.json index 1aec03c384..4d63a73efd 100644 --- a/public/locales/ta/translation.json +++ b/public/locales/ta/translation.json @@ -324,6 +324,12 @@ "started": "Update Started" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/tr/translation.json b/public/locales/tr/translation.json index 974cb8f043..481ce7779d 100644 --- a/public/locales/tr/translation.json +++ b/public/locales/tr/translation.json @@ -324,6 +324,12 @@ "started": "Güncelleme Başladı" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/uk/translation.json b/public/locales/uk/translation.json index ea6e8d2ba2..5057e12ec1 100644 --- a/public/locales/uk/translation.json +++ b/public/locales/uk/translation.json @@ -324,6 +324,12 @@ "started": "Розпочалось оновлення" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Ім'я змінного", diff --git a/public/locales/vi/translation.json b/public/locales/vi/translation.json index f4b260a0e9..4b7cda5926 100644 --- a/public/locales/vi/translation.json +++ b/public/locales/vi/translation.json @@ -324,6 +324,12 @@ "started": "Quá trình cập nhật đã bắt đầu" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/public/locales/zh_Hans/translation.json b/public/locales/zh_Hans/translation.json index 0d9dcef058..8e978bb692 100644 --- a/public/locales/zh_Hans/translation.json +++ b/public/locales/zh_Hans/translation.json @@ -324,6 +324,12 @@ "started": "更新已开始" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "变量名称", diff --git a/public/locales/zh_Hant/translation.json b/public/locales/zh_Hant/translation.json index b218b5e346..89135412d4 100644 --- a/public/locales/zh_Hant/translation.json +++ b/public/locales/zh_Hant/translation.json @@ -324,6 +324,12 @@ "started": "更新開始" } }, + "offline-message": { + "hint": "We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com", + "offline": "Offline", + "retry-in": "Retrying in ... {{seconds}} seconds", + "retrying": "Retrying" + }, "options": { "advanced": { "key": "Variable Name", diff --git a/src/backend/anticheat/utils.ts b/src/backend/anticheat/utils.ts index b31809bb60..b73acacb9d 100644 --- a/src/backend/anticheat/utils.ts +++ b/src/backend/anticheat/utils.ts @@ -3,21 +3,26 @@ import * as axios from 'axios' import { logInfo, LogPrefix, logWarning } from '../logger/logger' import { readFileSync, writeFileSync } from 'graceful-fs' import { AntiCheatInfo } from 'common/types' +import { runOnceWhenOnline } from '../online_monitor' async function downloadAntiCheatData() { if (!isLinux) return - try { - const { data } = await axios.default.get( - 'https://raw.githubusercontent.com/Starz0r/AreWeAntiCheatYet/HEAD/games.json' - ) - writeFileSync(heroicAnticheatDataPath, JSON.stringify(data, null, 2)) - logInfo(`AreWeAntiCheatYet data downloaded`, { prefix: LogPrefix.Backend }) - } catch (error) { - logWarning(['Failed download of AreWeAntiCheatYet data:', error], { - prefix: LogPrefix.Backend - }) - } + runOnceWhenOnline(async () => { + try { + const { data } = await axios.default.get( + 'https://raw.githubusercontent.com/Starz0r/AreWeAntiCheatYet/HEAD/games.json' + ) + writeFileSync(heroicAnticheatDataPath, JSON.stringify(data, null, 2)) + logInfo(`AreWeAntiCheatYet data downloaded`, { + prefix: LogPrefix.Backend + }) + } catch (error) { + logWarning(`Failed download of AreWeAntiCheatYet data: ${error}`, { + prefix: LogPrefix.Backend + }) + } + }) } function gameAnticheatInfo(appNamespace: string): AntiCheatInfo | null { diff --git a/src/backend/gog/library.ts b/src/backend/gog/library.ts index 77c72583e2..6b46e23890 100644 --- a/src/backend/gog/library.ts +++ b/src/backend/gog/library.ts @@ -13,7 +13,7 @@ import { join } from 'node:path' import { existsSync, readFileSync } from 'graceful-fs' import { logError, logInfo, LogPrefix, logWarning } from '../logger/logger' -import { getGOGdlBin, getFileSize, isOnline } from '../utils' +import { getGOGdlBin, getFileSize } from '../utils' import { fallBackImage } from '../constants' import { apiInfoCache, @@ -21,6 +21,7 @@ import { installedGamesStore } from './electronStores' import { callRunner } from '../launcher' +import { isOnline } from '../online_monitor' export class GOGLibrary { private static globalInstance: GOGLibrary diff --git a/src/backend/gog/setup.ts b/src/backend/gog/setup.ts index ec2cf401d6..5aebff43d7 100644 --- a/src/backend/gog/setup.ts +++ b/src/backend/gog/setup.ts @@ -10,12 +10,13 @@ import { copySync } from 'fs-extra' import path from 'node:path' import { GOGLibrary } from './library' import { GameInfo, InstalledInfo } from 'common/types' -import { execAsync, isOnline, quoteIfNecessary } from '../utils' +import { execAsync, quoteIfNecessary } from '../utils' import { GameConfig } from '../game_config' import { logError, logInfo, LogPrefix, logWarning } from '../logger/logger' import { userHome, isWindows } from '../constants' import ini from 'ini' import { GlobalConfig } from '../config' +import { isOnline } from '../online_monitor' /** * Handles setup instructions like create folders, move files, run exe, create registry entry etc... * For Galaxy games only (Windows) diff --git a/src/backend/gog/user.ts b/src/backend/gog/user.ts index 0c203389eb..a1e10fedaf 100644 --- a/src/backend/gog/user.ts +++ b/src/backend/gog/user.ts @@ -2,7 +2,8 @@ import axios from 'axios' import { logError, logInfo, LogPrefix, logWarning } from '../logger/logger' import { GOGLoginData } from 'common/types' import { configStore, libraryStore } from '../gog/electronStores' -import { errorHandler, isOnline } from '../utils' +import { errorHandler } from '../utils' +import { isOnline } from '../online_monitor' const gogAuthenticateUrl = 'https://auth.gog.com/token?client_id=46899977096215655&client_secret=9d85c43b1482497dbbce61f6e4aa173a433796eeae2ca8c5f6129f2dc4de46d9&grant_type=authorization_code&redirect_uri=https%3A%2F%2Fembed.gog.com%2Fon_login_success%3Forigin%3Dclient&code=' diff --git a/src/backend/launcher.ts b/src/backend/launcher.ts index 3921ff794f..49feeaeb32 100644 --- a/src/backend/launcher.ts +++ b/src/backend/launcher.ts @@ -15,7 +15,6 @@ import { execAsync, getSteamRuntime, isEpicServiceOffline, - isOnline, showErrorBoxModalAuto, searchForExecutableOnPath, quoteIfNecessary, @@ -49,6 +48,7 @@ import { import { spawn } from 'child_process' import shlex from 'shlex' import { Game } from './games' +import { isOnline } from './online_monitor' async function prepareLaunch( game: LegendaryGame | GOGGame, diff --git a/src/backend/legendary/games.ts b/src/backend/legendary/games.ts index dee610764f..c32bbd31ad 100644 --- a/src/backend/legendary/games.ts +++ b/src/backend/legendary/games.ts @@ -14,7 +14,7 @@ import { GameConfig } from '../game_config' import { GlobalConfig } from '../config' import { LegendaryLibrary, runLegendaryCommand } from './library' import { LegendaryUser } from './user' -import { execAsync, getLegendaryBin, isOnline, killPattern } from '../utils' +import { execAsync, getLegendaryBin, killPattern } from '../utils' import { heroicGamesConfigPath, userHome, @@ -39,6 +39,7 @@ import { gameInfoStore } from './electronStores' import { removeNonSteamGame } from '../shortcuts/nonesteamgame/nonesteamgame' import shlex from 'shlex' import { t } from 'i18next' +import { isOnline } from '../online_monitor' class LegendaryGame extends Game { public appName: string diff --git a/src/backend/legendary/library.ts b/src/backend/legendary/library.ts index 8418dcfb4b..d756285d6f 100644 --- a/src/backend/legendary/library.ts +++ b/src/backend/legendary/library.ts @@ -18,7 +18,6 @@ import { formatEpicStoreUrl, getLegendaryBin, isEpicServiceOffline, - isOnline, getFileSize } from '../utils' import { @@ -36,6 +35,7 @@ import { import { installStore, libraryStore } from './electronStores' import { callRunner } from '../launcher' import { join } from 'path' +import { isOnline } from '../online_monitor' /** * Legendary LegendaryLibrary. diff --git a/src/backend/logger/logger.ts b/src/backend/logger/logger.ts index df0dbdd9c4..097f88d662 100644 --- a/src/backend/logger/logger.ts +++ b/src/backend/logger/logger.ts @@ -20,7 +20,8 @@ export enum LogPrefix { Backend = 'Backend', Runtime = 'Runtime', Shortcuts = 'Shortcuts', - WineTricks = 'Winetricks' + WineTricks = 'Winetricks', + Connection = 'Connection' } type LogInputType = unknown[] | unknown diff --git a/src/backend/main.ts b/src/backend/main.ts index 3ea917380f..db5a8ed773 100644 --- a/src/backend/main.ts +++ b/src/backend/main.ts @@ -59,7 +59,6 @@ import { getGogdlVersion, getSystemInfo, handleExit, - isOnline, openUrlOrFile, resetHeroic, showAboutWindow, @@ -115,6 +114,11 @@ import { gameInfoStore } from './legendary/electronStores' import { getFonts } from 'font-list' import { verifyWinePrefix } from './launcher' import shlex from 'shlex' +import { + initOnlineMonitor, + isOnline, + runOnceWhenOnline +} from './online_monitor' const { showMessageBox, showOpenDialog } = dialog const isWindows = platform() === 'win32' @@ -331,6 +335,8 @@ if (!gotTheLock) { handleProtocol(mainWindow, argv) }) app.whenReady().then(async () => { + initOnlineMonitor() + const systemInfo = await getSystemInfo() initImagesCache() @@ -345,19 +351,22 @@ if (!gotTheLock) { logInfo(`\n\n${systemInfo}\n`, { prefix: LogPrefix.Backend }) // We can't use .config since apparently its not loaded fast enough. const { language, darkTrayIcon } = await GlobalConfig.get().getSettings() - const isLoggedIn = LegendaryUser.isLoggedIn() - if (!isLoggedIn) { - logInfo('User Not Found, removing it from Store', { - prefix: LogPrefix.Backend - }) - configStore.delete('userinfo') - } + runOnceWhenOnline(async () => { + const isLoggedIn = LegendaryUser.isLoggedIn() - // Update user details - if (GOGUser.isLoggedIn()) { - GOGUser.getUserDetails() - } + if (!isLoggedIn) { + logInfo('User Not Found, removing it from Store', { + prefix: LogPrefix.Backend + }) + configStore.delete('userinfo') + } + + // Update user details + if (GOGUser.isLoggedIn()) { + GOGUser.getUserDetails() + } + }) await i18next.use(Backend).init({ backend: { diff --git a/src/backend/online_monitor.ts b/src/backend/online_monitor.ts new file mode 100644 index 0000000000..88e98ab29b --- /dev/null +++ b/src/backend/online_monitor.ts @@ -0,0 +1,129 @@ +import { ConnectivityStatus } from '../common/types' +import { BrowserWindow, ipcMain, IpcMainEvent } from 'electron' +import { logInfo, LogPrefix } from './logger/logger' +import axios from 'axios' + +let status: ConnectivityStatus +let abortController: AbortController +let retryTimer: NodeJS.Timeout +let retryIn = 0 +const defaultTimeBetweenRetries = 5 +let timeBetweenRetries = defaultTimeBetweenRetries + +// handle setting the status, dispatch events for backend and frontend, and trigger pings +const setStatus = (newStatus: ConnectivityStatus) => { + logInfo(`Connectivity: ${newStatus}`, { prefix: LogPrefix.Connection }) + + status = newStatus + + // events + const mainWindow = BrowserWindow.getAllWindows()[0] + if (mainWindow) { + mainWindow.webContents.send('connectivity-changed', { status, retryIn }) + } + ipcMain.emit(status) + + // start pinging if needed or cancel pings + switch (status) { + case 'check-online': + pingSites() + break + default: + if (abortController) { + abortController.abort() + } + if (retryTimer) { + clearTimeout(retryTimer) + } + } +} + +const retry = (seconds: number) => { + retryIn = seconds + // logInfo(`Retrying in: ${retryIn} seconds`, { prefix: LogPrefix.Connection }) + // dispatch event with retry countdown + const mainWindow = BrowserWindow.getAllWindows()[0] + if (mainWindow) { + mainWindow.webContents.send('connectivity-changed', { + status: 'check-online', + retryIn: seconds + }) + } + + if (seconds) { + // if still counting down, repeat + retryTimer = setTimeout(() => retry(seconds - 1), 1000) + } else { + // else, retry pings + pingSites() + } +} + +const ping = async (url: string, signal: AbortSignal) => { + return axios.head(url, { + timeout: 2000, + signal, + headers: { 'Cache-Control': 'no-cache' } + }) +} + +const pingSites = () => { + logInfo(`Pinging external endpoints`, { prefix: LogPrefix.Connection }) + abortController = new AbortController() + + const ping1 = ping('https://github.com', abortController.signal) + const ping2 = ping('https://store.epicgames.com', abortController.signal) + const ping3 = ping('https://gog.com', abortController.signal) + + Promise.any([ping1, ping2, ping3]) + .then(() => { + setStatus('online') + abortController.abort() // abort the rest + timeBetweenRetries = defaultTimeBetweenRetries + }) + .catch((error) => { + logInfo('All ping requests failed:', { prefix: LogPrefix.Connection }) + logInfo(error, { prefix: LogPrefix.Connection }) + retry(timeBetweenRetries) + timeBetweenRetries = timeBetweenRetries + defaultTimeBetweenRetries + }) +} + +export const initOnlineMonitor = () => { + // listen to events from the frontend + ipcMain.addListener( + 'connectivity-changed', + (_event: IpcMainEvent, newStatus: ConnectivityStatus) => { + setStatus(newStatus) + } + ) + + // set initial status and ping external sites + setStatus('check-online') + + // listen to the frontend asking for current status + ipcMain.handle('get-connectivity-status', () => { + return { status, retryIn } + }) +} + +export const makeNetworkRequest = (callback: () => unknown) => { + if (isOnline()) { + callback() + } +} + +export const runOnceWhenOnline = (callback: () => unknown) => { + if (isOnline()) { + callback() + } else { + ipcMain.once('online', () => callback()) + } +} + +export const isOnline = () => status === 'online' + +// use this function to trigger the connectivity check when detecting an external request failing +export const checkConnectivity = () => { + setStatus('check-online') +} diff --git a/src/backend/tools.ts b/src/backend/tools.ts index 6fab0f2a2a..f14b5b7dfd 100644 --- a/src/backend/tools.ts +++ b/src/backend/tools.ts @@ -3,16 +3,12 @@ import * as axios from 'axios' import { existsSync, readFileSync, writeFileSync } from 'graceful-fs' import { exec, spawn } from 'child_process' -import { - execAsync, - getWineFromProton, - isOnline, - showErrorBoxModalAuto -} from './utils' +import { execAsync, getWineFromProton, showErrorBoxModalAuto } from './utils' import { execOptions, heroicToolsPath, userHome } from './constants' import { logError, logInfo, LogPrefix, logWarning } from './logger/logger' import i18next from 'i18next' import { dirname } from 'path' +import { isOnline } from './online_monitor' export const DXVK = { getLatest: async () => { diff --git a/src/backend/utils.ts b/src/backend/utils.ts index 92f1beebfe..9f2b706f0a 100644 --- a/src/backend/utils.ts +++ b/src/backend/utils.ts @@ -8,7 +8,7 @@ import { Release } from 'common/types' import * as axios from 'axios' -import { app, dialog, net, shell, Notification, BrowserWindow } from 'electron' +import { app, dialog, shell, Notification, BrowserWindow } from 'electron' import { exec, spawn, spawnSync } from 'child_process' import { existsSync, rmSync, stat } from 'graceful-fs' import { promisify } from 'util' @@ -127,37 +127,6 @@ function semverGt(target: string, base: string) { return isGE } -function isOnline() { - let online = net.isOnline() - if (online) { - const hosts = ['google.com', 'store.epicgames.com', 'gog.com'] - const errors = [] as string[] - online = hosts.some((host) => { - const args = [host] as string[] - - if (isWindows) { - args.push('-n', '1') - } else { - args.push('-c', '1') - } - - const { status, stderr } = spawnSync('ping', args) - if (stderr.length) { - errors.push( - [`Ping of ${host} failed with:`, stderr.toString()].join('\n') - ) - } - return status === 0 - }) - - if (!online && errors.length) { - logError(errors.join('\n'), { prefix: LogPrefix.Backend }) - } - } - - return online -} - export const getFileSize = fileSize.partial({ base: 2 }) export function getWineFromProton( @@ -825,7 +794,6 @@ export { errorHandler, execAsync, handleExit, - isOnline, isEpicServiceOffline, openUrlOrFile, semverGt, diff --git a/src/common/types.ts b/src/common/types.ts index d123969fef..5a8f776505 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -448,3 +448,5 @@ export type ElWebview = { export type WebviewType = HTMLWebViewElement & ElWebview export type InstallPlatform = LegendaryInstallPlatform | GogInstallPlatform + +export type ConnectivityStatus = 'offline' | 'check-online' | 'online' diff --git a/src/frontend/App.css b/src/frontend/App.css index 80438a2747..638bef89be 100644 --- a/src/frontend/App.css +++ b/src/frontend/App.css @@ -37,8 +37,8 @@ html, color: var(--text-default); display: grid; grid-template-columns: var(--sidebar-width) 1fr; - grid-template-areas: 'sidebar content' 'controller controller'; - grid-template-rows: 1fr min-content; + grid-template-areas: 'offline offline' 'sidebar content' 'controller controller'; + grid-template-rows: min-content 1fr min-content; font-family: var(--content-font-family); background: var(--body-background); --sidebar-width: 240px; @@ -51,8 +51,13 @@ html, grid-template-columns: var(--sidebar-width) 1fr; } +.App .Sidebar { + grid-area: sidebar; +} + .App .content { display: flex; + grid-area: content; flex-direction: column; height: 100%; overflow-y: auto; @@ -75,6 +80,10 @@ html, position: relative; } +.App .offline-message { + grid-area: offline; +} + .danger { font-weight: 700; color: var(--danger); diff --git a/src/frontend/App.tsx b/src/frontend/App.tsx index 94c6cb18e5..78e2f34789 100644 --- a/src/frontend/App.tsx +++ b/src/frontend/App.tsx @@ -12,7 +12,7 @@ import Settings from './screens/Settings' import Accessibility from './screens/Accessibility' import ContextProvider from './state/ContextProvider' import classNames from 'classnames' -import { ControllerHints } from './components/UI' +import { ControllerHints, OfflineMessage } from './components/UI' function App() { const { epic, gog, contentFontFamily, actionsFontFamily, sidebarCollapsed } = @@ -31,6 +31,7 @@ function App() { style={style} > +
diff --git a/src/frontend/components/UI/OfflineMessage/index.css b/src/frontend/components/UI/OfflineMessage/index.css new file mode 100644 index 0000000000..a835382866 --- /dev/null +++ b/src/frontend/components/UI/OfflineMessage/index.css @@ -0,0 +1,36 @@ +.offline-message { + background: wheat; + padding: 0.5rem; + color: black; + display: grid; + position: relative; +} + +.offline-message span, +.offline-message button { + grid-row: 1; + grid-column: 1; +} + +.offline-message button { + justify-self: flex-end; + align-self: flex-end; + background: wheat; + border: 2px solid rgb(243, 200, 121); +} + +.offline-message .retry-hint { + display: none; + position: absolute; + top: calc(100% - 5px); + right: 5px; + width: 200px; + z-index: 100; + background: wheat; + padding: 1rem; + border: 2px solid rgb(243, 200, 121); +} + +.offline-message .retry-hint.show { + display: block; +} diff --git a/src/frontend/components/UI/OfflineMessage/index.tsx b/src/frontend/components/UI/OfflineMessage/index.tsx new file mode 100644 index 0000000000..b5b5f52bc0 --- /dev/null +++ b/src/frontend/components/UI/OfflineMessage/index.tsx @@ -0,0 +1,53 @@ +import ContextProvider from 'frontend/state/ContextProvider' +import React, { MouseEvent, useContext, useState } from 'react' +import { useTranslation } from 'react-i18next' + +import './index.css' + +const OfflineMessage = () => { + const { t } = useTranslation() + const { connectivity } = useContext(ContextProvider) + const [showHint, setShowHint] = useState(false) + + // render nothing if online + if (connectivity.status === 'online') { + return <> + } + + let content = t('offline-message.offline', 'Offline') + + if (connectivity.status === 'check-online') { + if (connectivity.retryIn) { + content += t('offline-message.retry-in', { + defaultValue: 'Retrying in ... {{seconds}} seconds', + seconds: connectivity.retryIn + }) + } else { + content = t('offline-message.retrying', 'Retrying') + } + } + + const toggleHint = (ev: MouseEvent) => { + ev.preventDefault() + setShowHint(!showHint) + } + + const hintHtml = t('offline-message.hint', { + defaultValue: + 'We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com', + newline: '
' + }) + + return ( +
+ {content} + + +
+ ) +} + +export default OfflineMessage diff --git a/src/frontend/components/UI/index.tsx b/src/frontend/components/UI/index.tsx index de32d46ba4..9492e9c18a 100644 --- a/src/frontend/components/UI/index.tsx +++ b/src/frontend/components/UI/index.tsx @@ -11,3 +11,4 @@ export { default as UpdateComponent } from './UpdateComponent' export { default as SvgButton } from './SvgButton' export { default as ControllerHints } from './ControllerHints' export { default as CachedImage } from './CachedImage' +export { default as OfflineMessage } from './OfflineMessage' diff --git a/src/frontend/helpers/onlineMonitor.ts b/src/frontend/helpers/onlineMonitor.ts new file mode 100644 index 0000000000..38ccb59ad8 --- /dev/null +++ b/src/frontend/helpers/onlineMonitor.ts @@ -0,0 +1,11 @@ +import { ipcRenderer } from '.' + +export const initOnlineMonitor = () => { + window.addEventListener('online', () => { + ipcRenderer.send('connectivity-changed', 'check-online') + }) + + window.addEventListener('offline', () => { + ipcRenderer.send('connectivity-changed', 'offline') + }) +} diff --git a/src/frontend/index.tsx b/src/frontend/index.tsx index c33c611f23..e0af0db323 100644 --- a/src/frontend/index.tsx +++ b/src/frontend/index.tsx @@ -13,6 +13,9 @@ import { UpdateComponentBase } from './components/UI/UpdateComponent' import { initShortcuts } from './helpers/shortcuts' import { configStore } from './helpers/electronStores' import { ipcRenderer } from './helpers' +import { initOnlineMonitor } from './helpers/onlineMonitor' + +initOnlineMonitor() window.addEventListener('error', (ev: ErrorEvent) => { ipcRenderer.send('frontendError', ev.error) diff --git a/src/frontend/state/ContextProvider.tsx b/src/frontend/state/ContextProvider.tsx index 5a1687d90e..c98afc4020 100644 --- a/src/frontend/state/ContextProvider.tsx +++ b/src/frontend/state/ContextProvider.tsx @@ -65,7 +65,8 @@ const initialContext: ContextType = { setAllTilesInColor: () => null, sidebarCollapsed: false, setSideBarCollapsed: () => null, - activeController: '' + activeController: '', + connectivity: { status: 'online', retryIn: 0 } } export default React.createContext(initialContext) diff --git a/src/frontend/state/GlobalState.tsx b/src/frontend/state/GlobalState.tsx index 04d6489fd1..d9f13ff352 100644 --- a/src/frontend/state/GlobalState.tsx +++ b/src/frontend/state/GlobalState.tsx @@ -1,6 +1,7 @@ import React, { PureComponent } from 'react' import { + ConnectivityStatus, FavouriteGame, GameInfo, GameStatus, @@ -78,6 +79,7 @@ interface StateProps { allTilesInColor: boolean sidebarCollapsed: boolean activeController: string + connectivity: { status: ConnectivityStatus; retryIn: number } } export class GlobalState extends PureComponent { @@ -144,7 +146,8 @@ export class GlobalState extends PureComponent { actionsFontFamily: (configStore.get('actionsFontFamily') as string) || "'Rubik', sans-serif", allTilesInColor: (configStore.get('allTilesInColor') as boolean) || false, - activeController: '' + activeController: '', + connectivity: { status: 'offline', retryIn: 0 } } setLanguage = (newLanguage: string) => { @@ -591,6 +594,16 @@ export class GlobalState extends PureComponent { } ) + // listen to custom connectivity-changed event to update state + ipcRenderer.on('connectivity-changed', (_, connectivity) => { + this.setState({ connectivity }) + }) + + // get the current status + ipcRenderer + .invoke('get-connectivity-status', []) + .then((connectivity) => this.setState({ connectivity })) + ipcRenderer.send('frontendReady') } diff --git a/src/frontend/types.ts b/src/frontend/types.ts index 5d31c3c794..0c8231fee7 100644 --- a/src/frontend/types.ts +++ b/src/frontend/types.ts @@ -1,5 +1,5 @@ import { VersionInfo } from 'heroic-wine-downloader' -import { GameInfo, GameStatus, Runner } from 'common/types' +import { ConnectivityStatus, GameInfo, GameStatus, Runner } from 'common/types' export type Category = 'all' | 'legendary' | 'gog' @@ -67,6 +67,7 @@ export interface ContextType { setSideBarCollapsed: (value: boolean) => void sidebarCollapsed: boolean activeController: string + connectivity: { status: ConnectivityStatus; retryIn: number } } export type LibraryTopSectionOptions = From 6f74ef34941c5a30e14d8e416dd80dc76869a398 Mon Sep 17 00:00:00 2001 From: Ariel Juodziukynas Date: Mon, 26 Sep 2022 20:32:14 -0300 Subject: [PATCH 2/4] Style fixes, retry seconds fix? --- src/backend/online_monitor.ts | 3 +++ .../components/UI/OfflineMessage/index.css | 20 +++++++++---------- .../components/UI/OfflineMessage/index.tsx | 12 +++-------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/backend/online_monitor.ts b/src/backend/online_monitor.ts index 88e98ab29b..d274f6883b 100644 --- a/src/backend/online_monitor.ts +++ b/src/backend/online_monitor.ts @@ -52,6 +52,9 @@ const retry = (seconds: number) => { if (seconds) { // if still counting down, repeat + if (retryTimer) { + clearTimeout(retryTimer) + } retryTimer = setTimeout(() => retry(seconds - 1), 1000) } else { // else, retry pings diff --git a/src/frontend/components/UI/OfflineMessage/index.css b/src/frontend/components/UI/OfflineMessage/index.css index a835382866..1cc6862d94 100644 --- a/src/frontend/components/UI/OfflineMessage/index.css +++ b/src/frontend/components/UI/OfflineMessage/index.css @@ -1,7 +1,7 @@ .offline-message { - background: wheat; + background: var(--accent-overlay); padding: 0.5rem; - color: black; + color: var(--text-tertiary); display: grid; position: relative; } @@ -15,22 +15,22 @@ .offline-message button { justify-self: flex-end; align-self: flex-end; - background: wheat; - border: 2px solid rgb(243, 200, 121); + background: var(--accent-overlay); + border: transparent; } .offline-message .retry-hint { display: none; position: absolute; - top: calc(100% - 5px); - right: 5px; - width: 200px; + top: 100%; + right: 0px; + width: 400px; z-index: 100; - background: wheat; + background: var(--accent-overlay); padding: 1rem; - border: 2px solid rgb(243, 200, 121); + border: transparent; } -.offline-message .retry-hint.show { +.offline-message .hint-hover:hover + .retry-hint { display: block; } diff --git a/src/frontend/components/UI/OfflineMessage/index.tsx b/src/frontend/components/UI/OfflineMessage/index.tsx index b5b5f52bc0..662c53487f 100644 --- a/src/frontend/components/UI/OfflineMessage/index.tsx +++ b/src/frontend/components/UI/OfflineMessage/index.tsx @@ -1,5 +1,5 @@ import ContextProvider from 'frontend/state/ContextProvider' -import React, { MouseEvent, useContext, useState } from 'react' +import React, { useContext } from 'react' import { useTranslation } from 'react-i18next' import './index.css' @@ -7,7 +7,6 @@ import './index.css' const OfflineMessage = () => { const { t } = useTranslation() const { connectivity } = useContext(ContextProvider) - const [showHint, setShowHint] = useState(false) // render nothing if online if (connectivity.status === 'online') { @@ -27,11 +26,6 @@ const OfflineMessage = () => { } } - const toggleHint = (ev: MouseEvent) => { - ev.preventDefault() - setShowHint(!showHint) - } - const hintHtml = t('offline-message.hint', { defaultValue: 'We are checking the connectivity against:{{newline}}github.com,{{newline}}gog.com and{{newline}}store.epicgames.com', @@ -41,9 +35,9 @@ const OfflineMessage = () => { return (
{content} - +
From bc35bba436971d91a7c1a356fb96339b461270f5 Mon Sep 17 00:00:00 2001 From: Ariel Juodziukynas Date: Mon, 3 Oct 2022 19:06:06 -0300 Subject: [PATCH 3/4] Fix retry counter, don't retry if offline at start --- src/backend/online_monitor.ts | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/backend/online_monitor.ts b/src/backend/online_monitor.ts index d274f6883b..819a6dce7e 100644 --- a/src/backend/online_monitor.ts +++ b/src/backend/online_monitor.ts @@ -1,5 +1,5 @@ import { ConnectivityStatus } from '../common/types' -import { BrowserWindow, ipcMain, IpcMainEvent } from 'electron' +import { BrowserWindow, ipcMain, IpcMainEvent, net } from 'electron' import { logInfo, LogPrefix } from './logger/logger' import axios from 'axios' @@ -16,19 +16,14 @@ const setStatus = (newStatus: ConnectivityStatus) => { status = newStatus - // events - const mainWindow = BrowserWindow.getAllWindows()[0] - if (mainWindow) { - mainWindow.webContents.send('connectivity-changed', { status, retryIn }) - } - ipcMain.emit(status) - // start pinging if needed or cancel pings switch (status) { case 'check-online': pingSites() break default: + retryIn = 0 + timeBetweenRetries = defaultTimeBetweenRetries if (abortController) { abortController.abort() } @@ -36,6 +31,13 @@ const setStatus = (newStatus: ConnectivityStatus) => { clearTimeout(retryTimer) } } + + // events + const mainWindow = BrowserWindow.getAllWindows()[0] + if (mainWindow) { + mainWindow.webContents.send('connectivity-changed', { status, retryIn }) + } + ipcMain.emit(status) } const retry = (seconds: number) => { @@ -101,8 +103,12 @@ export const initOnlineMonitor = () => { } ) - // set initial status and ping external sites - setStatus('check-online') + if (net.isOnline()) { + // set initial status and ping external sites + setStatus('check-online') + } else { + setStatus('offline') + } // listen to the frontend asking for current status ipcMain.handle('get-connectivity-status', () => { From b6f64193137759cfb8d04e821bc6f41438819994 Mon Sep 17 00:00:00 2001 From: Ariel Juodziukynas Date: Mon, 3 Oct 2022 19:17:41 -0300 Subject: [PATCH 4/4] Use custom event emitter for connection events, revert strings after key change --- public/locales/ar/gamepage.json | 2 +- public/locales/az/gamepage.json | 2 +- public/locales/be/gamepage.json | 2 +- public/locales/bg/gamepage.json | 2 +- public/locales/bs/gamepage.json | 2 +- public/locales/ca/gamepage.json | 2 +- public/locales/cs/gamepage.json | 2 +- public/locales/da/gamepage.json | 2 +- public/locales/de/gamepage.json | 2 +- public/locales/el/gamepage.json | 2 +- public/locales/en/gamepage.json | 2 +- public/locales/es/gamepage.json | 2 +- public/locales/et/gamepage.json | 2 +- public/locales/eu/gamepage.json | 2 +- public/locales/fa/gamepage.json | 2 +- public/locales/fi/gamepage.json | 2 +- public/locales/fr/gamepage.json | 2 +- public/locales/gl/gamepage.json | 2 +- public/locales/hr/gamepage.json | 2 +- public/locales/hu/gamepage.json | 2 +- public/locales/id/gamepage.json | 2 +- public/locales/it/gamepage.json | 2 +- public/locales/ja/gamepage.json | 2 +- public/locales/ko/gamepage.json | 2 +- public/locales/ml/gamepage.json | 2 +- public/locales/nb_NO/gamepage.json | 2 +- public/locales/nl/gamepage.json | 2 +- public/locales/pl/gamepage.json | 2 +- public/locales/pt/gamepage.json | 2 +- public/locales/pt_BR/gamepage.json | 2 +- public/locales/ro/gamepage.json | 2 +- public/locales/ru/gamepage.json | 2 +- public/locales/sk/gamepage.json | 2 +- public/locales/sv/gamepage.json | 2 +- public/locales/ta/gamepage.json | 2 +- public/locales/tr/gamepage.json | 2 +- public/locales/uk/gamepage.json | 2 +- public/locales/vi/gamepage.json | 2 +- public/locales/zh_Hans/gamepage.json | 2 +- public/locales/zh_Hant/gamepage.json | 2 +- src/backend/online_monitor.ts | 6 ++++-- 41 files changed, 44 insertions(+), 42 deletions(-) diff --git a/public/locales/ar/gamepage.json b/public/locales/ar/gamepage.json index 51e8815744..548ec34c02 100644 --- a/public/locales/ar/gamepage.json +++ b/public/locales/ar/gamepage.json @@ -137,7 +137,7 @@ "language": "اللغة", "platform": "حدد إصدار النظام الأساسي المراد تثبيته", "info": "معلومات", - "reuirements": "متطلبات النظام", + "requirements": "متطلبات النظام", "tools": "الأدوات" }, "dlc": { diff --git a/public/locales/az/gamepage.json b/public/locales/az/gamepage.json index 5475a84582..b1556de6a1 100644 --- a/public/locales/az/gamepage.json +++ b/public/locales/az/gamepage.json @@ -63,7 +63,7 @@ "lastPlayed": "Son Oynama", "neverPlayed": "Heç vaxt", "platform": "Quraşdırmaq üçün Platforma Versiyasını seçin", - "reuirements": "Sistem Tələbləri", + "requirements": "Sistem Tələbləri", "tools": "Alətlər", "totalPlayed": "Oynanan Vaxt" }, diff --git a/public/locales/be/gamepage.json b/public/locales/be/gamepage.json index acf31093be..6e539d44c7 100644 --- a/public/locales/be/gamepage.json +++ b/public/locales/be/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Апошняя гульня", "neverPlayed": "ніколі", "platform": "Выберыце версію платформы для ўстаноўкі", - "reuirements": "Сістэмныя патрабаванні", + "requirements": "Сістэмныя патрабаванні", "tools": "інструменты", "totalPlayed": "Згуляны час" }, diff --git a/public/locales/bg/gamepage.json b/public/locales/bg/gamepage.json index 08ca38a0ea..47313127d9 100644 --- a/public/locales/bg/gamepage.json +++ b/public/locales/bg/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Последно пускане", "neverPlayed": "Никога", "platform": "Изберете версия за инсталиране", - "reuirements": "Системни изисквания", + "requirements": "Системни изисквания", "tools": "Инструменти", "totalPlayed": "Изиграно време" }, diff --git a/public/locales/bs/gamepage.json b/public/locales/bs/gamepage.json index c88cf2f495..9ffce474c4 100644 --- a/public/locales/bs/gamepage.json +++ b/public/locales/bs/gamepage.json @@ -63,7 +63,7 @@ "lastPlayed": "Zadnji put odigrano", "neverPlayed": "Nikada", "platform": "Odaberi verziju platforme za instalirati", - "reuirements": "Zahtjevi sistema", + "requirements": "Zahtjevi sistema", "tools": "Alati", "totalPlayed": "Vrijeme igranja" }, diff --git a/public/locales/ca/gamepage.json b/public/locales/ca/gamepage.json index 4e49cb646a..5185f27cc2 100644 --- a/public/locales/ca/gamepage.json +++ b/public/locales/ca/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Última partida", "neverPlayed": "Mai", "platform": "Selecciona la versió de la plataforma per instal·lar", - "reuirements": "Requeriments del sistema", + "requirements": "Requeriments del sistema", "tools": "Eines", "totalPlayed": "Temps jugat" }, diff --git a/public/locales/cs/gamepage.json b/public/locales/cs/gamepage.json index 38d6c5b0d1..710a71f6b7 100644 --- a/public/locales/cs/gamepage.json +++ b/public/locales/cs/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Naposledy hráno", "neverPlayed": "Nikdy", "platform": "Vyberte verzi platformy, kterou chcete nainstalovat", - "reuirements": "Systémové požadavky", + "requirements": "Systémové požadavky", "tools": "Nástroje", "totalPlayed": "Odehraný čas" }, diff --git a/public/locales/da/gamepage.json b/public/locales/da/gamepage.json index b26e25c4c3..ba99b6f0c1 100644 --- a/public/locales/da/gamepage.json +++ b/public/locales/da/gamepage.json @@ -64,7 +64,7 @@ "language": "Sprog", "info": "Info", "platform": "Vælg platformsversion, der skal installeres", - "reuirements": "System Krav", + "requirements": "System Krav", "tools": "Værktøjer" }, "gamecard": { diff --git a/public/locales/de/gamepage.json b/public/locales/de/gamepage.json index cd5abc417c..490db4e04f 100644 --- a/public/locales/de/gamepage.json +++ b/public/locales/de/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Zuletzt gespielt", "neverPlayed": "Nie", "platform": "Zu installierende Plattformversion auswählen", - "reuirements": "Systemanforderungen", + "requirements": "Systemanforderungen", "tools": "Werkzeuge", "totalPlayed": "Spielzeit" }, diff --git a/public/locales/el/gamepage.json b/public/locales/el/gamepage.json index 564618c999..dcd5914cd6 100644 --- a/public/locales/el/gamepage.json +++ b/public/locales/el/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Παίχτηκε Τελευταία φορά", "neverPlayed": "Ποτέ", "platform": "Επιλέξτε Έκδοση Πλατφόρμας για εγκατάσταση", - "reuirements": "Απαιτήσεις Συστήματος", + "requirements": "Απαιτήσεις Συστήματος", "tools": "Εργαλεία", "totalPlayed": "Συνολικός Χρόνος Παιχνιδιού" }, diff --git a/public/locales/en/gamepage.json b/public/locales/en/gamepage.json index 49c135929b..000f47c6c2 100644 --- a/public/locales/en/gamepage.json +++ b/public/locales/en/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Last Played", "neverPlayed": "Never", "platform": "Select Platform Version to Install", - "reuirements": "System Requirements", + "requirements": "System Requirements", "tools": "Tools", "totalPlayed": "Time Played" }, diff --git a/public/locales/es/gamepage.json b/public/locales/es/gamepage.json index 7b7ae0d415..72431854b1 100644 --- a/public/locales/es/gamepage.json +++ b/public/locales/es/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Jugado por Última Vez", "neverPlayed": "Nunca", "platform": "Seleccionar la Version de la Plataforma para Instalar", - "reuirements": "Requerimientos del Sistema", + "requirements": "Requerimientos del Sistema", "tools": "Herramientas", "totalPlayed": "Tiempo Jugado" }, diff --git a/public/locales/et/gamepage.json b/public/locales/et/gamepage.json index e23f494271..62e226c43d 100644 --- a/public/locales/et/gamepage.json +++ b/public/locales/et/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Viimati mängitud", "neverPlayed": "Mitte kunagi", "platform": "Valige paigaldatava platvormi versioon", - "reuirements": "Süsteeminõuded", + "requirements": "Süsteeminõuded", "tools": "Tööriistad", "totalPlayed": "Mängitud aeg" }, diff --git a/public/locales/eu/gamepage.json b/public/locales/eu/gamepage.json index 86b5dde677..d08fb612de 100644 --- a/public/locales/eu/gamepage.json +++ b/public/locales/eu/gamepage.json @@ -63,7 +63,7 @@ "lastPlayed": "Azken jokaldia", "neverPlayed": "Inoiz ez", "platform": "Instalatzeko plataformaren bertsioa hautatu", - "reuirements": "Sistemaren betekizunak", + "requirements": "Sistemaren betekizunak", "tools": "Tresnak", "totalPlayed": "Denbora jokatua" }, diff --git a/public/locales/fa/gamepage.json b/public/locales/fa/gamepage.json index 00855411ad..0ec57e29c8 100644 --- a/public/locales/fa/gamepage.json +++ b/public/locales/fa/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "آخرین اجرا", "neverPlayed": "هرگز", "platform": "انتخاب نسخه پلتفرم برای نصب", - "reuirements": "نیازهای سیستم", + "requirements": "نیازهای سیستم", "tools": "ابزارها", "totalPlayed": "زمان بازی" }, diff --git a/public/locales/fi/gamepage.json b/public/locales/fi/gamepage.json index 380078bf14..b1e4ffab3f 100644 --- a/public/locales/fi/gamepage.json +++ b/public/locales/fi/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Viimeksi pelattu", "neverPlayed": "Ei koskaan", "platform": "Select Platform Version to Install", - "reuirements": "System Requirements", + "requirements": "System Requirements", "tools": "Tools", "totalPlayed": "Pelattu aika" }, diff --git a/public/locales/fr/gamepage.json b/public/locales/fr/gamepage.json index 493c015a1c..b65d391d26 100644 --- a/public/locales/fr/gamepage.json +++ b/public/locales/fr/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Joué la dernière fois", "neverPlayed": "Jamais", "platform": "Sélectionner la version de la plateforme pour installer", - "reuirements": "System Requirements", + "requirements": "System Requirements", "tools": "Tools", "totalPlayed": "Temps passé à jouer" }, diff --git a/public/locales/gl/gamepage.json b/public/locales/gl/gamepage.json index a6fa5bda93..9c6579b264 100644 --- a/public/locales/gl/gamepage.json +++ b/public/locales/gl/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Xogado por última vez", "neverPlayed": "Nunca", "platform": "Select Platform Version to Install", - "reuirements": "System Requirements", + "requirements": "System Requirements", "tools": "Tools", "totalPlayed": "Tempo xogado" }, diff --git a/public/locales/hr/gamepage.json b/public/locales/hr/gamepage.json index e22503f655..aa0442c85d 100644 --- a/public/locales/hr/gamepage.json +++ b/public/locales/hr/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Zadnje odigrano", "neverPlayed": "Nikad", "platform": "Odaberi verziju platforme za instalirati", - "reuirements": "Zahtjevi sustava", + "requirements": "Zahtjevi sustava", "tools": "Alati", "totalPlayed": "Vrijeme igranja" }, diff --git a/public/locales/hu/gamepage.json b/public/locales/hu/gamepage.json index e1a10b633c..aada39cf40 100644 --- a/public/locales/hu/gamepage.json +++ b/public/locales/hu/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Legutóbb játszott", "neverPlayed": "Soha", "platform": "Telepítendő platform változat kiválasztása", - "reuirements": "Rendszerkövetelmények", + "requirements": "Rendszerkövetelmények", "tools": "Ezközök", "totalPlayed": "Játszott idő" }, diff --git a/public/locales/id/gamepage.json b/public/locales/id/gamepage.json index 65551d7dab..b574b0dccc 100644 --- a/public/locales/id/gamepage.json +++ b/public/locales/id/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Terakhir Dimainkan", "neverPlayed": "Tidak pernah", "platform": "Pilih Versi Platform yang Akan Dipasang", - "reuirements": "Persyaratan Sistem", + "requirements": "Persyaratan Sistem", "tools": "Peralatan", "totalPlayed": "Lama Dimainkan" }, diff --git a/public/locales/it/gamepage.json b/public/locales/it/gamepage.json index fcec5c71c3..736ddf2b1b 100644 --- a/public/locales/it/gamepage.json +++ b/public/locales/it/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Giocato recentemente", "neverPlayed": "Mai", "platform": "Seleziona la versione della piattaforma da installare", - "reuirements": "Requisiti Di Sistema", + "requirements": "Requisiti Di Sistema", "tools": "Strumenti", "totalPlayed": "Tempo giocato" }, diff --git a/public/locales/ja/gamepage.json b/public/locales/ja/gamepage.json index 0bca157876..01e631a821 100644 --- a/public/locales/ja/gamepage.json +++ b/public/locales/ja/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "最後にプレイした", "neverPlayed": "一度もない", "platform": "Select Platform Version to Install", - "reuirements": "System Requirements", + "requirements": "System Requirements", "tools": "Tools", "totalPlayed": "プレイ時間" }, diff --git a/public/locales/ko/gamepage.json b/public/locales/ko/gamepage.json index c92494fcda..01fecb9ed6 100644 --- a/public/locales/ko/gamepage.json +++ b/public/locales/ko/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "마지막 플레이", "neverPlayed": "플레이 한 적 없음", "platform": "설치할 플랫폼 버전 선택", - "reuirements": "시스템 요구 사항", + "requirements": "시스템 요구 사항", "tools": "도구", "totalPlayed": "플레이 시간" }, diff --git a/public/locales/ml/gamepage.json b/public/locales/ml/gamepage.json index b544d2b8c8..eb0255e7f7 100644 --- a/public/locales/ml/gamepage.json +++ b/public/locales/ml/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "ഒടുക്കം കളിച്ചത്", "neverPlayed": "കളിച്ചിട്ടേയില്ല", "platform": "Select Platform Version to Install", - "reuirements": "System Requirements", + "requirements": "System Requirements", "tools": "Tools", "totalPlayed": "കളിച്ച നേരം" }, diff --git a/public/locales/nb_NO/gamepage.json b/public/locales/nb_NO/gamepage.json index 1e9d45a429..8801769d29 100644 --- a/public/locales/nb_NO/gamepage.json +++ b/public/locales/nb_NO/gamepage.json @@ -63,7 +63,7 @@ "lastPlayed": "Sist spilt", "neverPlayed": "Aldri", "platform": "Velg plattformversjon som skal installeres", - "reuirements": "Systemkrav", + "requirements": "Systemkrav", "tools": "Verktøy", "totalPlayed": "Spilletid" }, diff --git a/public/locales/nl/gamepage.json b/public/locales/nl/gamepage.json index d40f4833fa..95d8e8ad1f 100644 --- a/public/locales/nl/gamepage.json +++ b/public/locales/nl/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Laatst gespeeld", "neverPlayed": "Nooit", "platform": "Select Platform Version to Install", - "reuirements": "System Requirements", + "requirements": "System Requirements", "tools": "Tools", "totalPlayed": "Tijd gespeeld" }, diff --git a/public/locales/pl/gamepage.json b/public/locales/pl/gamepage.json index dac2c72536..9c216eb416 100644 --- a/public/locales/pl/gamepage.json +++ b/public/locales/pl/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Ostatnio uruchamiane", "neverPlayed": "Nigdy", "platform": "Wybierz wersję platformy do zainstalowania", - "reuirements": "Wymagania systemowe", + "requirements": "Wymagania systemowe", "tools": "Narzędzia", "totalPlayed": "Czas Gry" }, diff --git a/public/locales/pt/gamepage.json b/public/locales/pt/gamepage.json index 469ccdef7e..f3719e5133 100644 --- a/public/locales/pt/gamepage.json +++ b/public/locales/pt/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Jogado pela última vez", "neverPlayed": "Nunca", "platform": "Select Platform Version to Install", - "reuirements": "Requisitos", + "requirements": "Requisitos", "tools": "Ferramentas", "totalPlayed": "Tempo de Jogo" }, diff --git a/public/locales/pt_BR/gamepage.json b/public/locales/pt_BR/gamepage.json index f636571899..bb2b8a571b 100644 --- a/public/locales/pt_BR/gamepage.json +++ b/public/locales/pt_BR/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Jogado pela última vez em", "neverPlayed": "Nunca", "platform": "Seleccione a versão da plataforma para instalar", - "reuirements": "Requisitos", + "requirements": "Requisitos", "tools": "Ferramentas", "totalPlayed": "Tempo de jogo" }, diff --git a/public/locales/ro/gamepage.json b/public/locales/ro/gamepage.json index a61b13e4f3..c9c17f2e8c 100644 --- a/public/locales/ro/gamepage.json +++ b/public/locales/ro/gamepage.json @@ -63,7 +63,7 @@ "lastPlayed": "Ultima Dată Jucat", "neverPlayed": "Niciodată", "platform": "Selectați versiunea platformei de instalat", - "reuirements": "Cerințe de sistem", + "requirements": "Cerințe de sistem", "tools": "Instrumente", "totalPlayed": "Timp Jucat" }, diff --git a/public/locales/ru/gamepage.json b/public/locales/ru/gamepage.json index aa4cd253aa..bcc421c2da 100644 --- a/public/locales/ru/gamepage.json +++ b/public/locales/ru/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Последний запуск", "neverPlayed": "Никогда", "platform": "Выберите версию платформы для установки", - "reuirements": "Системные требования", + "requirements": "Системные требования", "tools": "Инструменты", "totalPlayed": "Проведено в игре" }, diff --git a/public/locales/sk/gamepage.json b/public/locales/sk/gamepage.json index 072fceb964..acb985f339 100644 --- a/public/locales/sk/gamepage.json +++ b/public/locales/sk/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Naposledy hrané", "neverPlayed": "Nikdy", "platform": "Vyberte Verzia platformy na inštaláciu", - "reuirements": "Požiadavky na systém", + "requirements": "Požiadavky na systém", "tools": "Nástroje", "totalPlayed": "Hraný čas" }, diff --git a/public/locales/sv/gamepage.json b/public/locales/sv/gamepage.json index c30783434e..a5f58c450d 100644 --- a/public/locales/sv/gamepage.json +++ b/public/locales/sv/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Senast spelat", "neverPlayed": "Aldrig", "platform": "Välj plattform för installation", - "reuirements": "System Requirements", + "requirements": "System Requirements", "tools": "Tools", "totalPlayed": "Speltid" }, diff --git a/public/locales/ta/gamepage.json b/public/locales/ta/gamepage.json index eecd49e033..a28a7da578 100644 --- a/public/locales/ta/gamepage.json +++ b/public/locales/ta/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Last Played", "neverPlayed": "Never", "platform": "Select Platform Version to Install", - "reuirements": "System Requirements", + "requirements": "System Requirements", "tools": "Tools", "totalPlayed": "Time Played" }, diff --git a/public/locales/tr/gamepage.json b/public/locales/tr/gamepage.json index 3ba0327427..422351c850 100644 --- a/public/locales/tr/gamepage.json +++ b/public/locales/tr/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Son Oynanan", "neverPlayed": "Hiç Oynanmadı", "platform": "Kurulacak Platform Sürümünü Seç", - "reuirements": "Sistem Gereksinimleri", + "requirements": "Sistem Gereksinimleri", "tools": "Araçlar", "totalPlayed": "Oynanan Zaman" }, diff --git a/public/locales/uk/gamepage.json b/public/locales/uk/gamepage.json index e094de229d..fa830b924d 100644 --- a/public/locales/uk/gamepage.json +++ b/public/locales/uk/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Востаннє зіграно", "neverPlayed": "Ніколи", "platform": "Оберіть версію платформи для встановлення", - "reuirements": "Системні вимоги", + "requirements": "Системні вимоги", "tools": "Інструменти", "totalPlayed": "Зіграно часу" }, diff --git a/public/locales/vi/gamepage.json b/public/locales/vi/gamepage.json index 1670b10bd3..ea0d2bc28b 100644 --- a/public/locales/vi/gamepage.json +++ b/public/locales/vi/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "Lần chơi trước", "neverPlayed": "Không bao giờ", "platform": "Chọn phiên bản nền tảng để cài đặt", - "reuirements": "Yêu cầu hệ thống", + "requirements": "Yêu cầu hệ thống", "tools": "Công cụ", "totalPlayed": "Thời gian chơi" }, diff --git a/public/locales/zh_Hans/gamepage.json b/public/locales/zh_Hans/gamepage.json index 88748d1c25..d8807a70ed 100644 --- a/public/locales/zh_Hans/gamepage.json +++ b/public/locales/zh_Hans/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "上次玩", "neverPlayed": "从未玩过", "platform": "选择要安装的平台版本", - "reuirements": "系统要求", + "requirements": "系统要求", "tools": "工具", "totalPlayed": "游玩时间" }, diff --git a/public/locales/zh_Hant/gamepage.json b/public/locales/zh_Hant/gamepage.json index 9ffa9a937f..27d4bc3001 100644 --- a/public/locales/zh_Hant/gamepage.json +++ b/public/locales/zh_Hant/gamepage.json @@ -62,7 +62,7 @@ "lastPlayed": "上次遊玩", "neverPlayed": "從未遊玩", "platform": "選擇要安裝的平台版本", - "reuirements": "系統需求", + "requirements": "系統需求", "tools": "工具", "totalPlayed": "遊玩時間" }, diff --git a/src/backend/online_monitor.ts b/src/backend/online_monitor.ts index 819a6dce7e..15fcd33706 100644 --- a/src/backend/online_monitor.ts +++ b/src/backend/online_monitor.ts @@ -2,6 +2,7 @@ import { ConnectivityStatus } from '../common/types' import { BrowserWindow, ipcMain, IpcMainEvent, net } from 'electron' import { logInfo, LogPrefix } from './logger/logger' import axios from 'axios' +import EventEmitter from 'node:events' let status: ConnectivityStatus let abortController: AbortController @@ -9,6 +10,7 @@ let retryTimer: NodeJS.Timeout let retryIn = 0 const defaultTimeBetweenRetries = 5 let timeBetweenRetries = defaultTimeBetweenRetries +export const connectivityEmitter = new EventEmitter() // handle setting the status, dispatch events for backend and frontend, and trigger pings const setStatus = (newStatus: ConnectivityStatus) => { @@ -37,7 +39,7 @@ const setStatus = (newStatus: ConnectivityStatus) => { if (mainWindow) { mainWindow.webContents.send('connectivity-changed', { status, retryIn }) } - ipcMain.emit(status) + connectivityEmitter.emit(status) } const retry = (seconds: number) => { @@ -126,7 +128,7 @@ export const runOnceWhenOnline = (callback: () => unknown) => { if (isOnline()) { callback() } else { - ipcMain.once('online', () => callback()) + connectivityEmitter.once('online', () => callback()) } }