diff options
Diffstat (limited to 'webapp/actions')
-rw-r--r-- | webapp/actions/global_actions.jsx | 18 | ||||
-rw-r--r-- | webapp/actions/team_actions.jsx | 23 | ||||
-rw-r--r-- | webapp/actions/user_actions.jsx | 9 | ||||
-rw-r--r-- | webapp/actions/websocket_actions.jsx | 28 |
4 files changed, 71 insertions, 7 deletions
diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx index ed434fdc7..3c88a7013 100644 --- a/webapp/actions/global_actions.jsx +++ b/webapp/actions/global_actions.jsx @@ -58,7 +58,7 @@ export function emitChannelClickEvent(channel) { getMyChannelMemberPromise.then(() => { getChannelStats(chan.id)(dispatch, getState); - viewChannel(chan.id)(dispatch, getState); + viewChannel(chan.id, oldChannelId)(dispatch, getState); loadPosts(chan.id); // Mark previous and next channel as read @@ -379,7 +379,7 @@ export function newLocalizationSelected(locale) { translations: en }); } else { - const localeInfo = I18n.getLanguageInfo(locale) || I18n.getLanguageInfo(global.window.mm_config.DefaultClientLocale); + const localeInfo = I18n.getLanguageInfo(locale); Client.getTranslations( localeInfo.url, @@ -401,13 +401,23 @@ export function newLocalizationSelected(locale) { } } +export function loadCurrentLocale() { + const user = UserStore.getCurrentUser(); + + if (user && user.locale) { + newLocalizationSelected(user.locale); + } else { + loadDefaultLocale(); + } +} + export function loadDefaultLocale() { - const defaultLocale = global.window.mm_config.DefaultClientLocale; - let locale = global.window.mm_user ? global.window.mm_user.locale || defaultLocale : defaultLocale; + let locale = global.window.mm_config.DefaultClientLocale; if (!I18n.getLanguageInfo(locale)) { locale = 'en'; } + return newLocalizationSelected(locale); } diff --git a/webapp/actions/team_actions.jsx b/webapp/actions/team_actions.jsx index 44b554ded..6407e1b12 100644 --- a/webapp/actions/team_actions.jsx +++ b/webapp/actions/team_actions.jsx @@ -28,6 +28,9 @@ import { getTeamMembersForUser as getTeamMembersForUserRedux } from 'mattermost-redux/actions/teams'; +import {TeamTypes} from 'mattermost-redux/action_types'; +import {batchActions} from 'redux-batched-actions'; + export function checkIfTeamExists(teamName, onSuccess, onError) { checkIfTeamExistsRedux(teamName)(dispatch, getState).then( (exists) => { @@ -104,6 +107,26 @@ export function addUserToTeamFromInvite(data, hash, inviteId, success, error) { hash, inviteId, (team) => { + const member = { + team_id: team.id, + user_id: getState().entities.users.currentUserId, + roles: 'team_user', + delete_at: 0, + msg_count: 0, + mention_count: 0 + }; + + dispatch(batchActions([ + { + type: TeamTypes.RECEIVED_TEAMS_LIST, + data: [team] + }, + { + type: TeamTypes.RECEIVED_MY_TEAM_MEMBER, + data: member + } + ])); + if (success) { success(team); } diff --git a/webapp/actions/user_actions.jsx b/webapp/actions/user_actions.jsx index 377a11020..c8d848555 100644 --- a/webapp/actions/user_actions.jsx +++ b/webapp/actions/user_actions.jsx @@ -9,6 +9,7 @@ import UserStore from 'stores/user_store.jsx'; import ChannelStore from 'stores/channel_store.jsx'; import {getChannelMembersForUserIds} from 'actions/channel_actions.jsx'; +import {loadCurrentLocale} from 'actions/global_actions.jsx'; import {loadStatusesForProfilesList, loadStatusesForProfilesMap} from 'actions/status_actions.jsx'; import {getDirectChannelName, getUserIdFromChannelName} from 'utils/utils.jsx'; @@ -51,6 +52,8 @@ import {getTeamMembersByIds, getMyTeamMembers} from 'mattermost-redux/actions/te export function loadMe(callback) { loadMeRedux()(dispatch, getState).then( () => { + loadCurrentLocale(); + if (callback) { callback(); } @@ -742,6 +745,12 @@ export function webLogin(loginId, password, token, success, error) { success(); } else if (!ok && error) { const serverError = getState().requests.users.login.error; + if (serverError.server_error_id === 'api.context.mfa_required.app_error') { + if (success) { + success(); + } + return; + } error({id: serverError.server_error_id, ...serverError}); } } diff --git a/webapp/actions/websocket_actions.jsx b/webapp/actions/websocket_actions.jsx index 4d2b5a2b5..b7a0b12a8 100644 --- a/webapp/actions/websocket_actions.jsx +++ b/webapp/actions/websocket_actions.jsx @@ -34,9 +34,10 @@ import {browserHistory} from 'react-router/es6'; import store from 'stores/redux_store.jsx'; const dispatch = store.dispatch; const getState = store.getState; +import {batchActions} from 'redux-batched-actions'; import {viewChannel, getChannelAndMyMember, getChannelStats} from 'mattermost-redux/actions/channels'; import {setServerVersion} from 'mattermost-redux/actions/general'; -import {ChannelTypes} from 'mattermost-redux/action_types'; +import {ChannelTypes, TeamTypes, UserTypes} from 'mattermost-redux/action_types'; const MAX_WEBSOCKET_FAILS = 7; @@ -237,7 +238,9 @@ function handleNewPostEvent(msg) { posts[post.id] = post; loadProfilesForPosts(posts); - UserStore.setStatus(post.user_id, UserStatuses.ONLINE); + if (post.user_id !== UserStore.getCurrentId()) { + UserStore.setStatus(post.user_id, UserStatuses.ONLINE); + } } function handlePostEditEvent(msg) { @@ -294,6 +297,18 @@ function handleLeaveTeamEvent(msg) { GlobalActions.redirectUserToDefaultTeam(); } } + + dispatch(batchActions([ + { + type: UserTypes.RECEIVED_PROFILE_NOT_IN_TEAM, + data: {user_id: msg.data.user_id}, + id: msg.data.team_id + }, + { + type: TeamTypes.REMOVE_MEMBER_FROM_TEAM, + data: {team_id: msg.data.team_id, user_id: msg.data.user_id} + } + ])); } else { UserStore.removeProfileFromTeam(msg.data.team_id, msg.data.user_id); TeamStore.removeMemberInTeam(msg.data.team_id, msg.data.user_id); @@ -334,6 +349,11 @@ function handleUserRemovedEvent(msg) { BrowserStore.setItem('channel-removed-state', sentState); $('#removed_from_channel').modal('show'); } + + dispatch({ + type: ChannelTypes.LEAVE_CHANNEL, + data: {id: msg.data.channel_id, user_id: msg.broadcast.user_id} + }); } else if (ChannelStore.getCurrentId() === msg.broadcast.channel_id) { getChannelStats(ChannelStore.getCurrentId())(dispatch, getState); } @@ -382,7 +402,9 @@ function handlePreferencesDeletedEvent(msg) { function handleUserTypingEvent(msg) { GlobalActions.emitRemoteUserTypingEvent(msg.broadcast.channel_id, msg.data.user_id, msg.data.parent_id); - UserStore.setStatus(msg.data.user_id, UserStatuses.ONLINE); + if (msg.data.user_id !== UserStore.getCurrentId()) { + UserStore.setStatus(msg.data.user_id, UserStatuses.ONLINE); + } } function handleStatusChangedEvent(msg) { |