mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
refactor(multiboards): remove time filter system end-to-end
Backend retention now keeps only recent posts, making the time filter UI and newerThan filtering obsolete. Deleted use-time-filter hook, canonical multiboard routes only, removed footer suggestions, dropped i18n keys.
This commit is contained in:
@@ -15,7 +15,6 @@ import useModQueueStore from '../../stores/use-mod-queue-store';
|
||||
import useFeedViewSettingsStore from '../../stores/use-feed-view-settings-store';
|
||||
import useCountLinksInReplies from '../../hooks/use-count-links-in-replies';
|
||||
import useIsMobile from '../../hooks/use-is-mobile';
|
||||
import useTimeFilter from '../../hooks/use-time-filter';
|
||||
import CatalogFilters from '../catalog-filters';
|
||||
import CatalogSearch from '../catalog-search';
|
||||
import Tooltip from '../tooltip';
|
||||
@@ -39,16 +38,9 @@ const CatalogButton = ({ address, isInAllView, isInSubscriptionsView, isInModVie
|
||||
const directories = useDirectories();
|
||||
|
||||
const createCatalogLink = () => {
|
||||
if (isInAllView) {
|
||||
if (params?.timeFilterName) return `/all/catalog/${params.timeFilterName}`;
|
||||
return `/all/catalog`;
|
||||
} else if (isInSubscriptionsView) {
|
||||
if (params?.timeFilterName) return `/subs/catalog/${params.timeFilterName}`;
|
||||
return `/subs/catalog`;
|
||||
} else if (isInModView) {
|
||||
if (params?.timeFilterName) return `/mod/catalog/${params.timeFilterName}`;
|
||||
return `/mod/catalog`;
|
||||
}
|
||||
if (isInAllView) return `/all/catalog`;
|
||||
if (isInSubscriptionsView) return `/subs/catalog`;
|
||||
if (isInModView) return `/mod/catalog`;
|
||||
let boardPath = '';
|
||||
if (address) {
|
||||
boardPath = getBoardPath(address, directories);
|
||||
@@ -82,22 +74,16 @@ const ReturnButton = ({ address, isInAllView, isInSubscriptionsView, isInModView
|
||||
const directories = useDirectories();
|
||||
|
||||
const createReturnLink = () => {
|
||||
if (isInAllView) {
|
||||
if (params?.timeFilterName) return `/all/${params.timeFilterName}`;
|
||||
return `/all`;
|
||||
} else if (isInSubscriptionsView) {
|
||||
if (params?.timeFilterName) return `/subs/${params.timeFilterName}`;
|
||||
return `/subs`;
|
||||
} else if (isInModQueueView) {
|
||||
if (isInAllView) return `/all`;
|
||||
if (isInSubscriptionsView) return `/subs`;
|
||||
if (isInModQueueView) {
|
||||
// If in mod queue view, return to /mod or /:boardIdentifier
|
||||
if (params?.boardIdentifier) {
|
||||
return `/${params.boardIdentifier}`;
|
||||
}
|
||||
return `/mod`;
|
||||
} else if (isInModView) {
|
||||
if (params?.timeFilterName) return `/mod/${params.timeFilterName}`;
|
||||
return `/mod`;
|
||||
}
|
||||
if (isInModView) return `/mod`;
|
||||
let boardPath = '';
|
||||
if (address) {
|
||||
boardPath = getBoardPath(address, directories);
|
||||
@@ -335,53 +321,6 @@ const ShowOPCommentOption = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export const TimeFilter = ({ isInAllView, isInCatalogView, isInSubscriptionsView, isInModView, isTopbar = false }: BoardButtonsProps) => {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const { timeFilterName, timeFilterNames } = useTimeFilter();
|
||||
|
||||
const changeTimeFilter = (event: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
const timeFilterName = event.target.value;
|
||||
const link = isInAllView
|
||||
? isInCatalogView
|
||||
? `/all/catalog/${timeFilterName}`
|
||||
: `/all/${timeFilterName}`
|
||||
: isInSubscriptionsView
|
||||
? isInCatalogView
|
||||
? `/subs/catalog/${timeFilterName}`
|
||||
: `/subs/${timeFilterName}`
|
||||
: isInModView
|
||||
? isInCatalogView
|
||||
? `/mod/catalog/${timeFilterName}`
|
||||
: `/mod/${timeFilterName}`
|
||||
: null;
|
||||
link && navigate(link);
|
||||
};
|
||||
|
||||
const { sortType } = useSortingStore();
|
||||
|
||||
const allTimeFilterNames = timeFilterName ? Array.from(new Set([timeFilterName, ...timeFilterNames])) : timeFilterNames;
|
||||
|
||||
return (
|
||||
<>
|
||||
{!isTopbar ? (
|
||||
<>
|
||||
<span>{isInCatalogView ? (sortType === 'active' ? t('last_bumped') : t('newer_than')) : t('last_bumped')}</span>:
|
||||
</>
|
||||
) : (
|
||||
<> </>
|
||||
)}
|
||||
<select onChange={changeTimeFilter} className={[styles.feedName, styles.menuItem, 'capitalize'].join(' ')} value={timeFilterName}>
|
||||
{allTimeFilterNames.map((name, i) => (
|
||||
<option key={name + i} value={name}>
|
||||
{name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const AllFeedFilter = () => {
|
||||
const { t } = useTranslation();
|
||||
const { filter, setFilter } = useAllFeedFilterStore();
|
||||
@@ -643,9 +582,6 @@ export const DesktopBoardButtons = () => {
|
||||
</>
|
||||
)}
|
||||
{isInAllView && <AllFeedFilter />}
|
||||
{(isInAllView || isInSubscriptionsView || isInModView) && (
|
||||
<TimeFilter isInAllView={isInAllView} isInCatalogView={isInCatalogView} isInSubscriptionsView={isInSubscriptionsView} isInModView={isInModView} />
|
||||
)}
|
||||
{!(isInAllView || isInSubscriptionsView || isInModView) && (
|
||||
<>
|
||||
[
|
||||
@@ -684,17 +620,11 @@ const SearchOPsBar = () => {
|
||||
let catalogUrl = '';
|
||||
|
||||
if (isInAllView) {
|
||||
catalogUrl = params?.timeFilterName
|
||||
? `/all/catalog/${params.timeFilterName}?q=${encodeURIComponent(searchQuery)}`
|
||||
: `/all/catalog?q=${encodeURIComponent(searchQuery)}`;
|
||||
catalogUrl = `/all/catalog?q=${encodeURIComponent(searchQuery)}`;
|
||||
} else if (isInSubscriptionsView) {
|
||||
catalogUrl = params?.timeFilterName
|
||||
? `/subs/catalog/${params.timeFilterName}?q=${encodeURIComponent(searchQuery)}`
|
||||
: `/subs/catalog?q=${encodeURIComponent(searchQuery)}`;
|
||||
catalogUrl = `/subs/catalog?q=${encodeURIComponent(searchQuery)}`;
|
||||
} else if (isInModView) {
|
||||
catalogUrl = params?.timeFilterName
|
||||
? `/mod/catalog/${params.timeFilterName}?q=${encodeURIComponent(searchQuery)}`
|
||||
: `/mod/catalog?q=${encodeURIComponent(searchQuery)}`;
|
||||
catalogUrl = `/mod/catalog?q=${encodeURIComponent(searchQuery)}`;
|
||||
} else {
|
||||
catalogUrl = `/${boardPath}/catalog?q=${encodeURIComponent(searchQuery)}`;
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { TimeFilter, MobileBoardButtons, DesktopBoardButtons } from './board-buttons';
|
||||
export { MobileBoardButtons, DesktopBoardButtons } from './board-buttons';
|
||||
|
||||
@@ -9,7 +9,6 @@ import styles from './feed-cache-container.module.css';
|
||||
interface FeedContextFromKey {
|
||||
viewType: 'all' | 'subs' | 'mod' | 'board';
|
||||
boardIdentifier?: string;
|
||||
timeFilterName?: string;
|
||||
}
|
||||
|
||||
const parseFeedKey = (key: string): FeedContextFromKey => {
|
||||
@@ -17,28 +16,18 @@ const parseFeedKey = (key: string): FeedContextFromKey => {
|
||||
|
||||
const filteredSegments = segments.filter((s) => s !== 'catalog');
|
||||
if (filteredSegments[0] === 'all') {
|
||||
return {
|
||||
viewType: 'all',
|
||||
timeFilterName: filteredSegments[1],
|
||||
};
|
||||
return { viewType: 'all' };
|
||||
}
|
||||
if (filteredSegments[0] === 'subs') {
|
||||
return {
|
||||
viewType: 'subs',
|
||||
timeFilterName: filteredSegments[1],
|
||||
};
|
||||
return { viewType: 'subs' };
|
||||
}
|
||||
if (filteredSegments[0] === 'mod') {
|
||||
return {
|
||||
viewType: 'mod',
|
||||
timeFilterName: filteredSegments[1],
|
||||
};
|
||||
return { viewType: 'mod' };
|
||||
}
|
||||
|
||||
return {
|
||||
viewType: 'board',
|
||||
boardIdentifier: filteredSegments[0],
|
||||
timeFilterName: filteredSegments[1],
|
||||
};
|
||||
};
|
||||
|
||||
@@ -53,21 +42,9 @@ const CachedFeedWrapper = ({ feed, isVisible }: CachedFeedWrapperProps) => {
|
||||
return (
|
||||
<div className={isVisible ? styles.visible : styles.hidden}>
|
||||
{feed.type === 'catalog' ? (
|
||||
<Catalog
|
||||
feedCacheKey={feed.key}
|
||||
viewType={context.viewType}
|
||||
boardIdentifier={context.boardIdentifier}
|
||||
timeFilterNameFromCache={context.timeFilterName}
|
||||
isVisible={isVisible}
|
||||
/>
|
||||
<Catalog feedCacheKey={feed.key} viewType={context.viewType} boardIdentifier={context.boardIdentifier} isVisible={isVisible} />
|
||||
) : (
|
||||
<Board
|
||||
feedCacheKey={feed.key}
|
||||
viewType={context.viewType}
|
||||
boardIdentifier={context.boardIdentifier}
|
||||
timeFilterNameFromCache={context.timeFilterName}
|
||||
isVisible={isVisible}
|
||||
/>
|
||||
<Board feedCacheKey={feed.key} viewType={context.viewType} boardIdentifier={context.boardIdentifier} isVisible={isVisible} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -8,7 +8,6 @@ import { isAllView, isCatalogView, isSubscriptionsView } from '../../lib/utils/v
|
||||
import { useDirectories, DirectoryCommunity } from '../../hooks/use-directories';
|
||||
import { useBoardPath, useResolvedSubplebbitAddress } from '../../hooks/use-resolved-subplebbit-address';
|
||||
import { getBoardPath, extractDirectoryFromTitle } from '../../lib/utils/route-utils';
|
||||
import { TimeFilter } from '../board-buttons';
|
||||
import useCreateBoardModalStore from '../../stores/use-create-board-modal-store';
|
||||
import useTopbarEditModalStore from '../../stores/use-topbar-edit-modal-store';
|
||||
import useTopbarVisibilityStore from '../../stores/use-topbar-visibility-store';
|
||||
@@ -334,9 +333,6 @@ const TopBarMobile = ({ subplebbitAddress }: { subplebbitAddress: string }) => {
|
||||
<div className={styles.boardSelect}>
|
||||
<strong>{t('board')}</strong>
|
||||
{boardSelect}
|
||||
{(isInAllView || isInSubscriptionsView) && (
|
||||
<TimeFilter isTopbar={true} isInAllView={isInAllView} isInCatalogView={isInCatalogView} isInSubscriptionsView={isInSubscriptionsView} />
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.pageJump}>
|
||||
<Link to={useLocation().pathname.replace(/\/$/, '') + '/settings'}>{t('settings')}</Link>
|
||||
|
||||
Reference in New Issue
Block a user