Various updates to match latest mattermost-redux (#6794)

Этот коммит содержится в:
Joram Wilander
2017-06-29 10:03:57 -04:00
коммит произвёл enahum
родитель bef07fc53e
Коммит 3cd8057d28
2 изменённых файлов: 29 добавлений и 37 удалений

Просмотреть файл

@@ -164,14 +164,12 @@ export function openDirectChannelToUser(userId, success, error) {
} }
ChannelActions.createDirectChannel(UserStore.getCurrentId(), userId)(dispatch, getState).then( ChannelActions.createDirectChannel(UserStore.getCurrentId(), userId)(dispatch, getState).then(
(data) => { (result) => {
loadProfilesForSidebar(); loadProfilesForSidebar();
if (data && success) { if (result.data && success) {
success(data, false); success(result.data, false);
} else if (data == null && error) { } else if (result.error && error) {
browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/' + channelName); error({id: result.error.server_error_id, ...result.error});
const serverError = getState().requests.channels.createChannel.error;
error({id: serverError.server_error_id, ...serverError});
} }
} }
); );
@@ -237,17 +235,14 @@ export function loadDMsAndGMsForUnreads() {
} }
} }
export function joinChannel(channel, success, error) { export async function joinChannel(channel, success, error) {
ChannelActions.joinChannel(UserStore.getCurrentId(), null, channel.id)(dispatch, getState).then( const {data, serverError} = await ChannelActions.joinChannel(UserStore.getCurrentId(), null, channel.id)(dispatch, getState);
(data) => {
if (data && success) { if (data && success) {
success(data); success(data);
} else if (data == null && error) { } else if (data == null && error) {
const serverError = getState().requests.channels.joinChannel.error; error({id: serverError.server_error_id, ...serverError});
error({id: serverError.server_error_id, ...serverError}); }
}
}
);
} }
export function updateChannel(channel, success, error) { export function updateChannel(channel, success, error) {
@@ -373,15 +368,12 @@ export function leaveChannel(channelId, success) {
); );
} }
export function deleteChannel(channelId, success, error) { export async function deleteChannel(channelId, success, error) {
ChannelActions.deleteChannel(channelId)(dispatch, getState).then( const {data, serverError} = await ChannelActions.deleteChannel(channelId)(dispatch, getState);
(data) => {
if (data && success) { if (data && success) {
success(data); success(data);
} else if (data == null && error) { } else if (serverError && error) {
const serverError = getState().requests.channels.members.error; error({id: serverError.server_error_id, ...serverError});
error({id: serverError.server_error_id, ...serverError}); }
}
}
);
} }

Просмотреть файл

@@ -51,10 +51,10 @@ function doChannelChange(state, replace, callback) {
if (!channel) { if (!channel) {
joinChannel(UserStore.getCurrentId(), TeamStore.getCurrentId(), null, state.params.channel)(dispatch, getState).then( joinChannel(UserStore.getCurrentId(), TeamStore.getCurrentId(), null, state.params.channel)(dispatch, getState).then(
(data) => { (result) => {
if (data) { if (result.data) {
GlobalActions.emitChannelClickEvent(data.channel); GlobalActions.emitChannelClickEvent(result.data.channel);
} else if (data == null) { } else if (result.error) {
if (state.params.team) { if (state.params.team) {
replace('/' + state.params.team + '/channels/town-square'); replace('/' + state.params.team + '/channels/town-square');
} else { } else {
@@ -192,11 +192,11 @@ function onChannelByIdentifierEnter(state, replace, callback) {
callback(); callback();
} else { } else {
joinChannel(UserStore.getCurrentId(), TeamStore.getCurrentId(), null, identifier)(dispatch, getState).then( joinChannel(UserStore.getCurrentId(), TeamStore.getCurrentId(), null, identifier)(dispatch, getState).then(
(data) => { (result) => {
if (data) { if (result.data) {
GlobalActions.emitChannelClickEvent(data.channel); GlobalActions.emitChannelClickEvent(result.data.channel);
callback(); callback();
} else if (data == null) { } else if (result.error) {
handleError(state, replace, callback); handleError(state, replace, callback);
} }
} }