MM-29317 Select default team when current team is archived (#5295)

This commit is contained in:
Elias Nahum 2021-04-08 20:32:23 -04:00 committed by GitHub
parent da8c09ff98
commit e9d0fab8d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 4 deletions

View file

@ -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,

View file

@ -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);

View file

@ -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);
});
});

View file

@ -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),
};
}