feat(catalog): add sorting option

This commit is contained in:
Tom (plebeius.eth)
2024-05-31 18:18:42 +02:00
parent 5cf25f144d
commit 1ecb2ba13d
6 changed files with 67 additions and 26 deletions
+2 -1
View File
@@ -9,6 +9,7 @@ import { useDefaultSubplebbitAddresses } from '../../hooks/use-default-subplebbi
import useFeedStateString from '../../hooks/use-feed-state-string';
import useReplyModal from '../../hooks/use-reply-modal';
import useFeedResetStore from '../../stores/use-feed-reset-store';
import useSortingStore from '../../stores/use-sorting-store';
import LoadingEllipsis from '../../components/loading-ellipsis';
import Post from '../../components/post';
import ReplyModal from '../../components/reply-modal';
@@ -40,7 +41,7 @@ const Board = () => {
return [subplebbitAddress];
}, [isInAllView, isInSubscriptionsView, subplebbitAddress, defaultSubplebbitAddresses, subscriptions]);
const sortType = 'active';
const { sortType } = useSortingStore();
const { feed, hasMore, loadMore, reset } = useFeed({ subplebbitAddresses, sortType });
const setResetFunction = useFeedResetStore((state) => state.setResetFunction);
+3 -1
View File
@@ -9,6 +9,7 @@ import useFeedStateString from '../../hooks/use-feed-state-string';
import { useMultisubMetadata } from '../../hooks/use-default-subplebbits';
import useWindowWidth from '../../hooks/use-window-width';
import useFeedResetStore from '../../stores/use-feed-reset-store';
import useSortingStore from '../../stores/use-sorting-store';
import CatalogRow from '../../components/catalog-row';
import LoadingEllipsis from '../../components/loading-ellipsis';
import SettingsModal from '../../components/settings-modal';
@@ -102,7 +103,8 @@ const Catalog = () => {
// eslint-disable-next-line
const postsPerPage = useMemo(() => (columnCount <= 2 ? 10 : columnCount === 3 ? 15 : columnCount === 4 ? 20 : 25), []);
const { feed, hasMore, loadMore, reset } = useFeed({ subplebbitAddresses, sortType: 'active', postsPerPage });
const { sortType } = useSortingStore();
const { feed, hasMore, loadMore, reset } = useFeed({ subplebbitAddresses, sortType, postsPerPage });
const setResetFunction = useFeedResetStore((state) => state.setResetFunction);
useEffect(() => {