Skip to content

Commit

Permalink
refactor: use ms prefix for reselect memoized selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikThePendric committed Feb 5, 2025
1 parent 11e1932 commit e8e4440
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/components/DashboardsBar/InformationBlock/ActionsBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { itemTypeSupportsFullscreen } from '../../../modules/itemTypes.js'
import { useCacheableSection } from '../../../modules/useCacheableSection.js'
import { orObject } from '../../../modules/util.js'
import { ROUTE_START_PATH } from '../../../pages/start/index.js'
import { sGetNamedItemFilters } from '../../../reducers/itemFilters.js'
import { msGetNamedItemFilters } from '../../../reducers/itemFilters.js'
import {
sGetSelected,
sGetSelectedIsEmbedded,
Expand Down Expand Up @@ -347,7 +347,7 @@ const mapStateToProps = (state) => {
return {
...dashboard,
embedded: sGetSelectedIsEmbedded(state),
filtersLength: sGetNamedItemFilters(state).length,
filtersLength: msGetNamedItemFilters(state).length,
showDescription: sGetShowDescription(state),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Item/PrintTitlePageItem/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import React from 'react'
import { connect } from 'react-redux'
import { sGetIsEditing } from '../../../reducers/editDashboard.js'
import { sGetNamedItemFilters } from '../../../reducers/itemFilters.js'
import { msGetNamedItemFilters } from '../../../reducers/itemFilters.js'
import {
sGetPrintDashboardName,
sGetPrintDashboardDescription,
Expand Down Expand Up @@ -76,7 +76,7 @@ const mapStateToProps = (state) => {
return {
name,
description,
itemFilters: sGetNamedItemFilters(state),
itemFilters: msGetNamedItemFilters(state),
showDescription: sGetShowDescription(state),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/view/FilterBar/FilterBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
acClearItemFilters,
} from '../../../actions/itemFilters.js'
import ConfirmActionDialog from '../../../components/ConfirmActionDialog.js'
import { sGetNamedItemFilters } from '../../../reducers/itemFilters.js'
import { msGetNamedItemFilters } from '../../../reducers/itemFilters.js'
import FilterBadge from './FilterBadge.js'
import classes from './styles/FilterBar.module.css'

Expand Down Expand Up @@ -63,7 +63,7 @@ FilterBar.defaultProps = {
}

const mapStateToProps = (state) => ({
filters: sGetNamedItemFilters(state),
filters: msGetNamedItemFilters(state),
})

export default connect(mapStateToProps, {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/view/SlideshowFiltersInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Layer, Popper, IconFilter16 } from '@dhis2/ui'
import PropTypes from 'prop-types'
import React, { useMemo, useState, useRef } from 'react'
import { useSelector } from 'react-redux'
import { sGetNamedItemFilters } from '../../reducers/itemFilters.js'
import { msGetNamedItemFilters } from '../../reducers/itemFilters.js'
import styles from './styles/SlideshowFiltersInfo.module.css'

const popperModifiers = [
Expand Down Expand Up @@ -35,7 +35,7 @@ FilterSection.propTypes = {
export const SlideshowFiltersInfo = () => {
const [isOpen, setIsOpen] = useState(false)
const ref = useRef(null)
const filters = useSelector(sGetNamedItemFilters)
const filters = useSelector(msGetNamedItemFilters)
const totalFilterCount = useMemo(
() =>
filters.reduce((total, filter) => total + filter.values.length, 0),
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/itemFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const sGetItemFiltersRoot = (state) => state.itemFilters

// simplify the filters structure to:
// [{ id: 'pe', name: 'Period', values: [{ id: 2019: name: '2019' }, {id: 'LAST_MONTH', name: 'Last month' }]}, ...]
export const sGetNamedItemFilters = createSelector(
export const msGetNamedItemFilters = createSelector(
[sGetItemFiltersRoot, sGetDimensions],
(filters, dimensions) =>
Object.keys(filters).reduce((arr, id) => {
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/selected.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const sGetSelectedSupersetEmbedData = (state) => {
},
}
}
export const mGetSelectedSupersetEmbedData = createSelector(
export const msGetSelectedSupersetEmbedData = createSelector(
[
(state) => state.selected?.embedded.id,
(state) => state.selected?.embedded.options.hideChartControls,
Expand Down

0 comments on commit e8e4440

Please sign in to comment.