From fffaeb2459e35c250a55ef23799e1d32b47dc126 Mon Sep 17 00:00:00 2001 From: Felipe Leon Date: Sun, 6 Aug 2023 13:11:31 -0300 Subject: [PATCH] add 429 warning --- app/index.html | 1 - app/languages/0_Strings.js | 2 ++ app/languages/en_US.js | 4 ++++ app/languages/pt_BR.js | 5 +++++ app/specific/AddUser.js | 8 +++++++- app/specific/Screens.js | 3 +++ 6 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/index.html b/app/index.html index e4373c84e..2fb43594d 100644 --- a/app/index.html +++ b/app/index.html @@ -1505,7 +1505,6 @@ text-align: center; display: inline-block; filter: drop-shadow(0 0.05em 0.15em #000000) drop-shadow(0 0.05em 0.15em #000000); - word-break: break-all; white-space: normal; } diff --git a/app/languages/0_Strings.js b/app/languages/0_Strings.js index bc8894bd5..598f99f8c 100644 --- a/app/languages/0_Strings.js +++ b/app/languages/0_Strings.js @@ -756,3 +756,5 @@ var STR_BLOCK_OVERWRITE; var STR_BLOCK_SORT_DATE; var STR_BLOCK_SORT_NAME; var STR_BLOCK_EMPTY_CONTENT; +var STR_NO_TOKEN_WARNING; +var STR_NO_TOKEN_WARNING_429; diff --git a/app/languages/en_US.js b/app/languages/en_US.js index f4aa3edd8..be8c71b1f 100644 --- a/app/languages/en_US.js +++ b/app/languages/en_US.js @@ -863,4 +863,8 @@ function en_USLang() { STR_BLOCK_SORT_DATE = 'Sorted by blocked date'; STR_BLOCK_SORT_NAME = 'Sorted by name A to Z'; STR_BLOCK_EMPTY_CONTENT = 'There is no blocked content of this type'; + + STR_NO_TOKEN_WARNING = 'Without adding a user and authorization token the app, may fail to load the content, this is a Twitch API limitation'; + STR_NO_TOKEN_WARNING_429 = + 'The app is failing to load the content due to a Twitch API limitation, to fix this add a user and authorization token.'; } diff --git a/app/languages/pt_BR.js b/app/languages/pt_BR.js index 992e96d09..dc479ef9f 100644 --- a/app/languages/pt_BR.js +++ b/app/languages/pt_BR.js @@ -863,4 +863,9 @@ function pt_BRLang() { STR_BLOCK_SORT_DATE = 'Ordenado por data de bloqueio'; STR_BLOCK_SORT_NAME = 'Ordenado por nome de A a Z'; STR_BLOCK_EMPTY_CONTENT = 'Não há conteúdo bloqueado deste tipo'; + + STR_NO_TOKEN_WARNING = + 'Sem adicionar um usuário e token de autorização, o aplicativo pode falhar ao carregar o conteúdo, esta é uma limitação da API do Twitch'; + STR_NO_TOKEN_WARNING_429 = + 'O aplicativo está falhando ao carregar o conteúdo devido a uma limitação da API do Twitch, para corrigir isso, adicione um usuário e um token de autorização.'; } diff --git a/app/specific/AddUser.js b/app/specific/AddUser.js index 9a54e5690..fcc0b5c5e 100644 --- a/app/specific/AddUser.js +++ b/app/specific/AddUser.js @@ -196,7 +196,11 @@ function AddUser_RestoreUsers() { for (i; i < len; i++) { AddUser_UsernameArray[i].timeout_id = null; - if (AddUser_UsernameArray[i].access_token) AddCode_CheckTokenStart(i); + if (AddUser_UsernameArray[i].access_token) { + AddCode_CheckTokenStart(i); + } else if (!i) { + Main_showWarningDialog(STR_NO_TOKEN_WARNING, 5000); + } //Set user history obj Main_values_History_data[AddUser_UsernameArray[i].id] = { @@ -420,6 +424,8 @@ function AddUser_UserMakeOne(position) { if (AddUser_UsernameArray[0].access_token) { HttpGetSetUserHeader(); + } else { + Main_showWarningDialog(STR_NO_TOKEN_WARNING, 5000); } } diff --git a/app/specific/Screens.js b/app/specific/Screens.js index 7cc2ab33b..ce7cb76e8 100644 --- a/app/specific/Screens.js +++ b/app/specific/Screens.js @@ -429,6 +429,9 @@ function Screens_HttpResultStatus(resultObj, key) { if (ScreenObj[key].itemsCount && Main_ThumbOpenIsNull(ScreenObj[key].posY + 1 + '_0', ScreenObj[key].ids[0])) { Screens_addFocus(true, key); } + } else if (resultObj.status === 429 && !AddUser_UserHasToken()) { + Main_showWarningDialog(STR_NO_TOKEN_WARNING_429, 5000); + Screens_loadDataFail(key); } else if (resultObj.status === 401 || resultObj.status === 403) { //token expired