mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
feat: add time filter to p/all and p/subscriptions
This commit is contained in:
@@ -8,6 +8,7 @@ import { isAllView, isSubscriptionsView } from '../../lib/utils/view-utils';
|
||||
import { useDefaultSubplebbitAddresses } from '../../hooks/use-default-subplebbits';
|
||||
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 useSortingStore from '../../stores/use-sorting-store';
|
||||
import LoadingEllipsis from '../../components/loading-ellipsis';
|
||||
@@ -42,7 +43,8 @@ const Board = () => {
|
||||
}, [isInAllView, isInSubscriptionsView, subplebbitAddress, defaultSubplebbitAddresses, subscriptions]);
|
||||
|
||||
const { sortType } = useSortingStore();
|
||||
const { feed, hasMore, loadMore, reset } = useFeed({ subplebbitAddresses, sortType });
|
||||
const { timeFilterSeconds } = useTimeFilter();
|
||||
const { feed, hasMore, loadMore, reset } = useFeed({ subplebbitAddresses, sortType, postsPerPage: 10, newerThan: timeFilterSeconds });
|
||||
|
||||
const setResetFunction = useFeedResetStore((state) => state.setResetFunction);
|
||||
useEffect(() => {
|
||||
@@ -91,15 +93,15 @@ const Board = () => {
|
||||
const setLastVirtuosoState = () => {
|
||||
virtuosoRef.current?.getState((snapshot: StateSnapshot) => {
|
||||
if (snapshot?.ranges?.length) {
|
||||
lastVirtuosoStates[location.pathname] = snapshot;
|
||||
lastVirtuosoStates[sortType + timeFilterSeconds] = snapshot;
|
||||
}
|
||||
});
|
||||
};
|
||||
window.addEventListener('scroll', setLastVirtuosoState);
|
||||
return () => window.removeEventListener('scroll', setLastVirtuosoState);
|
||||
}, [location.pathname]);
|
||||
}, [sortType, timeFilterSeconds]);
|
||||
|
||||
const lastVirtuosoState = lastVirtuosoStates?.[location.pathname];
|
||||
const lastVirtuosoState = lastVirtuosoStates?.[sortType + timeFilterSeconds];
|
||||
|
||||
useEffect(() => {
|
||||
document.title = title ? title : shortAddress || subplebbitAddress;
|
||||
|
||||
@@ -7,6 +7,7 @@ import { isAllView, isSubscriptionsView } from '../../lib/utils/view-utils';
|
||||
import { useDefaultSubplebbitAddresses } from '../../hooks/use-default-subplebbits';
|
||||
import useFeedStateString from '../../hooks/use-feed-state-string';
|
||||
import { useMultisubMetadata } from '../../hooks/use-default-subplebbits';
|
||||
import useTimeFilter from '../../hooks/use-time-filter';
|
||||
import useWindowWidth from '../../hooks/use-window-width';
|
||||
import useFeedResetStore from '../../stores/use-feed-reset-store';
|
||||
import useSortingStore from '../../stores/use-sorting-store';
|
||||
@@ -104,7 +105,8 @@ const Catalog = () => {
|
||||
const postsPerPage = useMemo(() => (columnCount <= 2 ? 10 : columnCount === 3 ? 15 : columnCount === 4 ? 20 : 25), []);
|
||||
|
||||
const { sortType } = useSortingStore();
|
||||
const { feed, hasMore, loadMore, reset } = useFeed({ subplebbitAddresses, sortType, postsPerPage });
|
||||
const { timeFilterSeconds } = useTimeFilter();
|
||||
const { feed, hasMore, loadMore, reset } = useFeed({ subplebbitAddresses, sortType, postsPerPage, newerThan: timeFilterSeconds });
|
||||
|
||||
const setResetFunction = useFeedResetStore((state) => state.setResetFunction);
|
||||
useEffect(() => {
|
||||
@@ -147,14 +149,14 @@ const Catalog = () => {
|
||||
const setLastVirtuosoState = () =>
|
||||
virtuosoRef.current?.getState((snapshot: StateSnapshot) => {
|
||||
if (snapshot?.ranges?.length) {
|
||||
lastVirtuosoStates[location.pathname] = snapshot;
|
||||
lastVirtuosoStates[sortType + timeFilterSeconds + 'catalog'] = snapshot;
|
||||
}
|
||||
});
|
||||
window.addEventListener('scroll', setLastVirtuosoState);
|
||||
return () => window.removeEventListener('scroll', setLastVirtuosoState);
|
||||
}, [location.pathname]);
|
||||
}, [sortType, timeFilterSeconds]);
|
||||
|
||||
const lastVirtuosoState = lastVirtuosoStates?.[location.pathname];
|
||||
const lastVirtuosoState = lastVirtuosoStates?.[sortType + timeFilterSeconds + 'catalog'];
|
||||
|
||||
useEffect(() => {
|
||||
let documentTitle = title ? title : shortAddress;
|
||||
|
||||
Reference in New Issue
Block a user