MM-38331: fixes opening notification while in threads (#5664)

Opening a notification while in threads didn't pop the threads screen,
this commit fixes that.
This commit is contained in:
Kyriakos Z 2021-09-07 15:17:04 +03:00 committed by GitHub
parent 69a65067c3
commit 308637be32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 2 deletions

View file

@ -97,6 +97,7 @@ export function loadFromPushNotification(notification, isInitialNotification) {
}
dispatch(handleSelectTeamAndChannel(teamId, channelId));
dispatch(selectPost(''));
const {root_id: rootId} = notification.payload || {};
if (isCollapsedThreadsEnabled(state) && rootId) {

View file

@ -37,6 +37,7 @@ export default class ChannelBase extends PureComponent {
showTermsOfService: PropTypes.bool,
skipMetrics: PropTypes.bool,
viewingGlobalThreads: PropTypes.bool,
collapsedThreadsEnabled: PropTypes.bool.isRequired,
selectedPost: PropTypes.shape({
id: PropTypes.string.isRequired,
channel_id: PropTypes.string.isRequired,
@ -199,7 +200,7 @@ export default class ChannelBase extends PureComponent {
loadChannels = (teamId) => {
const {loadChannelsForTeam, selectInitialChannel} = this.props.actions;
if (EphemeralStore.getStartFromNotification()) {
if (this.props.selectedPost) {
if (this.props.selectedPost && this.props.collapsedThreadsEnabled) {
EventEmitter.emit('goToThread', this.props.selectedPost);
}
// eslint-disable-next-line no-console

View file

@ -26,6 +26,7 @@ describe('ChannelBase', () => {
},
componentId: channelBaseComponentId,
theme: Preferences.THEMES.denim,
collapsedThreadsEnabled: false,
};
const optionsForTheme = (theme) => {
return {

View file

@ -40,6 +40,7 @@ function mapStateToProps(state) {
const currentTeamId = currentTeam?.delete_at === 0 ? currentTeam?.id : '';
const currentChannelId = currentTeam?.delete_at === 0 ? getCurrentChannelId(state) : '';
const collapsedThreadsEnabled = isCollapsedThreadsEnabled(state);
return {
currentChannelId,
@ -48,10 +49,11 @@ function mapStateToProps(state) {
isSupportedServer,
isSystemAdmin,
selectedPost: getSelectedPost(state),
collapsedThreadsEnabled,
showTermsOfService: shouldShowTermsOfService(state),
teamName: currentTeam?.display_name,
theme: getTheme(state),
viewingGlobalThreads: isCollapsedThreadsEnabled(state) && getViewingGlobalThreads(state),
viewingGlobalThreads: collapsedThreadsEnabled && getViewingGlobalThreads(state),
};
}