From c6a1283b56b0953d9513d7aa32d0d8c59a5cdfee Mon Sep 17 00:00:00 2001 From: "Tom (plebeius.eth)" Date: Wed, 12 Jun 2024 16:50:39 +0200 Subject: [PATCH] fix(popular threads box): default to worksafe content and show 8 posts for single subplebbit --- src/hooks/use-popular-posts.ts | 9 +-------- src/stores/use-home-filters-store.ts | 2 +- .../home/popular-threads-box/popular-threads-box.tsx | 1 + 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/hooks/use-popular-posts.ts b/src/hooks/use-popular-posts.ts index d8aa7e42..1c3c83b9 100644 --- a/src/hooks/use-popular-posts.ts +++ b/src/hooks/use-popular-posts.ts @@ -9,14 +9,7 @@ const usePopularPosts = (subplebbits: Subplebbit[]) => { const uniqueLinks: Set = new Set(); const allPosts: Comment[] = []; - let postsPerSub = 1; - if (subplebbits.length === 2) { - postsPerSub = 4; - } else if (subplebbits.length === 3) { - postsPerSub = 3; - } else if (subplebbits.length >= 4 && subplebbits.length < 8) { - postsPerSub = 2; - } + const postsPerSub = [0, 8, 4, 3, 2, 2, 2, 2, 1][Math.min(subplebbits.length, 8)]; subplebbits.forEach((subplebbit: any) => { let subplebbitPosts: Comment[] = []; diff --git a/src/stores/use-home-filters-store.ts b/src/stores/use-home-filters-store.ts index 86884b7a..00fed51c 100644 --- a/src/stores/use-home-filters-store.ts +++ b/src/stores/use-home-filters-store.ts @@ -29,7 +29,7 @@ const useHomeFiltersStore = create((set) => ({ set({ useCatalog: value }); localStorage.setItem('useCatalog', value.toString()); }, - showWorksafeContentOnly: localStorage.getItem('showWorksafeContentOnly') === 'true' ? true : false, + showWorksafeContentOnly: localStorage.getItem('showWorksafeContentOnly') === 'true' || localStorage.getItem('showWorksafeContentOnly') === null ? true : false, setShowWorksafeContentOnly: (value: boolean) => { set({ showWorksafeContentOnly: value }); localStorage.setItem('showWorksafeContentOnly', value.toString()); diff --git a/src/views/home/popular-threads-box/popular-threads-box.tsx b/src/views/home/popular-threads-box/popular-threads-box.tsx index 338dc4c8..726023ec 100644 --- a/src/views/home/popular-threads-box/popular-threads-box.tsx +++ b/src/views/home/popular-threads-box/popular-threads-box.tsx @@ -60,6 +60,7 @@ const PopularThreadsBox = ({ multisub, subplebbits }: { multisub: Subplebbit[]; const filteredSubplebbits = useMemo(getFilteredSubplebbits, [subplebbits, showWorksafeContentOnly, showNsfwContentOnly, multisub]); const popularPosts = usePopularPosts(filteredSubplebbits); + console.log(showWorksafeContentOnly, showNsfwContentOnly); return (