so much discovery I can't take it #2617

Merged
neb-b merged 20 commits from fixes into master 2019-07-23 01:45:30 +02:00
4 changed files with 10 additions and 4 deletions
Showing only changes of commit 0b841bf268 - Show all commits

View file

@ -1,10 +1,9 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectScrollStartingPosition } from 'redux/selectors/app';
import Router from './view'; import Router from './view';
const select = state => ({ const select = state => ({
scroll: state.app.scrollHistory[state.app.scrollHistory.length - 1], currentScroll: selectScrollStartingPosition(state),
scrollHistory: state.app.scrollHistory,
currentScroll: state.app.currentScroll || 0,
}); });
export default connect(select)(Router); export default connect(select)(Router);

View file

@ -22,7 +22,7 @@ import NavigationHistory from 'page/navigationHistory';
import TagsPage from 'page/tags'; import TagsPage from 'page/tags';
import FollowingPage from 'page/following'; import FollowingPage from 'page/following';
// Let app handle scroll // Tell the browser we are handling scroll restoration
if ('scrollRestoration' in history) { if ('scrollRestoration' in history) {
history.scrollRestoration = 'manual'; history.scrollRestoration = 'manual';
} }

View file

@ -67,6 +67,8 @@ const defaultState: AppState = {
scrollHistory: [0], scrollHistory: [0],
}; };
// @@router comes from react-router
// This action is dispatched any time a user navigates forward or back
reducers['@@router/LOCATION_CHANGE'] = (state, action) => { reducers['@@router/LOCATION_CHANGE'] = (state, action) => {
const { currentScroll } = state; const { currentScroll } = state;
const scrollHistory = state.scrollHistory.slice(); const scrollHistory = state.scrollHistory.slice();

View file

@ -123,3 +123,8 @@ export const selectSearchOptionsExpanded = createSelector(
selectState, selectState,
state => state.searchOptionsExpanded state => state.searchOptionsExpanded
); );
export const selectScrollStartingPosition = createSelector(
selectState,
state => state.currentScroll
);