diff --git a/frontend/src/components/store/Store.tsx b/frontend/src/components/store/Store.tsx index 99d7fe40e..c9f1bf2bb 100644 --- a/frontend/src/components/store/Store.tsx +++ b/frontend/src/components/store/Store.tsx @@ -8,7 +8,7 @@ import { TextField, findModule, } from 'decky-frontend-lib'; -import { FC, useEffect, useMemo, useState } from 'react'; +import { FC, useEffect, useMemo, useState, Dispatch, SetStateAction } from 'react'; import { useTranslation } from 'react-i18next'; import logo from '../../../assets/plugin_store.png'; @@ -61,7 +61,7 @@ const StorePage: FC<{}> = () => { ); }; -const BrowseTab: FC<{ children: { setPluginCount: setPluginCount } }> = (data) => { +const BrowseTab: FC<{ children: { setPluginCount: Dispatch> } }> = (data) => { const { t } = useTranslation(); @@ -79,29 +79,30 @@ const BrowseTab: FC<{ children: { setPluginCount: setPluginCount } }> = (data) = const [selectedSort, setSort] = useState(dropdownSortOptions[0].data); // const [selectedFilter, setFilter] = useState(filterOptions[0].data); const [searchFieldValue, setSearchValue] = useState(''); - const [data, setData] = useState(null); + const [pluginList, setPluginList] = useState(null); const [isTesting, setIsTesting] = useState(false); useEffect(() => { (async () => { - sort, direction = null, null + let sort = null + let direction = null switch (selectedSort) { - case 1: direction=SortDirections.ascending;sort=SortOptions.name + case 1: direction=SortDirections.ascending; sort=SortOptions.name case 2: direction=SortDirections.descending;sort=SortOptions.name - case 3: direction=SortDirections.ascending;sort=SortOptions.date + case 3: direction=SortDirections.ascending; sort=SortOptions.date case 4: direction=SortDirections.descending;sort=SortOptions.date } const res = await getPluginList(sort, direction); logger.log('got data!', res); - setData(res); - setPluginCount(res.length) + setPluginList(res); + data.children.setPluginCount(res.length) const storeRes = await getStore(); logger.log(`store is ${storeRes}, isTesting is ${storeRes === Store.Testing}`); setIsTesting(storeRes === Store.Testing); })(); }, []); - return !data ? ( + return !pluginList ? (
@@ -222,7 +223,7 @@ const BrowseTab: FC<{ children: { setPluginCount: setPluginCount } }> = (data) = )}
- {data + {pluginList .filter((plugin: StorePlugin) => { return ( plugin.name.toLowerCase().includes(searchFieldValue.toLowerCase()) ||