Fix jump to recent messages (#1834)

* Fix jump to recent messages

* force scroll to bottom when jumping to recent messages
This commit is contained in:
Elias Nahum 2018-06-27 08:13:21 -04:00 committed by Harrison Healey
parent ffd7c70d61
commit cd265fb7c2
2 changed files with 23 additions and 12 deletions

View file

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

View file

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