From 981b3688f1912d5c8b41567f34687769a34c1b68 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Thu, 27 May 2021 14:27:24 -0300 Subject: [PATCH] [FIX] Team creation not raising error if something unexpected happens (#3152) * [IMPROVEMENT] Add error to AddExistingChannel * Fix the alert error when create a channel * Fix the error alert box when create channel and teams Co-authored-by: Diego Mello --- app/actions/createChannel.js | 5 +++-- app/i18n/locales/en.json | 1 + app/i18n/locales/pt-BR.json | 3 ++- app/sagas/createChannel.js | 8 ++++---- app/views/AddExistingChannelView.js | 2 ++ 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/actions/createChannel.js b/app/actions/createChannel.js index 60a8cca30..c93b47ef4 100644 --- a/app/actions/createChannel.js +++ b/app/actions/createChannel.js @@ -14,9 +14,10 @@ export function createChannelSuccess(data) { }; } -export function createChannelFailure(err) { +export function createChannelFailure(err, isTeam) { return { type: types.CREATE_CHANNEL.FAILURE, - err + err, + isTeam }; } diff --git a/app/i18n/locales/en.json b/app/i18n/locales/en.json index 71403821a..76d60f21f 100644 --- a/app/i18n/locales/en.json +++ b/app/i18n/locales/en.json @@ -61,6 +61,7 @@ "error-message-editing-blocked": "Message editing is blocked", "error-message-size-exceeded": "Message size exceeds Message_MaxAllowedSize", "error-missing-unsubscribe-link": "You must provide the [unsubscribe] link.", + "error-no-owner-channel":"You don't own the channel", "error-no-tokens-for-this-user": "There are no tokens for this user", "error-not-allowed": "Not allowed", "error-not-authorized": "Not authorized", diff --git a/app/i18n/locales/pt-BR.json b/app/i18n/locales/pt-BR.json index 64369e781..7eca8b049 100644 --- a/app/i18n/locales/pt-BR.json +++ b/app/i18n/locales/pt-BR.json @@ -667,5 +667,6 @@ "Teams": "Times", "No_team_channels_found": "Nenhum canal encontrado", "Team_not_found": "Time não encontrado", - "Private_Team": "Equipe Privada" + "Private_Team": "Equipe Privada", + "Add_Existing_Channel": "Adicionar Canal Existente" } \ No newline at end of file diff --git a/app/sagas/createChannel.js b/app/sagas/createChannel.js index 8979e230e..a768916c8 100644 --- a/app/sagas/createChannel.js +++ b/app/sagas/createChannel.js @@ -96,7 +96,7 @@ const handleRequest = function* handleRequest({ data }) { yield put(createChannelSuccess(sub)); } catch (err) { logEvent(events[data.group ? 'SELECTED_USERS_CREATE_GROUP_F' : 'CR_CREATE_F']); - yield put(createChannelFailure(err)); + yield put(createChannelFailure(err, data.isTeam)); } }; @@ -108,10 +108,10 @@ const handleSuccess = function* handleSuccess({ data }) { goRoom({ item: data, isMasterDetail }); }; -const handleFailure = function handleFailure({ err }) { +const handleFailure = function handleFailure({ err, isTeam }) { setTimeout(() => { - const msg = err.data ? I18n.t(err.data.error) : err.reason || I18n.t('There_was_an_error_while_action', { action: I18n.t('creating_channel') }); - showErrorAlert(msg); + const msg = err.data.errorType ? I18n.t(err.data.errorType, { room_name: err.data.details.channel_name }) : err.reason || I18n.t('There_was_an_error_while_action', { action: isTeam ? I18n.t('creating_team') : I18n.t('creating_channel') }); + showErrorAlert(msg, isTeam ? I18n.t('Create_Team') : I18n.t('Create_Channel')); }, 300); }; diff --git a/app/views/AddExistingChannelView.js b/app/views/AddExistingChannelView.js index 03cfaa4f1..c1c94fec8 100644 --- a/app/views/AddExistingChannelView.js +++ b/app/views/AddExistingChannelView.js @@ -20,6 +20,7 @@ import SafeAreaView from '../containers/SafeAreaView'; import Loading from '../containers/Loading'; import { animateNextTransition } from '../utils/layoutAnimation'; import { goRoom } from '../utils/goRoom'; +import { showErrorAlert } from '../utils/info'; import debounce from '../utils/debounce'; const QUERY_SIZE = 50; @@ -125,6 +126,7 @@ class AddExistingChannelView extends React.Component { goRoom({ item: result, isMasterDetail }); } } catch (e) { + showErrorAlert(I18n.t(e.data.error), I18n.t('Add_Existing_Channel'), () => {}); logEvent(events.CT_ADD_ROOM_TO_TEAM_F); this.setState({ loading: false }); }