From 9f587750eb9bb0fa08dccb0745f8718d7555ccb0 Mon Sep 17 00:00:00 2001 From: Niko Date: Mon, 21 Feb 2022 22:27:28 +0100 Subject: [PATCH] Added a "app.warn" ns in locales for warning messages instead of all error --- api/src/api/accounts.js | 2 +- web/src/app/js/pages/meet.js | 8 ++++++-- web/src/config/lang/en.php | 8 +++++--- web/src/config/lang/es.php | 8 +++++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/api/src/api/accounts.js b/api/src/api/accounts.js index 0f9c023..fbeb43d 100644 --- a/api/src/api/accounts.js +++ b/api/src/api/accounts.js @@ -174,7 +174,7 @@ module.exports = { const follow = await httpGetValidFollow(req, res) if (follow !== null) { if (follow.accepted) - return res.json({ error: 'already_following' }) + return res.json({ warn: 'already_following' }) return res.json({ error: 'follow_pending' }) } diff --git a/web/src/app/js/pages/meet.js b/web/src/app/js/pages/meet.js index 32b7e36..e863295 100644 --- a/web/src/app/js/pages/meet.js +++ b/web/src/app/js/pages/meet.js @@ -165,7 +165,9 @@ app.pages.meet = { return app.toast.error(s('app.error.unknown_error')); http.post(`/api/v1/accounts/follow?url=${current.account.url}`, {}, function(json) { if (json === undefined) return; - if (json.error !== undefined) + if (json.warn !== undefined) + app.toast.warn(app.strings.app.warn[json.warn]); + else if (json.error !== undefined) app.toast.error(app.strings.app.error[json.error]); else if (json.result !== undefined && json.result === 1) { const n = randomNum(0, 3); @@ -180,7 +182,9 @@ app.pages.meet = { return app.toast.error(s('app.error.unknown_error')); http.post(`/api/v1/accounts/block?url=${current.account.url}`, {}, function(json) { if (json === undefined) return; - if (json.error !== undefined) + if (json.warn !== undefined) + app.toast.warn(app.strings.app.warn[json.warn]); + else if (json.error !== undefined) app.toast.error(app.strings.app.error[json.error]); else if (json.result !== undefined && json.result === 1) { const n = randomNum(0, 3); diff --git a/web/src/config/lang/en.php b/web/src/config/lang/en.php index 7ad621d..e1fa226 100644 --- a/web/src/config/lang/en.php +++ b/web/src/config/lang/en.php @@ -27,12 +27,14 @@ $strings = [ 'discarded_success_2' => 'Maybe other person like you, but not me', 'discarded_success_3' => 'You\'ll find someone, but it won\'t be me', ], + 'warn' => [ + 'already_following' => 'This person has already accepted being your crush', + ], 'error' => [ 'unknown_error' => 'We are sorry, an unknown error has ocurred.', - 'already_following' => 'This person is your Crush already', - 'follow_pending' => 'Your Crush didn\'t accept you as a crush yet', + 'follow_pending' => 'This person has not yet accepted to be your crush', 'follow_rejected_max' => 'You have reached the limit of crush requests on this person', - 'user_blocked_you' => 'We are sorry, this person rejected your crush request. You will find another person for sure!', + 'user_blocked_you' => 'We are sorry, this person rejected to be your crush. You will find another love soon!', ], ], ]; diff --git a/web/src/config/lang/es.php b/web/src/config/lang/es.php index 1a8df95..b5072ef 100644 --- a/web/src/config/lang/es.php +++ b/web/src/config/lang/es.php @@ -27,12 +27,14 @@ $strings = [ 'discarded_success_2' => 'Quizás le guste a otra persona, pero a mi no', 'discarded_success_3' => 'Encontrarás a alguien, pero no seré yo', ], + 'warn' => [ + 'already_following' => 'Esta persona ya te ha aceptado como su crush', + ], 'error' => [ 'unknown_error' => 'Lo sentimos, ha ocurrido un error inesperado.', - 'already_following' => 'Esta persona ya es tu Crush', - 'follow_pending' => 'Tu Crush todavía no te considera un crush', + 'follow_pending' => 'Esta persona todavía no ha aceptado ser tu crush', 'follow_rejected_max' => 'Has alcanzado el límite de peticiones de crush para esta persona', - 'user_blocked_you' => 'Lo sentimos, esta persona ha rechazado tu petición de crush. ¡Encontrarás a otra persona seguro!', + 'user_blocked_you' => 'Lo sentimos, esta persona ha rechazado ser su crush. ¡Encontrarás a otra persona pronto!', ], ], ];