diff --git a/app/components/post_list/post_list.js b/app/components/post_list/post_list.js index d5d3bd502..178f91bd3 100644 --- a/app/components/post_list/post_list.js +++ b/app/components/post_list/post_list.js @@ -10,6 +10,8 @@ import { StyleSheet, } from 'react-native'; +import EventEmitter from 'mattermost-redux/utils/event_emitter'; + import Post from 'app/components/post'; import {DATE_LINE, START_OF_NEW_MESSAGES} from 'app/selectors/post_list'; import mattermostManaged from 'app/mattermost_managed'; @@ -77,6 +79,7 @@ export default class PostList extends PureComponent { } componentDidMount() { + EventEmitter.on('reset_channel', this.scrollToBottomOffset); this.setManagedConfig(); } @@ -98,6 +101,7 @@ export default class PostList extends PureComponent { } componentWillUnmount() { + EventEmitter.off('reset_channel', this.scrollToBottomOffset); mattermostManaged.removeEventListener(this.listenerId); } diff --git a/app/screens/permalink/permalink.js b/app/screens/permalink/permalink.js index 88963a3e2..d33686252 100644 --- a/app/screens/permalink/permalink.js +++ b/app/screens/permalink/permalink.js @@ -14,6 +14,7 @@ import * as Animatable from 'react-native-animatable'; import MaterialIcon from 'react-native-vector-icons/MaterialIcons'; import {General} from 'mattermost-redux/constants'; +import EventEmitter from 'mattermost-redux/utils/event_emitter'; import FormattedText from 'app/components/formatted_text'; import Loading from 'app/components/loading'; @@ -200,22 +201,28 @@ export default class Permalink extends PureComponent { actions.selectPost(''); + if (channelId === currentChannelId) { + EventEmitter.emit('reset_channel'); + } else { + navigator.resetTo({ + screen: 'Channel', + animated: true, + animationType: 'fade', + navigatorStyle: { + navBarHidden: true, + statusBarHidden: false, + statusBarHideWithNavBar: false, + screenBackgroundColor: theme.centerChannelBg, + }, + }); + } + + navigator.dismissAllModals({animationType: 'slide-down'}); + if (onClose) { onClose(); } - navigator.resetTo({ - screen: 'Channel', - animated: true, - animationType: 'fade', - navigatorStyle: { - navBarHidden: true, - statusBarHidden: false, - statusBarHideWithNavBar: false, - screenBackgroundColor: theme.centerChannelBg, - }, - }); - if (channelTeamId && currentTeamId !== channelTeamId) { handleTeamChange(channelTeamId, false); }