diff --git a/public/translations/ar/default.json b/public/translations/ar/default.json index 14ae199c..d06f94f0 100644 --- a/public/translations/ar/default.json +++ b/public/translations/ar/default.json @@ -146,5 +146,6 @@ "ban_user_for": "حظر المستخدم لمدة <1> يوم(أيام)", "optional": "اختياري", "close_thread": "اغلق الموضوع", - "view_spoiler": "عرض الحاضر" + "view_spoiler": "عرض الحاضر", + "filter": "تصفية" } \ No newline at end of file diff --git a/public/translations/bn/default.json b/public/translations/bn/default.json index f1a50393..263dd18b 100644 --- a/public/translations/bn/default.json +++ b/public/translations/bn/default.json @@ -146,5 +146,6 @@ "ban_user_for": "ব্যবহারকারীকে <1> দিনের জন্য বন্ধ করুন", "optional": "ঐচ্ছিক", "close_thread": "থ্রেড বন্ধ করুন", - "view_spoiler": "স্পোয়ালার দেখুন" + "view_spoiler": "স্পোয়ালার দেখুন", + "filter": "ফিল্টার" } \ No newline at end of file diff --git a/public/translations/cs/default.json b/public/translations/cs/default.json index c0138174..2715d135 100644 --- a/public/translations/cs/default.json +++ b/public/translations/cs/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Zakázat uživatele na <1> den (dní)", "optional": "volitelný", "close_thread": "uzavřít vlákno", - "view_spoiler": "zobrazit spoiler" + "view_spoiler": "zobrazit spoiler", + "filter": "filtr" } \ No newline at end of file diff --git a/public/translations/da/default.json b/public/translations/da/default.json index f5a47a62..82179016 100644 --- a/public/translations/da/default.json +++ b/public/translations/da/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Udeluk brugeren i <1> dag(e)", "optional": "valgfri", "close_thread": "luk tråd", - "view_spoiler": "vis spoiler" + "view_spoiler": "vis spoiler", + "filter": "filtrér" } \ No newline at end of file diff --git a/public/translations/de/default.json b/public/translations/de/default.json index 77fcd1fa..1a06f08d 100644 --- a/public/translations/de/default.json +++ b/public/translations/de/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Benutzer für <1> Tag(e) sperren", "optional": "optional", "close_thread": "Thread schließen", - "view_spoiler": "Spoiler anzeigen" + "view_spoiler": "Spoiler anzeigen", + "filter": "filtern" } \ No newline at end of file diff --git a/public/translations/el/default.json b/public/translations/el/default.json index d58dd2af..6253bbe1 100644 --- a/public/translations/el/default.json +++ b/public/translations/el/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Αποκλεισμός χρήστη για <1> ημέρα(ες)", "optional": "προαιρετικό", "close_thread": "κλείσιμο νήματος", - "view_spoiler": "προβολή spoiler" + "view_spoiler": "προβολή spoiler", + "filter": "φίλτρο" } \ No newline at end of file diff --git a/public/translations/en/default.json b/public/translations/en/default.json index 8bcc2f65..2afb5e6f 100644 --- a/public/translations/en/default.json +++ b/public/translations/en/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Ban user for <1> day(s)", "optional": "optional", "close_thread": "close thread", - "view_spoiler": "view spoiler" + "view_spoiler": "view spoiler", + "filter": "filter" } \ No newline at end of file diff --git a/public/translations/es/default.json b/public/translations/es/default.json index ecd6ec2c..1b538e6e 100644 --- a/public/translations/es/default.json +++ b/public/translations/es/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Prohibir al usuario durante <1> día(s)", "optional": "opcional", "close_thread": "cerrar hilo", - "view_spoiler": "ver spoiler" + "view_spoiler": "ver spoiler", + "filter": "filtrar" } \ No newline at end of file diff --git a/public/translations/fa/default.json b/public/translations/fa/default.json index d0fc3715..f8690e5c 100644 --- a/public/translations/fa/default.json +++ b/public/translations/fa/default.json @@ -146,5 +146,6 @@ "ban_user_for": "بستن کاربر برای <1> روز", "optional": "اختیاری", "close_thread": "بستن موضوع", - "view_spoiler": "نمایش اسپویلر" + "view_spoiler": "نمایش اسپویلر", + "filter": "فیلتر" } \ No newline at end of file diff --git a/public/translations/fi/default.json b/public/translations/fi/default.json index 0baf925f..829f1233 100644 --- a/public/translations/fi/default.json +++ b/public/translations/fi/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Estä käyttäjä <1> päiväksi", "optional": "valinnainen", "close_thread": "sulje keskustelu", - "view_spoiler": "näytä spoiler" + "view_spoiler": "näytä spoiler", + "filter": "suodatin" } \ No newline at end of file diff --git a/public/translations/fil/default.json b/public/translations/fil/default.json index 636ae90a..c467d2e8 100644 --- a/public/translations/fil/default.json +++ b/public/translations/fil/default.json @@ -146,5 +146,6 @@ "ban_user_for": "I-ban ang user para sa <1> araw", "optional": "opsyonal", "close_thread": "isara ang thread", - "view_spoiler": "tingnan ang spoiler" + "view_spoiler": "tingnan ang spoiler", + "filter": "salain" } \ No newline at end of file diff --git a/public/translations/fr/default.json b/public/translations/fr/default.json index 2ecfcb75..2fff437d 100644 --- a/public/translations/fr/default.json +++ b/public/translations/fr/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Bannir l'utilisateur pendant <1> jour(s)", "optional": "facultatif", "close_thread": "fermer le fil", - "view_spoiler": "voir le spoiler" + "view_spoiler": "voir le spoiler", + "filter": "filtre" } \ No newline at end of file diff --git a/public/translations/he/default.json b/public/translations/he/default.json index ca61ef47..cd2fba7f 100644 --- a/public/translations/he/default.json +++ b/public/translations/he/default.json @@ -146,5 +146,6 @@ "ban_user_for": "אסור למשתמש למשך <1> יום", "optional": "אופציונלי", "close_thread": "סגור את הנושא", - "view_spoiler": "הצג ספוילר" + "view_spoiler": "הצג ספוילר", + "filter": "סנן" } \ No newline at end of file diff --git a/public/translations/hi/default.json b/public/translations/hi/default.json index 30dbe6bc..1326e1f8 100644 --- a/public/translations/hi/default.json +++ b/public/translations/hi/default.json @@ -146,5 +146,6 @@ "ban_user_for": "उपयोगकर्ता को <1> दिनों के लिए प्रतिबंधित करें", "optional": "वैकल्पिक", "close_thread": "थ्रेड बंद करें", - "view_spoiler": "स्पॉइलर देखें" + "view_spoiler": "स्पॉइलर देखें", + "filter": "फ़िल्टर" } \ No newline at end of file diff --git a/public/translations/hu/default.json b/public/translations/hu/default.json index 521f06de..4cd93844 100644 --- a/public/translations/hu/default.json +++ b/public/translations/hu/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Felhasználó letiltása <1> napra", "optional": "opcionális", "close_thread": "szál bezárása", - "view_spoiler": "spoiler megtekintése" + "view_spoiler": "spoiler megtekintése", + "filter": "szűrő" } \ No newline at end of file diff --git a/public/translations/id/default.json b/public/translations/id/default.json index face6164..2ee91082 100644 --- a/public/translations/id/default.json +++ b/public/translations/id/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Blokir pengguna selama <1> hari", "optional": "opsional", "close_thread": "tutup utas", - "view_spoiler": "lihat spoiler" + "view_spoiler": "lihat spoiler", + "filter": "menyaring" } \ No newline at end of file diff --git a/public/translations/it/default.json b/public/translations/it/default.json index 9e7ccae3..5d0d493d 100644 --- a/public/translations/it/default.json +++ b/public/translations/it/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Banna l'utente per <1> giorno/i", "optional": "opzionale", "close_thread": "chiudi il thread", - "view_spoiler": "mostra spoiler" + "view_spoiler": "mostra spoiler", + "filter": "filtro" } \ No newline at end of file diff --git a/public/translations/ja/default.json b/public/translations/ja/default.json index 4cfae12a..7a84549b 100644 --- a/public/translations/ja/default.json +++ b/public/translations/ja/default.json @@ -146,5 +146,6 @@ "ban_user_for": "ユーザーを<1>日間禁止する", "optional": "オプショナル", "close_thread": "スレッドを閉じる", - "view_spoiler": "スポイラーを表示" + "view_spoiler": "スポイラーを表示", + "filter": "フィルター" } \ No newline at end of file diff --git a/public/translations/ko/default.json b/public/translations/ko/default.json index cdedea3e..b917b922 100644 --- a/public/translations/ko/default.json +++ b/public/translations/ko/default.json @@ -146,5 +146,6 @@ "ban_user_for": "사용자를 <1>일 동안 차단하기", "optional": "선택", "close_thread": "스레드 닫기", - "view_spoiler": "스포일러 보기" + "view_spoiler": "스포일러 보기", + "filter": "필터" } \ No newline at end of file diff --git a/public/translations/mr/default.json b/public/translations/mr/default.json index 30ea7776..a6bb9e11 100644 --- a/public/translations/mr/default.json +++ b/public/translations/mr/default.json @@ -146,5 +146,6 @@ "ban_user_for": "वापरकर्ता ब्लॉक करा <1> दिवस", "optional": "वैकल्पिक", "close_thread": "थ्रेड बंद करा", - "view_spoiler": "स्पॉईलर पहा" + "view_spoiler": "स्पॉईलर पहा", + "filter": "फिल्टर" } \ No newline at end of file diff --git a/public/translations/nl/default.json b/public/translations/nl/default.json index d0dff1b9..c03567f1 100644 --- a/public/translations/nl/default.json +++ b/public/translations/nl/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Gebruiker verbannen voor <1> dag(en)", "optional": "optioneel", "close_thread": "draad sluiten", - "view_spoiler": "bekijk spoiler" + "view_spoiler": "bekijk spoiler", + "filter": "filter" } \ No newline at end of file diff --git a/public/translations/no/default.json b/public/translations/no/default.json index f3f031af..c80a7e11 100644 --- a/public/translations/no/default.json +++ b/public/translations/no/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Blokker bruker i <1> dag(er)", "optional": "valgfritt", "close_thread": "lukk tråd", - "view_spoiler": "se spoiler" + "view_spoiler": "se spoiler", + "filter": "filter" } \ No newline at end of file diff --git a/public/translations/pl/default.json b/public/translations/pl/default.json index 5f80f104..07c92ec6 100644 --- a/public/translations/pl/default.json +++ b/public/translations/pl/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Zablokuj użytkownika na <1> dzień (dni)", "optional": "opcjonalnie", "close_thread": "zamknij wątek", - "view_spoiler": "pokaż spoiler" + "view_spoiler": "pokaż spoiler", + "filter": "filtr" } \ No newline at end of file diff --git a/public/translations/pt/default.json b/public/translations/pt/default.json index 96c20be6..4ed41c49 100644 --- a/public/translations/pt/default.json +++ b/public/translations/pt/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Banir usuário por <1> dia(s)", "optional": "opcional", "close_thread": "fechar tópico", - "view_spoiler": "ver spoiler" + "view_spoiler": "ver spoiler", + "filter": "filtro" } \ No newline at end of file diff --git a/public/translations/ro/default.json b/public/translations/ro/default.json index 67d435ae..34b556c7 100644 --- a/public/translations/ro/default.json +++ b/public/translations/ro/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Interzice utilizatorul pentru <1> zi(zile)", "optional": "opțional", "close_thread": "închide firul", - "view_spoiler": "vezi spoilerul" + "view_spoiler": "vezi spoilerul", + "filter": "filtru" } \ No newline at end of file diff --git a/public/translations/ru/default.json b/public/translations/ru/default.json index 0be60134..ec5101bc 100644 --- a/public/translations/ru/default.json +++ b/public/translations/ru/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Заблокировать пользователя на <1> день(дней)", "optional": "необязательный", "close_thread": "закрыть тему", - "view_spoiler": "посмотреть спойлер" + "view_spoiler": "посмотреть спойлер", + "filter": "фильтр" } \ No newline at end of file diff --git a/public/translations/sq/default.json b/public/translations/sq/default.json index 64363bb5..5cd7dd88 100644 --- a/public/translations/sq/default.json +++ b/public/translations/sq/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Ndalo përdoruesin për <1> ditë", "optional": "opsionale", "close_thread": "mbyll temën", - "view_spoiler": "shikoni spoiler" + "view_spoiler": "shikoni spoiler", + "filter": "filtruar" } \ No newline at end of file diff --git a/public/translations/sv/default.json b/public/translations/sv/default.json index 4572c67d..54ab7daa 100644 --- a/public/translations/sv/default.json +++ b/public/translations/sv/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Blockera användaren i <1> dag(ar)", "optional": "valfritt", "close_thread": "stäng tråd", - "view_spoiler": "visa spoiler" + "view_spoiler": "visa spoiler", + "filter": "filter" } \ No newline at end of file diff --git a/public/translations/te/default.json b/public/translations/te/default.json index 2977b0df..a6bfdc5d 100644 --- a/public/translations/te/default.json +++ b/public/translations/te/default.json @@ -146,5 +146,6 @@ "ban_user_for": "<1> రోజుల కోసం వాడుకరినీ బ్యాన్ చేయండి", "optional": "ఐచ్ఛికం", "close_thread": "థ్రెడ్‌ను మూసేయండి", - "view_spoiler": "స్పోయ్లర్ వీక్షించండి" + "view_spoiler": "స్పోయ్లర్ వీక్షించండి", + "filter": "వడపోత" } \ No newline at end of file diff --git a/public/translations/th/default.json b/public/translations/th/default.json index e7f31758..1c1da9ec 100644 --- a/public/translations/th/default.json +++ b/public/translations/th/default.json @@ -146,5 +146,6 @@ "ban_user_for": "แบนผู้ใช้ <1> วัน", "optional": "ไม่จำเป็น", "close_thread": "ปิดกระทู้", - "view_spoiler": "ดูสปอยล์เลอร์" + "view_spoiler": "ดูสปอยล์เลอร์", + "filter": "ตัวกรอง" } \ No newline at end of file diff --git a/public/translations/tr/default.json b/public/translations/tr/default.json index c73e33b7..2203c0ff 100644 --- a/public/translations/tr/default.json +++ b/public/translations/tr/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Kullanıcıyı <1> gün boyunca yasakla", "optional": "isteğe bağlı", "close_thread": "konuyu kapat", - "view_spoiler": "spoileri görüntüle" + "view_spoiler": "spoileri görüntüle", + "filter": "filtre" } \ No newline at end of file diff --git a/public/translations/uk/default.json b/public/translations/uk/default.json index fc9b672f..1a33c0d8 100644 --- a/public/translations/uk/default.json +++ b/public/translations/uk/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Заборонити користувача на <1> день (днів)", "optional": "необов’язково", "close_thread": "закрити тему", - "view_spoiler": "переглянути спойлер" + "view_spoiler": "переглянути спойлер", + "filter": "фільтр" } \ No newline at end of file diff --git a/public/translations/ur/default.json b/public/translations/ur/default.json index 51b4236c..608519cd 100644 --- a/public/translations/ur/default.json +++ b/public/translations/ur/default.json @@ -146,5 +146,6 @@ "ban_user_for": "<1> دنوں کے لیے صارف کو پابندی عائد کریں", "optional": "اختیاری", "close_thread": "موضوع بند کریں", - "view_spoiler": "اسپوائلر دیکھیں" + "view_spoiler": "اسپوائلر دیکھیں", + "filter": "فلٹر" } \ No newline at end of file diff --git a/public/translations/vi/default.json b/public/translations/vi/default.json index 77a5362d..b1a6ff6d 100644 --- a/public/translations/vi/default.json +++ b/public/translations/vi/default.json @@ -146,5 +146,6 @@ "ban_user_for": "Cấm người dùng trong <1> ngày", "optional": "tùy chọn", "close_thread": "đóng chủ đề", - "view_spoiler": "xem spoiler" + "view_spoiler": "xem spoiler", + "filter": "bộ lọc" } \ No newline at end of file diff --git a/public/translations/zh/default.json b/public/translations/zh/default.json index 2ec3071a..59ebefb4 100644 --- a/public/translations/zh/default.json +++ b/public/translations/zh/default.json @@ -146,5 +146,6 @@ "ban_user_for": "封禁用户 <1> 天", "optional": "可选的", "close_thread": "关闭主题", - "view_spoiler": "查看剧透" + "view_spoiler": "查看剧透", + "filter": "过滤器" } \ No newline at end of file diff --git a/src/components/topbar/topbar.tsx b/src/components/topbar/topbar.tsx index 0c746d3e..c5e5ba92 100644 --- a/src/components/topbar/topbar.tsx +++ b/src/components/topbar/topbar.tsx @@ -8,7 +8,6 @@ import useDefaultSubplebbits, { categorizeSubplebbits, useDefaultSubplebbitAddre import _, { debounce } from 'lodash'; const SearchBar = ({ setShowSearchBar }: { setShowSearchBar: (show: boolean) => void }) => { - const { t } = useTranslation(); const navigate = useNavigate(); const searchBarRef = useRef(null); const searchInputRef = useRef(null); diff --git a/src/views/home/home.module.css b/src/views/home/home.module.css index 721bb6c3..0bad3b19 100644 --- a/src/views/home/home.module.css +++ b/src/views/home/home.module.css @@ -27,6 +27,7 @@ .boardsBox { overflow: hidden; + min-height: 150px; } .boxBar, .infoboxBar { @@ -79,7 +80,7 @@ color: var(--homepage-infobox-link-text-color); } -.searchBar { +.searchBar form { display: flex; text-align: center; justify-content: center; @@ -104,7 +105,7 @@ padding: 3px 10px; } -.searchBar button { +.searchButton { margin-left: 4px; padding: 3px 5px; display: inline-block; @@ -112,6 +113,41 @@ font-size: 14px; white-space: nowrap; flex-shrink: 0; + cursor: pointer; +} + +.filterModal { + position: absolute; + top: 30px; + right: 5px; + display: inline-block; + position: absolute; + text-align: right; + background: #fff; + border: 1px solid gray; + box-shadow: 2px 2px 0 1px rgba(0, 0, 0, .1); + padding: 4px 0; + line-height: 1.7em; + z-index: 100; +} + +.filterModal .separator { + border-bottom: 1px solid #ccc; + margin: 6px 0 4px; + padding: 0; +} + +.filterModal .option { + padding: 0 10px; +} + +.filterModal .option:hover { + background-color: #fca; + cursor: pointer; +} + +.filterModal .selected::before { + content: '✔ '; } .capitalize { diff --git a/src/views/home/home.tsx b/src/views/home/home.tsx index cfbd77c8..d784a474 100644 --- a/src/views/home/home.tsx +++ b/src/views/home/home.tsx @@ -1,9 +1,10 @@ -import { useEffect, useMemo, useRef } from 'react'; -import styles from './home.module.css'; +import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { Link, useNavigate } from 'react-router-dom'; import { Trans, useTranslation } from 'react-i18next'; import { Comment, Subplebbit, useAccount, useAccountSubplebbits, useSubplebbits } from '@plebbit/plebbit-react-hooks'; import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js'; +import { create } from 'zustand'; +import styles from './home.module.css'; import packageJson from '../../../package.json'; import useDefaultSubplebbits, { useMultisubMetadata, useDefaultSubplebbitAddresses } from '../../hooks/use-default-subplebbits'; import usePopularPosts from '../../hooks/use-popular-posts'; @@ -12,12 +13,32 @@ import { getCommentMediaInfo } from '../../lib/utils/media-utils'; import { CatalogPostMedia } from '../../components/catalog-row'; import LoadingEllipsis from '../../components/loading-ellipsis'; -const isValidAddress = (address: string): boolean => { - if (address.includes('/') || address.includes('\\') || address.includes(' ')) { - return false; - } - return true; -}; +interface BoxModalStore { + showNsfwBoardsOnly: boolean; + setShowNsfwBoardsOnly: (value: boolean) => void; + showWorksafeBoardsOnly: boolean; + setShowWorksafeBoardsOnly: (value: boolean) => void; + useCatalog: boolean; + setUseCatalog: (value: boolean) => void; +} + +const useBoxModalStore = create((set) => ({ + showNsfwBoardsOnly: localStorage.getItem('showNsfwBoardsOnly') === 'true' ? true : false, + setShowNsfwBoardsOnly: (value: boolean) => { + set({ showNsfwBoardsOnly: value }); + localStorage.setItem('showNsfwBoardsOnly', value.toString()); + }, + showWorksafeBoardsOnly: localStorage.getItem('showWorksafeBoardsOnly') === 'true' ? true : false, + setShowWorksafeBoardsOnly: (value: boolean) => { + set({ showWorksafeBoardsOnly: value }); + localStorage.setItem('showWorksafeBoardsOnly', value.toString()); + }, + useCatalog: localStorage.getItem('useCatalog') === 'true' ? true : false, + setUseCatalog: (value: boolean) => { + set({ useCatalog: value }); + localStorage.setItem('useCatalog', value.toString()); + }, +})); const SearchBar = () => { const searchInputRef = useRef(null); @@ -25,32 +46,26 @@ const SearchBar = () => { const navigate = useNavigate(); const handleSearchSubmit = () => { - const inputValue = searchInputRef.current?.value; - if (inputValue && isValidAddress(inputValue)) { - navigate(`/p/${inputValue}`); - } else { - alert('invalid address'); + const searchInput = searchInputRef.current?.value; + if (searchInput) { + navigate(`/p/${searchInput}`); } }; return (
- { - if (e.key === 'Enter') { - handleSearchSubmit(); - } - }} - /> - +
+ + +
); }; @@ -72,35 +87,145 @@ const InfoBox = () => { ); }; +// https://github.com/plebbit/temporary-default-subplebbits/blob/master/README.md +const nsfwTags = ['adult', 'anti', 'gore']; + const Board = ({ isOffline, subplebbit }: { isOffline: boolean; subplebbit: Subplebbit }) => { const { t } = useTranslation(); const { address, title, tags } = subplebbit || {}; - const nsfwTags = ['adult', 'gore']; const nsfwTag = tags.find((tag: string) => nsfwTags.includes(tag)); + const { useCatalog } = useBoxModalStore(); + + const boardLink = useCatalog ? `/p/${address}/catalog` : `/p/${address}`; return (
{isOffline && } - {title || address} + {title || address} {nsfwTag && ({t(nsfwTag)})}
); }; +const BoxModal = ({ isBoardsBoxModal }: { isBoardsBoxModal: boolean }) => { + const { t } = useTranslation(); + const [showFilterModal, setShowFilterModal] = useState(false); + const modalRef = useRef(null); + + const { showNsfwBoardsOnly, setShowNsfwBoardsOnly, showWorksafeBoardsOnly, setShowWorksafeBoardsOnly, useCatalog, setUseCatalog } = useBoxModalStore(); + + const handleClickOutside = useCallback( + (event: MouseEvent) => { + if (modalRef.current && !modalRef.current.contains(event.target as Node)) { + setShowFilterModal(false); + } + }, + [modalRef, setShowFilterModal], + ); + + useEffect(() => { + document.addEventListener('mousedown', handleClickOutside); + return () => { + document.removeEventListener('mousedown', handleClickOutside); + }; + }, [handleClickOutside]); + + return ( + <> + setShowFilterModal(true)}> + {isBoardsBoxModal ? t('filter') : t('options')} ▼ + + {showFilterModal && ( +
+ {isBoardsBoxModal ? ( + <> +
{ + setShowNsfwBoardsOnly(false); + setShowWorksafeBoardsOnly(false); + setShowFilterModal(false); + }} + > + Show All Boards +
+
{ + if (showWorksafeBoardsOnly) { + setShowWorksafeBoardsOnly(false); + } + setShowNsfwBoardsOnly(!showNsfwBoardsOnly); + setShowFilterModal(false); + }} + > + Show NSFW Boards Only +
+
{ + if (showNsfwBoardsOnly) { + setShowNsfwBoardsOnly(false); + } + setShowWorksafeBoardsOnly(!showWorksafeBoardsOnly); + setShowFilterModal(false); + }} + > + Show Worksafe Boards Only +
+
+
{ + setUseCatalog(!useCatalog); + setShowFilterModal(false); + }} + > + Use Catalog +
+ + ) : ( + <> +
Show Worksafe Content Only
+
Show NSFW Content Only
+
Show All Content
+ + )} +
+ )} + + ); +}; + const Boards = ({ multisub, subplebbits }: { multisub: Subplebbit[]; subplebbits: any }) => { const { t } = useTranslation(); const account = useAccount(); const subscriptions = account?.subscriptions || []; const { accountSubplebbits } = useAccountSubplebbits(); const accountSubplebbitAddresses = Object.keys(accountSubplebbits); + const { showNsfwBoardsOnly, showWorksafeBoardsOnly } = useBoxModalStore(); - const plebbitSubs = multisub.filter((sub) => sub.tags?.includes('plebbit')); - const interestsSubs = multisub.filter( - (sub) => sub.tags?.includes('topic') && !sub.tags?.includes('plebbit') && !sub.tags?.includes('country') && !sub.tags?.includes('international'), - ); - const randomSubs = multisub.filter((sub) => sub.tags?.includes('random') && !sub.tags?.includes('plebbit')); - const internationalSubs = multisub.filter((sub) => sub.tags?.includes('international') || sub.tags?.includes('country')); - const projectsSubs = multisub.filter((sub) => sub.tags?.includes('project') && !sub.tags?.includes('plebbit') && !sub.tags?.includes('topic')); + const filterSubs = (subs: Subplebbit[], includeTags: string[], excludeTags: string[] = []) => + subs.filter((sub) => includeTags.every((tag) => sub.tags?.includes(tag)) && excludeTags.every((tag) => !sub.tags?.includes(tag))); + + let plebbitSubs = filterSubs(multisub, ['plebbit']); + let interestsSubs = filterSubs(multisub, ['topic'], ['plebbit', 'country', 'international']); + let randomSubs = filterSubs(multisub, ['random'], ['plebbit']); + let internationalSubs = filterSubs(multisub, ['international']); + let projectsSubs = filterSubs(multisub, ['project'], ['plebbit', 'topic']); + + const filterByNsfw = (subs: Subplebbit[], includeNsfw: boolean) => subs.filter((sub) => sub.tags.some((tag: string) => nsfwTags.includes(tag)) === includeNsfw); + + const filterCategoriesByNsfw = (subsArray: Subplebbit[][], includeNsfw: boolean) => subsArray.map((subs) => filterByNsfw(subs, includeNsfw)); + + const includeNsfw = showNsfwBoardsOnly ? true : showWorksafeBoardsOnly ? false : null; + + if (includeNsfw !== null) { + [plebbitSubs, interestsSubs, randomSubs, internationalSubs, projectsSubs] = filterCategoriesByNsfw( + [plebbitSubs, interestsSubs, randomSubs, internationalSubs, projectsSubs], + includeNsfw, + ); + } const isSubOffline = (address: string) => { const subplebbit = subplebbits && subplebbits.find((sub: Subplebbit) => sub?.address === address); @@ -113,7 +238,7 @@ const Boards = ({ multisub, subplebbits }: { multisub: Subplebbit[]; subplebbits

{t('boards')}

- {t('options')} ▼ +
@@ -126,40 +251,60 @@ const Boards = ({ multisub, subplebbits }: { multisub: Subplebbit[]; subplebbits Subscriptions
-

Plebbit

-
- {plebbitSubs.map((sub) => ( - - ))} -
-

{t('projects')}

-
- {projectsSubs.map((sub) => ( - - ))} -
+ {plebbitSubs.length > 0 && ( + <> +

Plebbit

+
+ {plebbitSubs.map((sub) => ( + + ))} +
+ + )} + {projectsSubs.length > 0 && ( + <> +

{t('projects')}

+
+ {projectsSubs.map((sub) => ( + + ))} +
+ + )}
-

{t('interests')}

-
- {interestsSubs.map((sub) => ( - - ))} -
+ {interestsSubs.length > 0 && ( + <> +

{t('interests')}

+
+ {interestsSubs.map((sub) => ( + + ))} +
+ + )}
-

{t('random')}

-
- {randomSubs.map((sub) => ( - - ))} -
-

{t('international')}

-
- {internationalSubs.map((sub) => ( - - ))} -
+ {randomSubs.length > 0 && ( + <> +

{t('random')}

+
+ {randomSubs.map((sub) => ( + + ))} +
+ + )} + {internationalSubs.length > 0 && ( + <> +

{t('international')}

+
+ {internationalSubs.map((sub) => ( + + ))} +
+ + )}
@@ -222,7 +367,7 @@ const PopularThreads = ({ subplebbits }: { subplebbits: any }) => {

{t('popular_threads')}

- {t('options')} ▼ +
{popularPosts.length < 8 ? ( @@ -268,9 +413,6 @@ const Stats = ({ multisub, subplebbitAddresses }: { multisub: any; subplebbitAdd

{t('stats')}

- {/*
-

{t('stats_info')}

-
*/} {enoughStats ? ( <>