diff --git a/src/components/AllApps.tsx b/src/components/AllApps.tsx index f3a067b..e2661c6 100644 --- a/src/components/AllApps.tsx +++ b/src/components/AllApps.tsx @@ -5,13 +5,13 @@ import { useSelector } from 'react-redux' import { BACKGROUND_COLOR } from '../constants' import { AppDetails } from '../models/app-details' import { RenderedIn } from '../models/rendered-in' -import { selectAppsListMemoized } from '../slices/appsList' +import { selectAppsList } from '../slices/appsList' import { getListItemLayout, getListKey } from '../utils/apps' import AllAppsLetterIndex from './AllAppsLetterIndex' import AppItem from './AppItem' const AllApps = () => { - const apps = useSelector(selectAppsListMemoized) + const apps = useSelector(selectAppsList) const listRef: MutableRefObject | null> = useRef(null) const scrollToIndex = useCallback( diff --git a/src/components/AppItemMenu.tsx b/src/components/AppItemMenu.tsx index e912d78..42ec5dc 100644 --- a/src/components/AppItemMenu.tsx +++ b/src/components/AppItemMenu.tsx @@ -11,22 +11,12 @@ import { } from '../constants' import SearchContext from '../contexts/SearchContext' import { resetAppsSearchState, selectDisplayAppMenu, selectMenuAppDetails, setDisplayAppMenu } from '../slices/appState' +import { addFavoriteApp, removeFavoriteApp, selectFavoriteApps, selectFavoriteAppsCount } from '../slices/favoriteApps' +import { addPinnedApp, removePinnedApp, selectPinnedApps, selectTemporaryPinnedApps } from '../slices/pinnedApps' import { - addFavoriteApp, - removeFavoriteApp, - selectFavoriteAppsCountMemoized, - selectFavoriteAppsMemoized, -} from '../slices/favoriteApps' -import { - addPinnedApp, - removePinnedApp, - selectPinnedAppsMemoized, - selectTemporaryPinnedAppsMemoized, -} from '../slices/pinnedApps' -import { - selectDisplayFavoriteAppsMemoized, - selectDisplayPinnedAppsMemoized, - selectDisplayTemporaryPinnedAppsMemoized, + selectDisplayFavoriteApps, + selectDisplayPinnedApps, + selectDisplayTemporaryPinnedApps, } from '../slices/preferences' import { getAppIndex } from '../utils/apps' import { requestAppUninstall, showAppDetails } from '../utils/apps-module' @@ -38,13 +28,13 @@ const AppItemMenu = () => { const [isFavoriteApp, setIsFavoriteApp] = useState(false) const [isPinnedApp, setIsPinnedApp] = useState(false) const [isTemporarilyPinnedApp, setIsTemporarilyPinnedApp] = useState(false) - const favoriteApps = useSelector(selectFavoriteAppsMemoized) - const pinnedApps = useSelector(selectPinnedAppsMemoized) - const temporaryPinnedApps = useSelector(selectTemporaryPinnedAppsMemoized) - const favoriteAppsCount = useSelector(selectFavoriteAppsCountMemoized) - const displayFavoriteAppsValue = useSelector(selectDisplayFavoriteAppsMemoized) - const displayPinnedAppsValue = useSelector(selectDisplayPinnedAppsMemoized) - const displayTemporaryPinnedApps = useSelector(selectDisplayTemporaryPinnedAppsMemoized) + const favoriteApps = useSelector(selectFavoriteApps) + const pinnedApps = useSelector(selectPinnedApps) + const temporaryPinnedApps = useSelector(selectTemporaryPinnedApps) + const favoriteAppsCount = useSelector(selectFavoriteAppsCount) + const displayFavoriteAppsValue = useSelector(selectDisplayFavoriteApps) + const displayPinnedAppsValue = useSelector(selectDisplayPinnedApps) + const displayTemporaryPinnedApps = useSelector(selectDisplayTemporaryPinnedApps) const { clearAndBlurSearchInput } = useContext(SearchContext) const appDetails = useSelector(selectMenuAppDetails) diff --git a/src/components/FavoriteApps.tsx b/src/components/FavoriteApps.tsx index d31e1fe..3a499fc 100644 --- a/src/components/FavoriteApps.tsx +++ b/src/components/FavoriteApps.tsx @@ -10,11 +10,11 @@ import { sectionWrapper, whiteTextColorStyle, } from '../shared/styles' -import { selectFavoriteAppsMemoized } from '../slices/favoriteApps' +import { selectFavoriteApps } from '../slices/favoriteApps' import AppItem from './AppItem' const FavoriteApps = () => { - const apps = useSelector(selectFavoriteAppsMemoized) + const apps = useSelector(selectFavoriteApps) const noAppsFound = useMemo(() => apps.length === 0, [apps]) diff --git a/src/components/PinnedApps.tsx b/src/components/PinnedApps.tsx index 0183591..24b0d66 100644 --- a/src/components/PinnedApps.tsx +++ b/src/components/PinnedApps.tsx @@ -4,13 +4,13 @@ import { useSelector } from 'react-redux' import { PinnedApp } from '../models/pinned-app' import { RenderedIn } from '../models/rendered-in' import { sectionHeaderLabelStyle, sectionHeaderWrapperStyle, sectionWrapper } from '../shared/styles' -import { selectPinnedAppsMemoized } from '../slices/pinnedApps' +import { selectPinnedApps } from '../slices/pinnedApps' import { getListItemLayout, getListKey } from '../utils/apps' import AppItem from './AppItem' import EmptyListComponent from './shared/EmptyListComponent' const PinnedApps = () => { - const apps = useSelector(selectPinnedAppsMemoized) + const apps = useSelector(selectPinnedApps) const renderItem: ListRenderItem = ({ item }: ListRenderItemInfo) => ( diff --git a/src/components/RecentApps.tsx b/src/components/RecentApps.tsx index a2722e7..3ca81f6 100644 --- a/src/components/RecentApps.tsx +++ b/src/components/RecentApps.tsx @@ -4,13 +4,13 @@ import { useSelector } from 'react-redux' import { RecentApp } from '../models/recent-app' import { RenderedIn } from '../models/rendered-in' import { sectionHeaderLabelStyle, sectionHeaderWrapperStyle, sectionWrapper } from '../shared/styles' -import { selectRecentAppsMemoized } from '../slices/recentApps' +import { selectRecentApps } from '../slices/recentApps' import { getListItemLayout, getListKey } from '../utils/apps' import AppItem from './AppItem' import EmptyListComponent from './shared/EmptyListComponent' const RecentApps = () => { - const apps = useSelector(selectRecentAppsMemoized) + const apps = useSelector(selectRecentApps) const renderItem: ListRenderItem = ({ item }: ListRenderItemInfo) => ( diff --git a/src/components/Search.tsx b/src/components/Search.tsx index 86d7acc..9047692 100644 --- a/src/components/Search.tsx +++ b/src/components/Search.tsx @@ -14,12 +14,12 @@ import { setAppsSearchResult, setDisplayAllApps, } from '../slices/appState' -import { selectAppsListMemoized, selectAppsLoading } from '../slices/appsList' +import { selectAppsList, selectAppsLoading } from '../slices/appsList' import { getAppsByLabel } from '../utils/apps' const Search = () => { const dispatch = useDispatch() - const apps = useSelector(selectAppsListMemoized) + const apps = useSelector(selectAppsList) const appsLoading = useSelector(selectAppsLoading) const searchQuery = useSelector(selectAppsSearchQuery) const displayAllApps = useSelector(selectDisplayAllApps) diff --git a/src/components/Settings/sections/FavoriteAppsSettings.tsx b/src/components/Settings/sections/FavoriteAppsSettings.tsx index b9f4d83..20509d8 100644 --- a/src/components/Settings/sections/FavoriteAppsSettings.tsx +++ b/src/components/Settings/sections/FavoriteAppsSettings.tsx @@ -2,8 +2,8 @@ import React, { useMemo } from 'react' import { Switch, View } from 'react-native' import { useDispatch, useSelector } from 'react-redux' import { sortFavoriteApps } from '../../../slices/appState' -import { clearFavoriteApps, selectFavoriteAppsCountMemoized } from '../../../slices/favoriteApps' -import { displayFavoriteApps, selectDisplayFavoriteAppsMemoized } from '../../../slices/preferences' +import { clearFavoriteApps, selectFavoriteAppsCount } from '../../../slices/favoriteApps' +import { displayFavoriteApps, selectDisplayFavoriteApps } from '../../../slices/preferences' import { displayToast } from '../../../utils/toast' import CustomPressable from '../../shared/CustomPressable' import SettingsItemLabel from '../shared/SettingsItemLabel' @@ -18,8 +18,8 @@ import { const FavoriteAppsSettings = () => { const dispatch = useDispatch() - const favoriteAppsCount = useSelector(selectFavoriteAppsCountMemoized) - const displayFavoriteAppsValue = useSelector(selectDisplayFavoriteAppsMemoized) + const favoriteAppsCount = useSelector(selectFavoriteAppsCount) + const displayFavoriteAppsValue = useSelector(selectDisplayFavoriteApps) const toggleDisplayFavoriteApps = () => { dispatch(displayFavoriteApps(!displayFavoriteAppsValue)) diff --git a/src/components/Settings/sections/PinnedAppsSettings.tsx b/src/components/Settings/sections/PinnedAppsSettings.tsx index e43a8c6..d8ab517 100644 --- a/src/components/Settings/sections/PinnedAppsSettings.tsx +++ b/src/components/Settings/sections/PinnedAppsSettings.tsx @@ -5,16 +5,16 @@ import { useDispatch, useSelector } from 'react-redux' import { sortPinnedApps, sortTemporaryPinnedApps } from '../../../slices/appState' import { clearPinnedApps, - selectPinnedAppsCountMemoized, - selectTemporaryPinnedAppsConfigMemoized, - selectTemporaryPinnedAppsCountMemoized, + selectPinnedAppsCount, + selectTemporaryPinnedAppsConfig, + selectTemporaryPinnedAppsCount, setTemporaryAppsConfig, } from '../../../slices/pinnedApps' import { displayPinnedApps, displayTemporaryPinnedApps, - selectDisplayPinnedAppsMemoized, - selectDisplayTemporaryPinnedAppsMemoized, + selectDisplayPinnedApps, + selectDisplayTemporaryPinnedApps, } from '../../../slices/preferences' import { getDateFromStringWithCurrentDateValue, getTimeFromDate, stripDateFromSeconds } from '../../../utils/date' import { displayToast } from '../../../utils/toast' @@ -33,11 +33,11 @@ import { const PinnedAppsSettings = () => { const dispatch = useDispatch() - const displayPinnedAppsValue = useSelector(selectDisplayPinnedAppsMemoized) - const pinnedAppsCount = useSelector(selectPinnedAppsCountMemoized) - const displayTemporaryPinnedAppsValue = useSelector(selectDisplayTemporaryPinnedAppsMemoized) - const temporaryPinnedAppsCount = useSelector(selectTemporaryPinnedAppsCountMemoized) - const temporaryPinnedAppsConfig = useSelector(selectTemporaryPinnedAppsConfigMemoized) + const displayPinnedAppsValue = useSelector(selectDisplayPinnedApps) + const pinnedAppsCount = useSelector(selectPinnedAppsCount) + const displayTemporaryPinnedAppsValue = useSelector(selectDisplayTemporaryPinnedApps) + const temporaryPinnedAppsCount = useSelector(selectTemporaryPinnedAppsCount) + const temporaryPinnedAppsConfig = useSelector(selectTemporaryPinnedAppsConfig) const toggleDisplayPinnedApps = () => { dispatch(displayPinnedApps(!displayPinnedAppsValue)) diff --git a/src/components/Settings/sections/RecentAppsSettings.tsx b/src/components/Settings/sections/RecentAppsSettings.tsx index c248a87..dc90f51 100644 --- a/src/components/Settings/sections/RecentAppsSettings.tsx +++ b/src/components/Settings/sections/RecentAppsSettings.tsx @@ -1,7 +1,7 @@ import React from 'react' import { Switch, View } from 'react-native' import { useDispatch, useSelector } from 'react-redux' -import { displayRecentApps, selectDisplayRecentAppsMemoized } from '../../../slices/preferences' +import { displayRecentApps, selectDisplayRecentApps } from '../../../slices/preferences' import { clearRecentApps } from '../../../slices/recentApps' import { displayToast } from '../../../utils/toast' import CustomPressable from '../../shared/CustomPressable' @@ -17,7 +17,7 @@ import { const RecentAppsSettings = () => { const dispatch = useDispatch() - const displayRecentAppsValue = useSelector(selectDisplayRecentAppsMemoized) + const displayRecentAppsValue = useSelector(selectDisplayRecentApps) const toggleDisplayRecentApps = () => { dispatch(displayRecentApps(!displayRecentAppsValue)) diff --git a/src/components/SortableFavoriteApps.tsx b/src/components/SortableFavoriteApps.tsx index 58b2fc7..23279d7 100644 --- a/src/components/SortableFavoriteApps.tsx +++ b/src/components/SortableFavoriteApps.tsx @@ -12,7 +12,7 @@ import { useDispatch, useSelector } from 'react-redux' import { BACKGROUND_COLOR, WHITE_COLOR } from '../constants' import { FavoriteApp } from '../models/favorite-app' import { setDisplaySortableFavoriteApps } from '../slices/appState' -import { selectFavoriteAppsMemoized, setFavoriteApps } from '../slices/favoriteApps' +import { selectFavoriteApps, setFavoriteApps } from '../slices/favoriteApps' import { getListKey } from '../utils/apps' import AppIcon from './shared/AppIcon' import CustomIcon from './shared/CustomIcon' @@ -27,7 +27,7 @@ const doneButtonRippleConfig: PressableAndroidRippleConfig = { const SortableFavoriteApps = () => { const dispatch = useDispatch() - const apps = useSelector(selectFavoriteAppsMemoized) + const apps = useSelector(selectFavoriteApps) const [sorted, setSorted] = useState(false) const rotateValue = useSharedValue(-5) diff --git a/src/components/SortablePinnedApps.tsx b/src/components/SortablePinnedApps.tsx index 50b7a4e..9d8a64a 100644 --- a/src/components/SortablePinnedApps.tsx +++ b/src/components/SortablePinnedApps.tsx @@ -12,7 +12,7 @@ import { useDispatch, useSelector } from 'react-redux' import { BACKGROUND_COLOR, WHITE_COLOR } from '../constants' import { PinnedApp } from '../models/pinned-app' import { setDisplaySortablePinnedApps } from '../slices/appState' -import { selectPinnedAppsMemoized, setPinnedApps } from '../slices/pinnedApps' +import { selectPinnedApps, setPinnedApps } from '../slices/pinnedApps' import { getListKey } from '../utils/apps' import AppIcon from './shared/AppIcon' import CustomIcon from './shared/CustomIcon' @@ -27,7 +27,7 @@ const doneButtonRippleConfig: PressableAndroidRippleConfig = { const SortablePinnedApps = () => { const dispatch = useDispatch() - const apps = useSelector(selectPinnedAppsMemoized) + const apps = useSelector(selectPinnedApps) const [sorted, setSorted] = useState(false) const rotateValue = useSharedValue(-5) diff --git a/src/components/SortableTemporaryPinnedApps.tsx b/src/components/SortableTemporaryPinnedApps.tsx index ac4d13c..4dda08d 100644 --- a/src/components/SortableTemporaryPinnedApps.tsx +++ b/src/components/SortableTemporaryPinnedApps.tsx @@ -12,7 +12,7 @@ import { useDispatch, useSelector } from 'react-redux' import { BACKGROUND_COLOR, WHITE_COLOR } from '../constants' import { PinnedApp } from '../models/pinned-app' import { setDisplaySortableTemporaryPinnedApps } from '../slices/appState' -import { selectTemporaryPinnedAppsMemoized, setPinnedApps } from '../slices/pinnedApps' +import { selectTemporaryPinnedApps, setPinnedApps } from '../slices/pinnedApps' import { getListKey } from '../utils/apps' import AppIcon from './shared/AppIcon' import CustomIcon from './shared/CustomIcon' @@ -27,7 +27,7 @@ const doneButtonRippleConfig: PressableAndroidRippleConfig = { const SortableTemporaryPinnedApps = () => { const dispatch = useDispatch() - const apps = useSelector(selectTemporaryPinnedAppsMemoized) + const apps = useSelector(selectTemporaryPinnedApps) const [sorted, setSorted] = useState(false) const rotateValue = useSharedValue(-5) diff --git a/src/components/TemporaryPinnedApps.tsx b/src/components/TemporaryPinnedApps.tsx index e384063..c262875 100644 --- a/src/components/TemporaryPinnedApps.tsx +++ b/src/components/TemporaryPinnedApps.tsx @@ -4,13 +4,13 @@ import { useSelector } from 'react-redux' import { PinnedApp } from '../models/pinned-app' import { RenderedIn } from '../models/rendered-in' import { sectionHeaderLabelStyle, sectionHeaderWrapperStyle, sectionWrapper } from '../shared/styles' -import { selectTemporaryPinnedAppsMemoized } from '../slices/pinnedApps' +import { selectTemporaryPinnedApps } from '../slices/pinnedApps' import { getListItemLayout, getListKey } from '../utils/apps' import AppItem from './AppItem' import EmptyListComponent from './shared/EmptyListComponent' const TemporaryPinnedApps = () => { - const apps = useSelector(selectTemporaryPinnedAppsMemoized) + const apps = useSelector(selectTemporaryPinnedApps) const renderItem: ListRenderItem = ({ item }: ListRenderItemInfo) => ( diff --git a/src/containers/TopContainer.tsx b/src/containers/TopContainer.tsx index e89ee80..a1e64dc 100644 --- a/src/containers/TopContainer.tsx +++ b/src/containers/TopContainer.tsx @@ -19,18 +19,18 @@ import { selectDisplaySortableTemporaryPinnedApps, } from '../slices/appState' import { - selectDisplayFavoriteAppsMemoized, - selectDisplayPinnedAppsMemoized, - selectDisplayRecentAppsMemoized, - selectDisplayTemporaryPinnedAppsMemoized, + selectDisplayFavoriteApps, + selectDisplayPinnedApps, + selectDisplayRecentApps, + selectDisplayTemporaryPinnedApps, } from '../slices/preferences' const TopContainer = () => { const searchQuery = useSelector(selectAppsSearchQuery) - const displayRecentApps = useSelector(selectDisplayRecentAppsMemoized) - const displayPinnedApps = useSelector(selectDisplayPinnedAppsMemoized) - const displayTemporaryPinnedApps = useSelector(selectDisplayTemporaryPinnedAppsMemoized) - const displayFavoriteApps = useSelector(selectDisplayFavoriteAppsMemoized) + const displayRecentApps = useSelector(selectDisplayRecentApps) + const displayPinnedApps = useSelector(selectDisplayPinnedApps) + const displayTemporaryPinnedApps = useSelector(selectDisplayTemporaryPinnedApps) + const displayFavoriteApps = useSelector(selectDisplayFavoriteApps) const sortableFavoriteApps = useSelector(selectDisplaySortableFavoriteApps) const sortablePinnedApps = useSelector(selectDisplaySortablePinnedApps) const sortableTemporaryPinnedApps = useSelector(selectDisplaySortableTemporaryPinnedApps) diff --git a/src/hooks/useTimeBasedRendering.ts b/src/hooks/useTimeBasedRendering.ts index 7168f67..5a1e675 100644 --- a/src/hooks/useTimeBasedRendering.ts +++ b/src/hooks/useTimeBasedRendering.ts @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react' import { useSelector } from 'react-redux' -import { selectTemporaryPinnedAppsConfigMemoized } from '../slices/pinnedApps' +import { selectTemporaryPinnedAppsConfig } from '../slices/pinnedApps' type CheckResult = { startRenderingTimeOutId: NodeJS.Timeout | undefined @@ -12,7 +12,7 @@ export const useTimeBasedRendering = () => { const [endDate, setEndDate] = useState() const [canRender, setCanRender] = useState(false) - const temporaryPinnedAppsConfig = useSelector(selectTemporaryPinnedAppsConfigMemoized) + const temporaryPinnedAppsConfig = useSelector(selectTemporaryPinnedAppsConfig) useEffect(() => { setStartDate(temporaryPinnedAppsConfig.startDate ? new Date(temporaryPinnedAppsConfig.startDate) : undefined) diff --git a/src/slices/appStateHandler.ts b/src/slices/appStateHandler.ts index 9d0a0b6..9084ce0 100644 --- a/src/slices/appStateHandler.ts +++ b/src/slices/appStateHandler.ts @@ -23,8 +23,8 @@ import { sortTemporaryPinnedApps, toogleAllApps, } from './appState' -import { selectFavoriteAppsMemoized } from './favoriteApps' -import { selectPinnedAppsMemoized } from './pinnedApps' +import { selectFavoriteApps } from './favoriteApps' +import { selectPinnedApps } from './pinnedApps' import { addRecentApp } from './recentApps' // We should only add a launched app if it was clicked (rendered) in one of the following places; @@ -50,8 +50,8 @@ function* appLaunchHandler(action: PayloadAction<{ renderedIn: RenderedIn; appDe } // Skip adding to recent apps if permanently pinned/favourited but launched from different lists/views - const pinnedApps: PinnedApp[] = yield select(selectPinnedAppsMemoized) - const favoriteApps: FavoriteApp[] = yield select(selectFavoriteAppsMemoized) + const pinnedApps: PinnedApp[] = yield select(selectPinnedApps) + const favoriteApps: FavoriteApp[] = yield select(selectFavoriteApps) // TODO: Include the temporarily pinned apps but only when they're rendered/displayed. const pinnedAppsPackages: string[] = pinnedApps.map(({ packageName }: PinnedApp) => packageName) diff --git a/src/slices/appsList.ts b/src/slices/appsList.ts index 9fafae9..cc2ee1a 100644 --- a/src/slices/appsList.ts +++ b/src/slices/appsList.ts @@ -35,10 +35,9 @@ export const { setAppsList, setAppsLoading } = appsListSlice.actions export const getAppsListAction = createAction('appsList/getAppsListAction') export const appRemovedAction = createAction('appsList/appRemovedAction') -const selectAppsList = (state: RootState) => state.appsList.list +export const selectAppsList = (state: RootState) => state.appsList.list export const selectAppsLoading = (state: RootState) => state.appsList.loading -export const selectAppsListMemoized = createSelector(selectAppsList, (list: AppDetails[]) => list) export const selectAppsLetterListMemoized = createSelector(selectAppsList, (list: AppDetails[]) => getAppsLetterIndex(list) ) diff --git a/src/slices/favoriteApps.ts b/src/slices/favoriteApps.ts index 4257aad..ca4494e 100644 --- a/src/slices/favoriteApps.ts +++ b/src/slices/favoriteApps.ts @@ -1,4 +1,4 @@ -import { createSelector, createSlice, PayloadAction } from '@reduxjs/toolkit' +import { createSlice, PayloadAction } from '@reduxjs/toolkit' import { FavoriteApp } from '../models/favorite-app' import { RootState } from '../store' import { getApp, getAppIndex } from '../utils/apps' @@ -39,9 +39,7 @@ export const favoriteAppsSlice = createSlice({ export const { addFavoriteApp, removeFavoriteApp, setFavoriteApps, clearFavoriteApps } = favoriteAppsSlice.actions -const selectFavoriteApps = (state: RootState) => state.favoriteApps.list - -export const selectFavoriteAppsMemoized = createSelector(selectFavoriteApps, (list: FavoriteApp[]) => list) -export const selectFavoriteAppsCountMemoized = createSelector(selectFavoriteApps, (list: FavoriteApp[]) => list.length) +export const selectFavoriteApps = (state: RootState) => state.favoriteApps.list +export const selectFavoriteAppsCount = (state: RootState) => state.favoriteApps.list.length export default favoriteAppsSlice.reducer diff --git a/src/slices/pinnedApps.ts b/src/slices/pinnedApps.ts index fe3a65d..7b19643 100644 --- a/src/slices/pinnedApps.ts +++ b/src/slices/pinnedApps.ts @@ -1,4 +1,4 @@ -import { createSelector, createSlice, PayloadAction } from '@reduxjs/toolkit' +import { createSlice, PayloadAction } from '@reduxjs/toolkit' import { PinnedApp, PinnedAppsState, TemporaryPinnedAppsConfig } from '../models/pinned-app' import { RootState } from '../store' import { getAppIndex } from '../utils/apps' @@ -66,20 +66,10 @@ export const pinnedAppsSlice = createSlice({ export const { addPinnedApp, removePinnedApp, setTemporaryAppsConfig, clearPinnedApps, setPinnedApps } = pinnedAppsSlice.actions -const selectPinnedApps = (state: RootState) => state.pinnedApps.list -const selecttTemporaryPinnedApps = (state: RootState) => state.pinnedApps.temporarily -const selectTemporaryPinnedAppsConfig = (state: RootState) => state.pinnedApps.temporaryAppsConfig - -export const selectPinnedAppsMemoized = createSelector(selectPinnedApps, (list: PinnedApp[]) => list) -export const selectPinnedAppsCountMemoized = createSelector(selectPinnedApps, (list: PinnedApp[]) => list.length) -export const selectTemporaryPinnedAppsMemoized = createSelector(selecttTemporaryPinnedApps, (list: PinnedApp[]) => list) -export const selectTemporaryPinnedAppsCountMemoized = createSelector( - selecttTemporaryPinnedApps, - (list: PinnedApp[]) => list.length -) -export const selectTemporaryPinnedAppsConfigMemoized = createSelector( - selectTemporaryPinnedAppsConfig, - (config: TemporaryPinnedAppsConfig) => config -) +export const selectPinnedApps = (state: RootState) => state.pinnedApps.list +export const selectPinnedAppsCount = (state: RootState) => state.pinnedApps.list.length +export const selectTemporaryPinnedApps = (state: RootState) => state.pinnedApps.temporarily +export const selectTemporaryPinnedAppsCount = (state: RootState) => state.pinnedApps.temporarily.length +export const selectTemporaryPinnedAppsConfig = (state: RootState) => state.pinnedApps.temporaryAppsConfig export default pinnedAppsSlice.reducer diff --git a/src/slices/preferences.ts b/src/slices/preferences.ts index 66f5b58..9201ab9 100644 --- a/src/slices/preferences.ts +++ b/src/slices/preferences.ts @@ -1,4 +1,4 @@ -import { createSelector, createSlice, PayloadAction } from '@reduxjs/toolkit' +import { createSlice, PayloadAction } from '@reduxjs/toolkit' import { RootState } from '../store' export interface PreferencesState { @@ -48,17 +48,9 @@ export const { resetPreferences, } = preferencesSlice.actions -const selectDisplayRecentApps = (state: RootState) => state.preferences.displayRecentApps -const selectDisplayFavoriteApps = (state: RootState) => state.preferences.displayFavoriteApps -const selectDisplayPinnedApps = (state: RootState) => state.preferences.displayPinnedApps -const selectDisplayTemporaryPinnedApps = (state: RootState) => state.preferences.displayTemporaryPinnedApps - -export const selectDisplayRecentAppsMemoized = createSelector(selectDisplayRecentApps, (value: boolean) => value) -export const selectDisplayFavoriteAppsMemoized = createSelector(selectDisplayFavoriteApps, (value: boolean) => value) -export const selectDisplayPinnedAppsMemoized = createSelector(selectDisplayPinnedApps, (value: boolean) => value) -export const selectDisplayTemporaryPinnedAppsMemoized = createSelector( - selectDisplayTemporaryPinnedApps, - (value: boolean) => value -) +export const selectDisplayRecentApps = (state: RootState) => state.preferences.displayRecentApps +export const selectDisplayFavoriteApps = (state: RootState) => state.preferences.displayFavoriteApps +export const selectDisplayPinnedApps = (state: RootState) => state.preferences.displayPinnedApps +export const selectDisplayTemporaryPinnedApps = (state: RootState) => state.preferences.displayTemporaryPinnedApps export default preferencesSlice.reducer diff --git a/src/slices/recentApps.ts b/src/slices/recentApps.ts index f61b746..2bcacf2 100644 --- a/src/slices/recentApps.ts +++ b/src/slices/recentApps.ts @@ -1,4 +1,4 @@ -import { createSelector, createSlice, PayloadAction } from '@reduxjs/toolkit' +import { createSlice, PayloadAction } from '@reduxjs/toolkit' import { RecentApp } from '../models/recent-app' import { RootState } from '../store' import { getAppIndex } from '../utils/apps' @@ -41,8 +41,6 @@ export const recentAppsSlice = createSlice({ export const { addRecentApp, removeRecentApp, clearRecentApps } = recentAppsSlice.actions -const selectRecentApps = (state: RootState) => state.recentApps.list - -export const selectRecentAppsMemoized = createSelector(selectRecentApps, (list: RecentApp[]) => list) +export const selectRecentApps = (state: RootState) => state.recentApps.list export default recentAppsSlice.reducer