{"size": 1580, "ext": "js", "max_stars_repo_path": "src/selectorsOLD/CommonPageSelectors.js", "max_stars_repo_name": "schreiaj/the-blue-alliance-pwa-test", "max_stars_repo_stars_event_min_datetime": "2017-09-18T17:55:54.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-13T15:12:40.000Z", "max_issues_repo_path": "src/selectorsOLD/CommonPageSelectors.js", "max_issues_repo_name": "schreiaj/the-blue-alliance-pwa-test", "max_issues_repo_issues_event_min_datetime": "2017-09-23T02:46:30.000Z", "max_issues_repo_issues_event_max_datetime": "2018-05-16T02:28:00.000Z", "max_forks_repo_path": "src/selectorsOLD/CommonPageSelectors.js", "max_forks_repo_name": "schreiaj/the-blue-alliance-pwa-test", "max_forks_repo_forks_event_min_datetime": "2017-09-18T17:55:56.000Z", "max_forks_repo_forks_event_max_datetime": "2018-10-02T02:20:21.000Z"}
{"max_stars_count": 3, "max_issues_count": 2, "max_forks_count": 2, "avg_line_length": 27.2413793103, "max_line_length": 66, "alphanum_fraction": 0.7063291139}
import { createSelector } from 'reselect'
import { Map } from 'immutable';

// Pages
const getCurrentPageKey = (state, props) => {
  return state.getIn(['page', 'currentKey'])
}

const getCurrentModalKey = (state, props) => {
  return state.getIn(['page', 'currentModalKey'])
}

const getStateHistory = (state, props) => {
  return state.getIn(['page', 'stateHistory'])
}

const getScrollHistory = (state, props) => {
  return state.getIn(['page', 'scrollHistory'])
}

export const getCurrentPageState = createSelector(
  [getCurrentPageKey, getStateHistory],
  (pageKey, stateHistory) => {
    const pageState = stateHistory.get(pageKey)
    return pageState === undefined ? Map() : pageState
  }
)

export const getCurrentScrollStates = createSelector(
  [getCurrentPageKey, getCurrentModalKey, getScrollHistory],
  (pageKey, modalKey, scrollHistory) => {
    const pageScrollStates = scrollHistory.get(pageKey) || Map()
    const modalScrollStates = scrollHistory.get(modalKey) || Map()
    return pageScrollStates.merge(modalScrollStates)
  }
)

export const getYear = (state, props) => {
  if (props.year) {
    return props.year
  }
  const year = parseInt(props.match.params.year, 10)
  return year ? year : 2018
}

// Modals
const getStateHistoryModal = (state, props) => {
  return state.getIn(['page', 'stateHistoryModal'])
}

export const getCurrentModalState = createSelector(
  [getCurrentModalKey, getStateHistoryModal],
  (modalKey, stateHistory) => {
    const modalState = stateHistory.get(modalKey)
    return modalState === undefined ? Map() : modalState
  }
)
