fix(popular threads box): default to worksafe content and show 8 posts for single subplebbit

This commit is contained in:
Tom (plebeius.eth)
2024-06-12 16:50:39 +02:00
parent f20a5f21f9
commit c6a1283b56
3 changed files with 3 additions and 9 deletions
+1 -8
View File
@@ -9,14 +9,7 @@ const usePopularPosts = (subplebbits: Subplebbit[]) => {
const uniqueLinks: Set<string> = 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[] = [];
+1 -1
View File
@@ -29,7 +29,7 @@ const useHomeFiltersStore = create<HomeFiltersStore>((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());
@@ -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 (
<div className={styles.box}>
<div className={`${styles.boxBar} ${styles.color2ColorBar}`}>