mattermost-mobile/share_extension/android/actions/index.js
Elias Nahum 10d433cfab
Port WebSocket from mm-redux and batch actions (#4060)
* Port WebSocket from mm-redux and batch actions

* Update mm-redux and fix tests

* Change action name

* Naming batch actions

* Fix unit tests

* Dispatch connection change only if its different

* Remove comment

* Add Lint to TypeScript and fix linting errors

* Add WebSocket Unit Tests

* Revert from unwanted RN 0.62
2020-03-26 21:23:50 -03:00

28 lines
1 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {fetchMyChannelsAndMembers} from 'mattermost-redux/actions/channels';
import {getRedirectChannelNameForTeam, getChannelsNameMapInTeam} from 'mattermost-redux/selectors/entities/channels';
import {getChannelByName} from 'mattermost-redux/utils/channel_utils';
import {loadChannelsForTeam} from 'app/actions/views/channel';
import {ViewTypes} from 'app/constants';
export function getTeamChannels(teamId) {
return async (dispatch, getState) => {
await dispatch(loadChannelsForTeam(teamId));
const state = getState();
const channelsInTeam = getChannelsNameMapInTeam(state, teamId);
const redirectChannel = getChannelByName(channelsInTeam, getRedirectChannelNameForTeam(state, teamId));
return redirectChannel.id;
};
}
export function extensionSelectTeamId(teamId) {
return {
type: ViewTypes.EXTENSION_SELECTED_TEAM_ID,
data: teamId,
};
}