revert 2c1ea47, sorting store should be separate from catalog filters store

This commit is contained in:
Tom (plebeius.eth)
2024-06-15 16:03:59 +02:00
parent 05f7977467
commit 60ab84efd1
4 changed files with 18 additions and 8 deletions
-5
View File
@@ -3,8 +3,6 @@ import { create } from 'zustand';
interface CatalogFiltersStore {
showTextOnlyThreads: boolean;
setShowTextOnlyThreads: (value: boolean) => void;
sortType: 'active' | 'new';
setSortType: (type: 'active' | 'new') => void;
}
const useCatalogFiltersStore = create<CatalogFiltersStore>((set) => ({
@@ -13,9 +11,6 @@ const useCatalogFiltersStore = create<CatalogFiltersStore>((set) => ({
set({ showTextOnlyThreads: value });
localStorage.setItem('showTextOnlyThreads', value.toString());
},
sortType: 'active',
setSortType: (type: 'active' | 'new') => set({ sortType: type }),
}));
export default useCatalogFiltersStore;
+13
View File
@@ -0,0 +1,13 @@
import { create } from 'zustand';
interface SortingStore {
sortType: 'active' | 'new';
setSortType: (type: 'active' | 'new') => void;
}
const useSortingStore = create<SortingStore>((set) => ({
sortType: 'active',
setSortType: (type) => set({ sortType: type }),
}));
export default useSortingStore;
+2 -2
View File
@@ -10,7 +10,7 @@ import useFeedStateString from '../../hooks/use-feed-state-string';
import useReplyModal from '../../hooks/use-reply-modal';
import useTimeFilter from '../../hooks/use-time-filter';
import useFeedResetStore from '../../stores/use-feed-reset-store';
import useCatalogFiltersStore from '../../stores/use-catalog-filters-store';
import useSortingStore from '../../stores/use-sorting-store';
import LoadingEllipsis from '../../components/loading-ellipsis';
import { Post } from '../post';
import ReplyModal from '../../components/reply-modal';
@@ -42,7 +42,7 @@ const Board = () => {
return [subplebbitAddress];
}, [isInAllView, isInSubscriptionsView, subplebbitAddress, defaultSubplebbitAddresses, subscriptions]);
const { sortType } = useCatalogFiltersStore();
const { sortType } = useSortingStore();
const { timeFilterSeconds } = useTimeFilter();
const feedOptions: any = {
+3 -1
View File
@@ -11,6 +11,7 @@ import useTimeFilter from '../../hooks/use-time-filter';
import useWindowWidth from '../../hooks/use-window-width';
import useCatalogFiltersStore from '../../stores/use-catalog-filters-store';
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';
@@ -112,7 +113,8 @@ const Catalog = () => {
const postsPerPage = useMemo(() => (columnCount <= 2 ? 10 : columnCount === 3 ? 15 : columnCount === 4 ? 20 : 25), []);
const { timeFilterSeconds } = useTimeFilter();
const { showTextOnlyThreads, sortType } = useCatalogFiltersStore();
const { showTextOnlyThreads } = useCatalogFiltersStore();
const { sortType } = useSortingStore();
const feedOptions: any = {
subplebbitAddresses,