MM-29317 Select default team when current team is archived (#5295)
This commit is contained in:
parent
da8c09ff98
commit
e9d0fab8d1
4 changed files with 21 additions and 4 deletions
|
|
@ -52,7 +52,7 @@ export default class Post extends PureComponent {
|
|||
hasComments: PropTypes.bool,
|
||||
isSearchResult: PropTypes.bool,
|
||||
commentedOnPost: PropTypes.object,
|
||||
managedConfig: PropTypes.object.isRequired,
|
||||
managedConfig: PropTypes.object,
|
||||
onHashtagPress: PropTypes.func,
|
||||
onPermalinkPress: PropTypes.func,
|
||||
shouldRenderReplyButton: PropTypes.bool,
|
||||
|
|
|
|||
|
|
@ -132,6 +132,10 @@ export default class ChannelBase extends PureComponent {
|
|||
});
|
||||
}
|
||||
|
||||
if (prevProps.currentTeamId && !this.props.currentTeamId) {
|
||||
this.props.actions.selectDefaultTeam();
|
||||
}
|
||||
|
||||
if (this.props.currentTeamId &&
|
||||
(!this.props.currentChannelId || this.props.currentTeamId !== prevProps.currentTeamId)) {
|
||||
this.loadChannels(this.props.currentTeamId);
|
||||
|
|
|
|||
|
|
@ -106,4 +106,14 @@ describe('ChannelBase', () => {
|
|||
EventEmitter.emit(General.REMOVED_FROM_CHANNEL);
|
||||
expect(alert).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('should call selectDefault team when the current team is archived', () => {
|
||||
const wrapper = shallow(
|
||||
<ChannelBase {...baseProps}/>,
|
||||
{context: {intl: {formatMessage: jest.fn()}}},
|
||||
);
|
||||
|
||||
wrapper.setProps({currentTeamId: '', currentChannelId: ''});
|
||||
expect(baseProps.actions.selectDefaultTeam).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -36,14 +36,17 @@ function mapStateToProps(state) {
|
|||
);
|
||||
}
|
||||
|
||||
const currentTeamId = currentTeam?.delete_at === 0 ? currentTeam?.id : '';
|
||||
const currentChannelId = currentTeam?.delete_at === 0 ? getCurrentChannelId(state) : '';
|
||||
|
||||
return {
|
||||
currentTeamId: currentTeam?.id,
|
||||
currentChannelId: getCurrentChannelId(state),
|
||||
currentChannelId,
|
||||
currentTeamId,
|
||||
isSupportedServer,
|
||||
isSystemAdmin,
|
||||
showTermsOfService: shouldShowTermsOfService(state),
|
||||
teamName: currentTeam?.display_name,
|
||||
theme: getTheme(state),
|
||||
showTermsOfService: shouldShowTermsOfService(state),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue