mattermost-mobile/app/actions/views/root.js
Chris Duarte bffc75f8d1 RN-223 Emoji picker for adding new emoji reactions (#854)
* RN-223 Emoji picker for adding new emoji reactions

* Remove redundant setServerVersion and fetch custom emojis on reset

* Review feedback

* Review feedback 2

* Review feedback 3

* Review feedback 4

* Change aliases to array and add header to image source

* Remove aliases from custom emojis
2017-08-23 15:29:09 -03:00

88 lines
2.8 KiB
JavaScript

// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {ViewTypes} from 'app/constants';
import {
handleSelectChannel,
loadChannelsIfNecessary,
loadProfilesAndTeamMembersForDMSidebar,
setChannelDisplayName
} from 'app/actions/views/channel';
import {handleTeamChange, selectFirstAvailableTeam} from 'app/actions/views/select_team';
import {General} from 'mattermost-redux/constants';
import {getClientConfig, getLicenseConfig} from 'mattermost-redux/actions/general';
import {markChannelAsRead, viewChannel} from 'mattermost-redux/actions/channels';
export function loadConfigAndLicense() {
return async (dispatch, getState) => {
const [config, license] = await Promise.all([
getClientConfig()(dispatch, getState),
getLicenseConfig()(dispatch, getState)
]);
return {config, license};
};
}
export function queueNotification(notification) {
return async (dispatch, getState) => {
dispatch({type: ViewTypes.NOTIFICATION_CHANGED, data: notification}, getState);
};
}
export function clearNotification() {
return async (dispatch, getState) => {
dispatch({type: ViewTypes.NOTIFICATION_CHANGED, data: null}, getState);
};
}
export function goToNotification(notification) {
return async (dispatch, getState) => {
const state = getState();
const {data} = notification;
const {currentTeamId, teams} = state.entities.teams;
const {currentChannelId} = state.entities.channels;
const channelId = data.channel_id;
// if the notification does not have a team id is because its from a DM or GM
let teamId = data.team_id || currentTeamId;
dispatch(setChannelDisplayName(''));
if (teamId) {
handleTeamChange(teams[teamId], false)(dispatch, getState);
await loadChannelsIfNecessary(teamId)(dispatch, getState);
} else {
await selectFirstAvailableTeam()(dispatch, getState);
teamId = state.entities.team.currentTeamId;
}
viewChannel(channelId)(dispatch, getState);
loadProfilesAndTeamMembersForDMSidebar(teamId)(dispatch, getState);
if (channelId !== currentChannelId) {
handleSelectChannel(channelId)(dispatch, getState);
}
markChannelAsRead(channelId, currentChannelId)(dispatch, getState);
};
}
export function setStatusBarHeight(height = 20) {
return {
type: ViewTypes.STATUSBAR_HEIGHT_CHANGED,
data: height
};
}
export function purgeOfflineStore() {
return {type: General.OFFLINE_STORE_PURGE};
}
export default {
loadConfigAndLicense,
queueNotification,
clearNotification,
goToNotification,
setStatusBarHeight
};