revert(catalog): disable catalog filters temporarily, they don't perform well with api

This commit is contained in:
Tom (plebeius.eth)
2024-09-17 17:04:38 +02:00
parent 7742e1c9b0
commit cadf416058
2 changed files with 24 additions and 16 deletions
+23 -15
View File
@@ -45,29 +45,37 @@ const useCatalogFiltersStore = create(
}, },
filter: undefined, filter: undefined,
updateFilter: () => { updateFilter: () => {
const filteredCids = new Set<string>(); // const filteredCids = new Set<string>();
set((state) => ({ set((state) => ({
filter: (comment: Comment) => { filter: (comment: Comment) => {
const { showTextOnlyThreads, filterItems } = state; const {
showTextOnlyThreads,
// filterItems
} = state;
const hasThumbnail = getHasThumbnail(getCommentMediaInfo(comment), comment?.link); const hasThumbnail = getHasThumbnail(getCommentMediaInfo(comment), comment?.link);
const title = comment?.title?.toLowerCase() || ''; // const title = comment?.title?.toLowerCase() || '';
const content = comment?.content?.toLowerCase() || ''; // const content = comment?.content?.toLowerCase() || '';
const matchesFilterItems = filterItems // const matchesFilterItems = filterItems
.filter((item) => item.enabled) // .filter((item) => item.enabled)
.some((item) => { // .some((item) => {
const text = item.text.toLowerCase(); // const text = item.text.toLowerCase();
return title.includes(text) || content.includes(text); // return title.includes(text) || content.includes(text);
}); // });
const shouldShow = showTextOnlyThreads || hasThumbnail; const shouldShow = showTextOnlyThreads || hasThumbnail;
if (!shouldShow || matchesFilterItems) { if (
if (matchesFilterItems && !filteredCids.has(comment.cid)) { !shouldShow
filteredCids.add(comment.cid); // || matchesFilterItems
set((state) => ({ filteredCount: state.filteredCount + 1 })); ) {
} // if (
// matchesFilterItems &&
// !filteredCids.has(comment.cid)) {
// filteredCids.add(comment.cid);
// set((state) => ({ filteredCount: state.filteredCount + 1 }));
// }
return false; return false;
} }
@@ -131,7 +131,7 @@ const CatalogFilters = () => {
return ( return (
<> <>
<span className={`${styles.filtersButton} button`} onClick={() => setShowModal(true)}> <span className={`${styles.filtersButton} button`} onClick={() => setShowModal(false)} style={{ cursor: 'not-allowed' }}>
{t('filters')} {t('filters')}
</span> </span>
{showModal && <FiltersModal closeModal={closeModal} />} {showModal && <FiltersModal closeModal={closeModal} />}