Save scroll state when swapping to non-room pages too

This commit is contained in:
Richard van der Hoff 2015-12-10 21:53:14 +00:00
parent d9782b35e1
commit b7699c0544

View file

@ -254,21 +254,15 @@ module.exports = React.createClass({
}); });
break; break;
case 'view_user_settings': case 'view_user_settings':
this.setState({ this._setPage(this.PageTypes.UserSettings);
page_type: this.PageTypes.UserSettings,
});
this.notifyNewScreen('settings'); this.notifyNewScreen('settings');
break; break;
case 'view_create_room': case 'view_create_room':
this.setState({ this._setPage(this.PageTypes.CreateRoom);
page_type: this.PageTypes.CreateRoom,
});
this.notifyNewScreen('new'); this.notifyNewScreen('new');
break; break;
case 'view_room_directory': case 'view_room_directory':
this.setState({ this._setPage(this.PageTypes.RoomDirectory);
page_type: this.PageTypes.RoomDirectory,
});
this.notifyNewScreen('directory'); this.notifyNewScreen('directory');
break; break;
case 'notifier_enabled': case 'notifier_enabled':
@ -297,6 +291,15 @@ module.exports = React.createClass({
} }
}, },
_setPage: function(pageType) {
// record the scroll state if we're in a room view.
this._updateScrollMap();
this.setState({
page_type: this.PageTypes.RoomDirectory,
});
},
_viewRoom: function(roomId) { _viewRoom: function(roomId) {
// before we switch room, record the scroll state of the current room // before we switch room, record the scroll state of the current room
this._updateScrollMap(); this._updateScrollMap();