From 5c8d1605bbfd80cd438cdf191d5a4eb87ba59bc9 Mon Sep 17 00:00:00 2001 From: 1aerostorm Date: Sat, 16 Dec 2023 02:08:00 +0000 Subject: [PATCH] Fix long title handling --- app/locales/en.json | 1 + app/locales/ru-RU.json | 1 + app/redux/TransactionSaga.js | 2 +- app/redux/Transaction_Error.js | 10 +++++++++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/locales/en.json b/app/locales/en.json index c8bd9ceb..63de8a9e 100644 --- a/app/locales/en.json +++ b/app/locales/en.json @@ -973,6 +973,7 @@ "chain_errors": { "only_comment_once_every": "You may only comment once every 20 seconds", "only_post_once_every": "You may only post once every 5 minutes", + "too_long_title": "Too long post title.", "exceeded_maximum_allowed_bandwidth": "Insufficient account bandwidth. Replenish the Golos Power or write to info@golos.id", "already_voted": "You have already voted in a similar way", "only_vote_once_every": "Can only vote once every 3 seconds", diff --git a/app/locales/ru-RU.json b/app/locales/ru-RU.json index 6ed16f13..93234a45 100644 --- a/app/locales/ru-RU.json +++ b/app/locales/ru-RU.json @@ -1036,6 +1036,7 @@ "chain_errors": { "only_comment_once_every": "Комментировать можно не чаще, чем раз в 20 секунд", "only_post_once_every": "Публиковать посты можно не чаще, чем раз в 5 минут", + "too_long_title": "Слишком длинный заголовок поста.", "exceeded_maximum_allowed_bandwidth": "Недостаточно пропускной способности аккаунта. Пополните Силу Голоса или напишите на info@golos.id", "already_voted": "Вы уже голосовали за этот пост", "only_vote_once_every": "Голосовать можно не чаще, чем раз в 3 секунды", diff --git a/app/redux/TransactionSaga.js b/app/redux/TransactionSaga.js index 5f6a4db8..def2644e 100644 --- a/app/redux/TransactionSaga.js +++ b/app/redux/TransactionSaga.js @@ -267,7 +267,7 @@ function* broadcastPayload({payload: {operations, keys, username, hideErrors, su yield new Promise((resolve, reject) => { broadcast.send({ extensions: [], operations }, keys, (err) => { if(err) { - console.error(err); + console.error(err) reject(err) } else { broadcastedEvent() diff --git a/app/redux/Transaction_Error.js b/app/redux/Transaction_Error.js index 8b32730b..9a3db86f 100644 --- a/app/redux/Transaction_Error.js +++ b/app/redux/Transaction_Error.js @@ -95,7 +95,11 @@ export default function transactionErrorReducer( const err_lines = error.message.split('\n'); if (err_lines.length > 2) { - errorKey = err_lines[1]; + if (error.message.includes('Title larger than size limit') && err_lines.length >= 4) { + errorKey = err_lines[3] + } else { + errorKey = err_lines[1] + } const txt = errorKey.split(': '); if (txt.length && txt[txt.length - 1].trim() !== '') { @@ -126,6 +130,10 @@ export default function transactionErrorReducer( errorKey.includes('You may only post once every 5 minutes') ) { errorKey = errorStr = tt('chain_errors.only_post_once_every'); + } else if ( + errorKey.includes('Title larger than size limit') + ) { + errorKey = errorStr = tt('chain_errors.too_long_title') } else if ( errorKey.includes( 'Account exceeded maximum allowed bandwidth per vesting share'