Creating the concept of RedirectChannel and use it before the DefaultChannel when we are redirecting the user (#2674)
* Creating the concept of RedirectChannel and use it before the DefaultChannel when we are redirecting the user * upgrading to the last mattermost-redux version
This commit is contained in:
parent
53d4d33a60
commit
c769b536ae
5 changed files with 18 additions and 18 deletions
|
|
@ -24,8 +24,14 @@ import {savePreferences} from 'mattermost-redux/actions/preferences';
|
|||
import {getTeamMembersByIds} from 'mattermost-redux/actions/teams';
|
||||
import {getProfilesInChannel} from 'mattermost-redux/actions/users';
|
||||
import {General, Preferences} from 'mattermost-redux/constants';
|
||||
import {getChannel, getCurrentChannelId, getMyChannelMember} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getPostIdsInChannel} from 'mattermost-redux/selectors/entities/posts';
|
||||
import {
|
||||
getChannel,
|
||||
getCurrentChannelId,
|
||||
getMyChannelMember,
|
||||
getRedirectChannelNameForTeam,
|
||||
getChannelByName as getChannelByNameSelector,
|
||||
} from 'mattermost-redux/selectors/entities/channels';
|
||||
import {getCurrentTeamId, getTeamByName} from 'mattermost-redux/selectors/entities/teams';
|
||||
|
||||
import {
|
||||
|
|
@ -330,16 +336,16 @@ export function selectPenultimateChannel(teamId) {
|
|||
|
||||
export function selectDefaultChannel(teamId) {
|
||||
return (dispatch, getState) => {
|
||||
const {channels} = getState().entities.channels;
|
||||
const state = getState();
|
||||
|
||||
const channel = Object.values(channels).find((c) => c.team_id === teamId && c.name === General.DEFAULT_CHANNEL);
|
||||
const channel = getChannelByNameSelector(state, getRedirectChannelNameForTeam(state, teamId));
|
||||
let channelId;
|
||||
if (channel) {
|
||||
channelId = channel.id;
|
||||
} else {
|
||||
// Handle case when the default channel cannot be found
|
||||
// so we need to get the first available channel of the team
|
||||
const channelsInTeam = Object.values(channels).filter((c) => c.team_id === teamId);
|
||||
const channelsInTeam = Object.values(state.entities.channels).filter((c) => c.team_id === teamId);
|
||||
const firstChannel = channelsInTeam.length ? channelsInTeam[0].id : {id: ''};
|
||||
|
||||
channelId = firstChannel.id;
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -9730,8 +9730,8 @@
|
|||
"integrity": "sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A=="
|
||||
},
|
||||
"mattermost-redux": {
|
||||
"version": "github:mattermost/mattermost-redux#29e65f58b0fb536e6923b270aa848208986f01ab",
|
||||
"from": "github:mattermost/mattermost-redux#29e65f58b0fb536e6923b270aa848208986f01ab",
|
||||
"version": "github:mattermost/mattermost-redux#477150436ac1871d0d63954c4f4f4d16ff692483",
|
||||
"from": "github:mattermost/mattermost-redux#477150436ac1871d0d63954c4f4f4d16ff692483",
|
||||
"requires": {
|
||||
"deep-equal": "1.0.1",
|
||||
"eslint-plugin-header": "3.0.0",
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
"intl": "1.2.5",
|
||||
"jail-monkey": "2.0.0",
|
||||
"jsc-android": "236355.1.1",
|
||||
"mattermost-redux": "github:mattermost/mattermost-redux#29e65f58b0fb536e6923b270aa848208986f01ab",
|
||||
"mattermost-redux": "github:mattermost/mattermost-redux#477150436ac1871d0d63954c4f4f4d16ff692483",
|
||||
"mime-db": "1.38.0",
|
||||
"moment-timezone": "0.5.23",
|
||||
"prop-types": "15.7.2",
|
||||
|
|
|
|||
|
|
@ -2,18 +2,20 @@
|
|||
// See LICENSE.txt for license information.
|
||||
|
||||
import {fetchMyChannelsAndMembers} from 'mattermost-redux/actions/channels';
|
||||
import {getRedirectChannelNameForTeam, getChannelByName} from 'mattermost-redux/selectors/entities/channels';
|
||||
|
||||
import {loadProfilesAndTeamMembersForDMSidebar} from 'app/actions/views/channel';
|
||||
import {ViewTypes} from 'app/constants';
|
||||
import {getDefaultChannelForTeam} from 'share_extension/common/selectors';
|
||||
|
||||
export function getTeamChannels(teamId) {
|
||||
return async (dispatch, getState) => {
|
||||
await dispatch(fetchMyChannelsAndMembers(teamId));
|
||||
dispatch(loadProfilesAndTeamMembersForDMSidebar(teamId));
|
||||
const defaultChannel = getDefaultChannelForTeam(getState(), teamId);
|
||||
|
||||
return defaultChannel.id;
|
||||
const state = getState();
|
||||
const redirectChannel = getChannelByName(state, getRedirectChannelNameForTeam(state, teamId));
|
||||
|
||||
return redirectChannel.id;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,14 +25,6 @@ import {
|
|||
} from 'mattermost-redux/utils/channel_utils';
|
||||
import {createIdsSelector} from 'mattermost-redux/utils/helpers';
|
||||
|
||||
export const getDefaultChannelForTeam = createSelector(
|
||||
getAllChannels,
|
||||
(state, teamId) => teamId,
|
||||
(channels, teamId) => {
|
||||
return Object.values(channels).find((c) => c.team_id === teamId && c.name === General.DEFAULT_CHANNEL);
|
||||
}
|
||||
);
|
||||
|
||||
export const getChannelIdsForExtensionTeam = createIdsSelector(
|
||||
(state) => state.views.extension.selectedTeamId,
|
||||
getChannelsInTeam,
|
||||
|
|
|
|||
Loading…
Reference in a new issue