Unverified Commit 981b3688 authored by Reinaldo Neto's avatar Reinaldo Neto Committed by GitHub
Browse files

[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: default avatarDiego Mello <diegolmello@gmail.com>
parent 0bbeb422
......@@ -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
};
}
......@@ -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",
......
......@@ -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
......@@ -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);
};
......
......@@ -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 });
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment