feat: add p/mod feed for all subs the user moderates

This commit is contained in:
Tom (plebeius.eth)
2025-03-05 17:38:34 +01:00
parent 8557ebb3a7
commit ba5753d85e
42 changed files with 133 additions and 68 deletions
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "تم حذف هذا الموضوع بواسطة مؤلفه",
"this_thread_was_removed": "تم إزالة هذا الموضوع بواسطة مشرفي المنتدى",
"this_reply_was_deleted": "تم حذف هذه الرد من قبل مؤلفه",
"this_reply_was_removed": "تمت إزالة هذه الرد من قبل مشرفي المنتدى"
"this_reply_was_removed": "تمت إزالة هذه الرد من قبل مشرفي المنتدى",
"not_mod_of_any_board": "أنت لست مشرفًا في أي لوحة."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "এই থ্রেডটি এর লেখক দ্বারা মুছে ফেলা হয়েছে",
"this_thread_was_removed": "এই থ্রেডটি বোর্ড moderators দ্বারা মুছে ফেলা হয়েছে",
"this_reply_was_deleted": "এই প্রতিক্রিয়া তার লেখক দ্বারা মুছে ফেলা হয়েছে",
"this_reply_was_removed": "এই প্রতিক্রিয়া বোর্ড পরিচালকদের দ্বারা সরানো হয়েছে"
"this_reply_was_removed": "এই প্রতিক্রিয়া বোর্ড পরিচালকদের দ্বারা সরানো হয়েছে",
"not_mod_of_any_board": "আপনি কোনও বোর্ডের মড নন।"
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Toto vlákno bylo smazáno jeho autorem",
"this_thread_was_removed": "Toto vlákno bylo odstraněno moderátory fóra",
"this_reply_was_deleted": "Tato odpověď byla smazána autorem",
"this_reply_was_removed": "Tato odpověď byla odstraněna moderátory fóra"
"this_reply_was_removed": "Tato odpověď byla odstraněna moderátory fóra",
"not_mod_of_any_board": "Nejste moderátor žádné desky."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Denne tråd blev slettet af dens forfatter",
"this_thread_was_removed": "Denne tråd blev fjernet af boardmoderatorer",
"this_reply_was_deleted": "Dette svar blev slettet af forfatteren",
"this_reply_was_removed": "Dette svar blev fjernet af forummoderatorer"
"this_reply_was_removed": "Dette svar blev fjernet af forummoderatorer",
"not_mod_of_any_board": "Du er ikke moderator for nogen tavler."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Dieser Thread wurde von seinem Autor gelöscht",
"this_thread_was_removed": "Dieser Thread wurde von den Moderatoren des Boards entfernt",
"this_reply_was_deleted": "Diese Antwort wurde vom Autor gelöscht",
"this_reply_was_removed": "Diese Antwort wurde von den Forenmoderatoren entfernt"
"this_reply_was_removed": "Diese Antwort wurde von den Forenmoderatoren entfernt",
"not_mod_of_any_board": "Du bist kein Moderator eines Boards."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Αυτή η συζήτηση διαγράφηκε από τον συγγραφέα της",
"this_thread_was_removed": "Αυτή η συζήτηση αφαιρέθηκε από τους διαχειριστές του φόρουμ",
"this_reply_was_deleted": "Αυτή η απάντηση διαγράφηκε από τον συγγραφέα της",
"this_reply_was_removed": "Η απάντηση αυτή αφαιρέθηκε από τους διαχειριστές του φόρουμ"
"this_reply_was_removed": "Η απάντηση αυτή αφαιρέθηκε από τους διαχειριστές του φόρουμ",
"not_mod_of_any_board": "Δεν είστε διαχειριστής σε καμία κοινότητα."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "This thread was deleted by its author",
"this_thread_was_removed": "This thread was removed by board moderators",
"this_reply_was_deleted": "This reply was deleted by its author",
"this_reply_was_removed": "This reply was removed by board moderators"
"this_reply_was_removed": "This reply was removed by board moderators",
"not_mod_of_any_board": "You are not a mod of any board."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Este hilo fue eliminado por su autor",
"this_thread_was_removed": "Este hilo fue eliminado por los moderadores del foro",
"this_reply_was_deleted": "Esta respuesta fue eliminada por su autor",
"this_reply_was_removed": "Esta respuesta fue eliminada por los moderadores del foro"
"this_reply_was_removed": "Esta respuesta fue eliminada por los moderadores del foro",
"not_mod_of_any_board": "No eres moderador de ningún tablero."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "این موضوع توسط نویسنده‌اش حذف شد",
"this_thread_was_removed": "این تاپیک توسط مدیران انجمن حذف شد",
"this_reply_was_deleted": "این پاسخ توسط نویسنده‌اش حذف شد",
"this_reply_was_removed": "این پاسخ توسط مدیران انجمن حذف شد"
"this_reply_was_removed": "این پاسخ توسط مدیران انجمن حذف شد",
"not_mod_of_any_board": "شما هیچ تابلو مدیر نیستید."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Tämä ketju poistettiin sen kirjoittajan toimesta",
"this_thread_was_removed": "Tämä ketju poistettiin foorumin moderaattoreiden toimesta",
"this_reply_was_deleted": "Tämä vastaus poistettiin sen kirjoittajalta",
"this_reply_was_removed": "Tämä vastaus poistettiin foorumin moderaattoreiden toimesta"
"this_reply_was_removed": "Tämä vastaus poistettiin foorumin moderaattoreiden toimesta",
"not_mod_of_any_board": "Et ole moderaattori missään taulussa."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Ang thread na ito ay tinanggal ng may-akda nito",
"this_thread_was_removed": "Inalis ang thread na ito ng mga moderator ng board",
"this_reply_was_deleted": "Ang tugon na ito ay tinanggal ng may-akda nito",
"this_reply_was_removed": "Ang sagot na ito ay tinanggal ng mga moderator ng board"
"this_reply_was_removed": "Ang sagot na ito ay tinanggal ng mga moderator ng board",
"not_mod_of_any_board": "Hindi ka mod ng anumang board."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Ce sujet a été supprimé par son auteur",
"this_thread_was_removed": "Ce sujet a été supprimé par les modérateurs du forum",
"this_reply_was_deleted": "Cette réponse a été supprimée par son auteur",
"this_reply_was_removed": "Cette réponse a été supprimée par les modérateurs du forum"
"this_reply_was_removed": "Cette réponse a été supprimée par les modérateurs du forum",
"not_mod_of_any_board": "Vous n'êtes pas modérateur de n'aucun forum."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "השרשור הזה נמחק על ידי המחבר שלו",
"this_thread_was_removed": "השרשור הזה הוסר על ידי מנהלי הפורום",
"this_reply_was_deleted": "תשובה זו נמחקה על ידי המחבר שלה",
"this_reply_was_removed": "תשובה זו הוסרה על ידי מנהלי הפורום"
"this_reply_was_removed": "תשובה זו הוסרה על ידי מנהלי הפורום",
"not_mod_of_any_board": "אתה לא מוד בכל לוח."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "इस थ्रेड को इसके लेखक ने हटा दिया है",
"this_thread_was_removed": "यह थ्रेड बोर्ड मॉडरेटर्स द्वारा हटा दिया गया था",
"this_reply_was_deleted": "इस उत्तर को इसके लेखक द्वारा हटा दिया गया था",
"this_reply_was_removed": "यह उत्तर बोर्ड मॉडरेटर द्वारा हटा दिया गया था"
"this_reply_was_removed": "यह उत्तर बोर्ड मॉडरेटर द्वारा हटा दिया गया था",
"not_mod_of_any_board": "आप किसी बोर्ड के मॉड नहीं हैं।"
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Ez a szál törlésre került a szerzője által",
"this_thread_was_removed": "Ezt a témát a fórum moderátorai eltávolították",
"this_reply_was_deleted": "Ez a válasz törölve lett a szerzője által",
"this_reply_was_removed": "Ez a válasz törlésre került a fórum moderátorai által"
"this_reply_was_removed": "Ez a válasz törlésre került a fórum moderátorai által",
"not_mod_of_any_board": "Nem vagy moderátor egyetlen táblán sem."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Thread ini dihapus oleh penulisnya",
"this_thread_was_removed": "Thread ini dihapus oleh moderator papan",
"this_reply_was_deleted": "Balasan ini dihapus oleh penulisnya",
"this_reply_was_removed": "Balasan ini dihapus oleh moderator papan"
"this_reply_was_removed": "Balasan ini dihapus oleh moderator papan",
"not_mod_of_any_board": "Anda bukan mod di papan manapun."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Questo thread è stato eliminato dal suo autore",
"this_thread_was_removed": "Questo thread è stato rimosso dai moderatori del board",
"this_reply_was_deleted": "Questa risposta è stata eliminata dal suo autore",
"this_reply_was_removed": "Questa risposta è stata rimossa dai moderatori del forum"
"this_reply_was_removed": "Questa risposta è stata rimossa dai moderatori del forum",
"not_mod_of_any_board": "Non sei un mod di nessuna board."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "このスレッドは著者によって削除されました",
"this_thread_was_removed": "このスレッドはボードのモデレーターによって削除されました",
"this_reply_was_deleted": "この返信はその著者によって削除されました",
"this_reply_was_removed": "この返信は掲示板のモデレーターによって削除されました"
"this_reply_was_removed": "この返信は掲示板のモデレーターによって削除されました",
"not_mod_of_any_board": "あなたはどのボードのモデレーターでもありません。"
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "이 스레드는 작성자에 의해 삭제되었습니다",
"this_thread_was_removed": "이 스레드는 보드 관리자에 의해 제거되었습니다",
"this_reply_was_deleted": "이 답글은 작성자에 의해 삭제되었습니다",
"this_reply_was_removed": "이 답글은 게시판 관리자에 의해 삭제되었습니다"
"this_reply_was_removed": "이 답글은 게시판 관리자에 의해 삭제되었습니다",
"not_mod_of_any_board": "당신은 어떤 게시판의 관리자도 아닙니다."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "हा धागा त्याच्या लेखकाने हटविला",
"this_thread_was_removed": "हे थ्रेड बोर्ड मध्यमाने काढले गेले आहे",
"this_reply_was_deleted": "हा प्रतिसाद त्याच्या लेखकाने हटवला आहे",
"this_reply_was_removed": "या उत्तराला बोर्ड मॉडरेटरने काढले आहे"
"this_reply_was_removed": "या उत्तराला बोर्ड मॉडरेटरने काढले आहे",
"not_mod_of_any_board": "तुम्ही कोणत्याही बोर्डचे मॉड नाहीत."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Dit draadje is verwijderd door de auteur",
"this_thread_was_removed": "Deze thread werd verwijderd door boardmoderators",
"this_reply_was_deleted": "Dit antwoord werd verwijderd door de auteur",
"this_reply_was_removed": "Dit antwoord is verwijderd door de forum moderators"
"this_reply_was_removed": "Dit antwoord is verwijderd door de forum moderators",
"not_mod_of_any_board": "Je bent geen mod van een bord."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Denne tråden ble slettet av forfatteren",
"this_thread_was_removed": "Denne tråden ble fjernet av boardmoderatorer",
"this_reply_was_deleted": "Dette svaret ble slettet av forfatteren",
"this_reply_was_removed": "Dette svaret ble fjernet av forummoderatorer"
"this_reply_was_removed": "Dette svaret ble fjernet av forummoderatorer",
"not_mod_of_any_board": "Du er ikke moderator på noen brett."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Wątek ten został usunięty przez jego autora",
"this_thread_was_removed": "Wątek został usunięty przez moderatorów forum",
"this_reply_was_deleted": "Ta odpowiedź została usunięta przez autora",
"this_reply_was_removed": "Ta odpowiedź została usunięta przez moderatorów forum"
"this_reply_was_removed": "Ta odpowiedź została usunięta przez moderatorów forum",
"not_mod_of_any_board": "Nie jesteś moderatorem żadnej tablicy."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Este tópico foi excluído pelo seu autor",
"this_thread_was_removed": "Este tópico foi removido pelos moderadores do fórum",
"this_reply_was_deleted": "Esta resposta foi excluída pelo autor",
"this_reply_was_removed": "Esta resposta foi removida pelos moderadores do fórum"
"this_reply_was_removed": "Esta resposta foi removida pelos moderadores do fórum",
"not_mod_of_any_board": "Você não é um moderador de nenhum quadro."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Acest thread a fost șters de autorul său",
"this_thread_was_removed": "Acest thread a fost eliminat de moderatorii board-ului",
"this_reply_was_deleted": "Acest răspuns a fost șters de autorul său",
"this_reply_was_removed": "Acest răspuns a fost eliminat de moderatorii forumului"
"this_reply_was_removed": "Acest răspuns a fost eliminat de moderatorii forumului",
"not_mod_of_any_board": "Nu ești moderator pe niciun tablou."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Эта тема была удалена её автором",
"this_thread_was_removed": "Эта тема была удалена модераторами форума",
"this_reply_was_deleted": "Этот ответ был удален автором",
"this_reply_was_removed": "Этот ответ был удален модераторами форума"
"this_reply_was_removed": "Этот ответ был удален модераторами форума",
"not_mod_of_any_board": "Вы не модератор ни одной доски."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Ky thread u fshi nga autori i tij",
"this_thread_was_removed": "Ky thread u hoq nga moderatorët e bordit",
"this_reply_was_deleted": "Ky përgjigje u fshi nga autori i saj",
"this_reply_was_removed": "Ky përgjigje u hoq nga moderatorët e forumit"
"this_reply_was_removed": "Ky përgjigje u hoq nga moderatorët e forumit",
"not_mod_of_any_board": "Nuk jeni mod në asnjë bord."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Denna tråd raderades av dess författare",
"this_thread_was_removed": "Denna tråd togs bort av forumets moderatorer",
"this_reply_was_deleted": "Detta svar togs bort av författaren",
"this_reply_was_removed": "Detta svar togs bort av forumets moderatorer"
"this_reply_was_removed": "Detta svar togs bort av forumets moderatorer",
"not_mod_of_any_board": "Du är inte moderator på någon tavla."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "ఈ థ్రెడ్‌ను దాని రచయిత తొలగించారు",
"this_thread_was_removed": "ఈ థ్రెడ్ బోర్డ్ మోడరేటర్ల ద్వారా తీసివేయబడింది",
"this_reply_was_deleted": "ఈ స్పందనను దాని రచయిత తొలగించారు",
"this_reply_was_removed": "ఈ స్పందన బోర్డ్ మోడరేటర్లచే తొలగించబడింది"
"this_reply_was_removed": "ఈ స్పందన బోర్డ్ మోడరేటర్లచే తొలగించబడింది",
"not_mod_of_any_board": "మీరు ఎటువంటి బోర్డుకు మోడ్ కంటే లేరు."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "กระทู้นี้ถูกลบโดยผู้แต่ง",
"this_thread_was_removed": "กระทู้นี้ถูกลบโดยผู้ดูแลบอร์ด",
"this_reply_was_deleted": "การตอบกลับนี้ถูกลบโดยผู้แต่ง",
"this_reply_was_removed": "คำตอบนี้ถูกลบโดยผู้ดูแลบอร์ด"
"this_reply_was_removed": "คำตอบนี้ถูกลบโดยผู้ดูแลบอร์ด",
"not_mod_of_any_board": "คุณไม่ใช่ผู้ดูแลบอร์ดใดๆ"
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Bu başlık, yazarının tarafından silindi",
"this_thread_was_removed": "Bu konu, board moderatörleri tarafından kaldırıldı",
"this_reply_was_deleted": "Bu yanıt, yazar tarafından silindi",
"this_reply_was_removed": "Bu yanıt, forum moderatörleri tarafından kaldırıldı"
"this_reply_was_removed": "Bu yanıt, forum moderatörleri tarafından kaldırıldı",
"not_mod_of_any_board": "Hiçbir tahtanın moderatörü değilsiniz."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Цю тему видалив її автор",
"this_thread_was_removed": "Цю тему було видалено модераторами форуму",
"this_reply_was_deleted": "Цю відповідь було видалено її автором",
"this_reply_was_removed": "Цю відповідь було видалено модераторами форуму"
"this_reply_was_removed": "Цю відповідь було видалено модераторами форуму",
"not_mod_of_any_board": "Ви не модератор жодної дошки."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "اس تھریڈ کو اس کے مصنف نے حذف کیا",
"this_thread_was_removed": "اس تھریڈ کو بورڈ کے موڈریٹرز نے ہٹا دیا ہے",
"this_reply_was_deleted": "اس جواب کو اس کے مصنف نے حذف کر دیا تھا",
"this_reply_was_removed": "اس جواب کو بورڈ کے منتظمین نے حذف کر دیا ہے"
"this_reply_was_removed": "اس جواب کو بورڈ کے منتظمین نے حذف کر دیا ہے",
"not_mod_of_any_board": "آپ کسی بورڈ کے موڈ نہیں ہیں۔"
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "Chủ đề này đã bị tác giả của nó xóa",
"this_thread_was_removed": "Chủ đề này đã bị các quản trị viên diễn đàn xóa",
"this_reply_was_deleted": "Câu trả lời này đã bị tác giả của nó xóa",
"this_reply_was_removed": "Phản hồi này đã bị xóa bởi các quản trị viên diễn đàn"
"this_reply_was_removed": "Phản hồi này đã bị xóa bởi các quản trị viên diễn đàn",
"not_mod_of_any_board": "Bạn không phải là quản trị viên của bất kỳ bảng nào."
}
+2 -1
View File
@@ -290,5 +290,6 @@
"this_thread_was_deleted": "该线程已被其作者删除",
"this_thread_was_removed": "此帖子已被论坛版主删除",
"this_reply_was_deleted": "该回复已被其作者删除",
"this_reply_was_removed": "该回复已被版主删除"
"this_reply_was_removed": "该回复已被版主删除",
"not_mod_of_any_board": "您不是任何板块的管理员。"
}
+5
View File
@@ -147,6 +147,11 @@ const App = () => {
<Route path='/p/subscriptions/catalog/:timeFilterName?' element={<Catalog />} />
<Route path='/p/subscriptions/catalog/:timeFilterName?/settings' element={<Catalog />} />
<Route path='/p/mod/:timeFilterName?' element={<Board />} />
<Route path='/p/mod/:timeFilterName?/settings' element={<Board />} />
<Route path='/p/mod/catalog/:timeFilterName?' element={<Catalog />} />
<Route path='/p/mod/catalog/:timeFilterName?/settings' element={<Catalog />} />
<Route path='/profile/:accountCommentIndex' element={<PendingPost />} />
<Route path='/profile/:accountCommentIndex/settings' element={<PendingPost />} />
</Route>
+5 -5
View File
@@ -1,7 +1,7 @@
import { useState } from 'react';
import { useLocation, useParams } from 'react-router-dom';
import { useAccountComment, useSubplebbit } from '@plebbit/plebbit-react-hooks';
import { isAllView, isSubscriptionsView } from '../../lib/utils/view-utils';
import { isAllView, isSubscriptionsView, isModView } from '../../lib/utils/view-utils';
import styles from './board-header.module.css';
import { useMultisubMetadata } from '../../hooks/use-default-subplebbits';
import useIsMobile from '../../hooks/use-is-mobile';
@@ -25,7 +25,7 @@ const BoardHeader = () => {
const params = useParams();
const isInAllView = isAllView(location.pathname);
const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
const isInModView = isModView(location.pathname);
const accountComment = useAccountComment({ commentIndex: params?.accountCommentIndex as any });
const subplebbitAddress = params?.subplebbitAddress || accountComment?.subplebbitAddress;
@@ -33,8 +33,8 @@ const BoardHeader = () => {
const { address, shortAddress } = subplebbit || {};
const multisubMetadata = useMultisubMetadata();
const title = isInAllView ? multisubMetadata?.title || 'all' : isInSubscriptionsView ? 'Subscriptions' : subplebbit?.title;
const subtitle = isInAllView ? 'p/all' : isInSubscriptionsView ? 'p/subscriptions' : `p/${address}`;
const title = isInAllView ? multisubMetadata?.title || 'all' : isInSubscriptionsView ? 'Subscriptions' : isInModView ? 'Mod' : subplebbit?.title;
const subtitle = isInAllView ? 'p/all' : isInSubscriptionsView ? 'p/subscriptions' : isInModView ? 'p/mod' : `p/${address}`;
const { isOffline, isOnlineStatusLoading, offlineIconClass, offlineTitle } = useIsSubplebbitOffline(subplebbit);
@@ -47,7 +47,7 @@ const BoardHeader = () => {
)}
<div className={styles.boardTitle}>
{title || (shortAddress ? (shortAddress.endsWith('.eth') || shortAddress.endsWith('.sol') ? shortAddress.slice(0, -4) : shortAddress) : subplebbitAddress)}
{(isOffline || isOnlineStatusLoading) && !isInAllView && !isInSubscriptionsView && (
{(isOffline || isOnlineStatusLoading) && !isInAllView && !isInSubscriptionsView && !isInModView && (
<span className={styles.offlineIconWrapper}>
<Tooltip content={offlineTitle}>
<span className={`${styles.offlineIcon} ${offlineIconClass}`} />
+16 -2
View File
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
import { Link, useLocation, useNavigate, useParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import Plebbit from '@plebbit/plebbit-js/dist/browser/index.js';
import { useAccount, useAccountComment } from '@plebbit/plebbit-react-hooks';
import { useAccount, useAccountComment, useAccountSubplebbits } from '@plebbit/plebbit-react-hooks';
import { isAllView, isCatalogView, isSubscriptionsView } from '../../lib/utils/view-utils';
import { useDefaultSubplebbitAddresses } from '../../hooks/use-default-subplebbits';
import { useAutoSubscribe } from '../../hooks/use-auto-subscribe';
@@ -79,10 +79,20 @@ const TopBarDesktop = () => {
const subscriptions = account?.subscriptions;
const { accountSubplebbits } = useAccountSubplebbits();
const accountSubplebbitAddresses = Object.keys(accountSubplebbits);
return (
<div className={styles.boardNavDesktop}>
<span className={styles.boardList}>
[<Link to='/p/all'>all</Link> / <Link to='/p/subscriptions'>subscriptions</Link>]{' '}
[<Link to='/p/all'>all</Link> / <Link to='/p/subscriptions'>subscriptions</Link>
{accountSubplebbitAddresses.length > 0 && (
<>
{' '}
/ <Link to='/p/mod'>mod</Link>
</>
)}
]{' '}
{subscriptions?.length > 0 && (
<>
[
@@ -137,11 +147,15 @@ const TopBarMobile = ({ subplebbitAddress }: { subplebbitAddress: string }) => {
const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
const selectValue = isInAllView ? 'all' : isInSubscriptionsView ? 'subscriptions' : subplebbitAddress;
const { accountSubplebbits } = useAccountSubplebbits();
const accountSubplebbitAddresses = Object.keys(accountSubplebbits);
const boardSelect = (
<select value={selectValue} onChange={(e) => navigate(`/p/${e.target.value}${isInCatalogView ? '/catalog' : ''}`)}>
{!currentSubplebbitIsInList && subplebbitAddress && <option value={subplebbitAddress}>{displaySubplebbitAddress}</option>}
<option value='all'>all</option>
<option value='subscriptions'>subscriptions</option>
{accountSubplebbitAddresses.length > 0 && <option value='mod'>mod</option>}
{subplebbitAddresses.map((address: any, index: number) => {
const subplebbitAddress = address?.includes('.') ? address : Plebbit.getShortAddress(address);
return (
+4 -2
View File
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
import { useLocation, useParams } from 'react-router-dom';
import useThemeStore from '../stores/use-theme-store';
import { useDefaultSubplebbits } from './use-default-subplebbits';
import { isAllView, isHomeView, isNotFoundView, isPendingPostView, isSubscriptionsView } from '../lib/utils/view-utils';
import { isAllView, isHomeView, isNotFoundView, isPendingPostView, isSubscriptionsView, isModView } from '../lib/utils/view-utils';
import { nsfwTags } from '../constants/nsfwTags';
import { useAccountComment } from '@plebbit/plebbit-react-hooks';
@@ -19,6 +19,7 @@ const useInitialTheme = (pendingPostSubplebbitAddress?: string) => {
const isInNotFoundView = isNotFoundView(location.pathname, params);
const isInAllView = isAllView(location.pathname);
const isInSubscriptionsView = isSubscriptionsView(location.pathname, params);
const isInModView = isModView(location.pathname);
const isInPendingPostView = isPendingPostView(location.pathname, params);
const initialTheme = useMemo(() => {
@@ -36,7 +37,7 @@ const useInitialTheme = (pendingPostSubplebbitAddress?: string) => {
} else {
theme = currentTheme || 'yotsuba';
}
} else if (isInAllView || isInSubscriptionsView) {
} else if (isInAllView || isInSubscriptionsView || isInModView) {
theme = getTheme('sfw', false) || 'yotsuba-b'; // Add 'false' parameter
} else if (isInHomeView || isInNotFoundView) {
theme = 'yotsuba';
@@ -54,6 +55,7 @@ const useInitialTheme = (pendingPostSubplebbitAddress?: string) => {
isInPendingPostView,
isInAllView,
isInSubscriptionsView,
isInModView,
isInHomeView,
isInNotFoundView,
paramsSubplebbitAddress,
+9 -13
View File
@@ -1,6 +1,6 @@
import { useState, useEffect, useCallback } from 'react';
import { useLocation, useParams } from 'react-router-dom';
import { isAllView, isSubscriptionsView } from '../lib/utils/view-utils';
import { isAllView, isSubscriptionsView, isModView } from '../lib/utils/view-utils';
import useThemeStore from '../stores/use-theme-store';
import { useDefaultSubplebbits } from './use-default-subplebbits';
import useInitialTheme from './use-initial-theme';
@@ -37,26 +37,24 @@ const useTheme = (): [string, (theme: string) => void] => {
const isInAllView = isAllView(location.pathname);
const isInSubscriptionsView = isSubscriptionsView(location.pathname, params);
const isInModView = isModView(location.pathname);
const subplebbitAddress = params?.subplebbitAddress || pendingPostSubplebbitAddress;
// Check for Christmas and initialize special theme if needed
useEffect(() => {
const isChristmasTime = isChristmas();
const subplebbitAddress = params?.subplebbitAddress || pendingPostSubplebbitAddress;
if (isChristmasTime && isEnabled === null && subplebbitAddress && !isInAllView && !isInSubscriptionsView) {
if (isChristmasTime && isEnabled === null && subplebbitAddress && !isInAllView && !isInSubscriptionsView && !isInModView) {
setIsEnabled(true);
setCurrentTheme('tomorrow');
updateThemeClass('tomorrow');
} else if (!isChristmasTime && isEnabled) {
setIsEnabled(false);
}
}, [isEnabled, setIsEnabled, params, pendingPostSubplebbitAddress, location.pathname, isInAllView, isInSubscriptionsView]);
}, [isEnabled, setIsEnabled, params, pendingPostSubplebbitAddress, location.pathname, isInAllView, isInSubscriptionsView, isInModView, subplebbitAddress]);
const getCurrentTheme = useCallback(() => {
const { isEnabled } = useSpecialThemeStore.getState();
const subplebbitAddress = params?.subplebbitAddress || pendingPostSubplebbitAddress;
const isInAllView = isAllView(location.pathname);
const isInSubscriptionsView = isSubscriptionsView(location.pathname, params);
// Always use yotsuba for home page
if (location.pathname === '/') {
@@ -69,7 +67,7 @@ const useTheme = (): [string, (theme: string) => void] => {
}
let storedTheme = null;
if (isInAllView || isInSubscriptionsView) {
if (isInAllView || isInSubscriptionsView || isInModView) {
storedTheme = getTheme('sfw', false);
} else if (subplebbitAddress) {
const subplebbit = subplebbits.find((s) => s.address === subplebbitAddress);
@@ -81,6 +79,7 @@ const useTheme = (): [string, (theme: string) => void] => {
}
return storedTheme || initialTheme;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [location.pathname, params, getTheme, subplebbits, initialTheme, pendingPostSubplebbitAddress]);
useEffect(() => {
@@ -97,11 +96,7 @@ const useTheme = (): [string, (theme: string) => void] => {
const setSubplebbitTheme = useCallback(
async (newTheme: string) => {
const subplebbitAddress = params?.subplebbitAddress || pendingPostSubplebbitAddress;
const isInAllView = isAllView(location.pathname);
const isInSubscriptionsView = isSubscriptionsView(location.pathname, params);
if (isInAllView || isInSubscriptionsView) {
if (isInAllView || isInSubscriptionsView || isInModView) {
await setThemeStore('sfw', newTheme);
} else if (subplebbitAddress) {
const subplebbit = subplebbits.find((s) => s.address === subplebbitAddress);
@@ -115,6 +110,7 @@ const useTheme = (): [string, (theme: string) => void] => {
setCurrentTheme(newTheme);
updateThemeClass(newTheme);
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[location.pathname, params, setThemeStore, subplebbits, pendingPostSubplebbitAddress],
);
+4
View File
@@ -42,6 +42,10 @@ export const isHomeView = (pathname: string): boolean => {
return pathname === '/';
};
export const isModView = (pathname: string): boolean => {
return pathname === `/p/mod` || pathname.startsWith(`/p/mod/`);
};
export const isPendingPostView = (pathname: string, params: ParamsType): boolean => {
return pathname === `/profile/${params.accountCommentIndex}` || pathname === `/profile/${params.accountCommentIndex}/settings`;
};
+20 -11
View File
@@ -1,12 +1,12 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import { Link, useLocation, useParams } from 'react-router-dom';
import { Comment, useAccount, useAccountComments, useBlock, useFeed, useSubplebbit } from '@plebbit/plebbit-react-hooks';
import { Comment, useAccount, useAccountComments, useAccountSubplebbits, useBlock, useFeed, useSubplebbit } from '@plebbit/plebbit-react-hooks';
import { Virtuoso, VirtuosoHandle, StateSnapshot } from 'react-virtuoso';
import { Trans, useTranslation } from 'react-i18next';
import styles from './board.module.css';
import { shouldShowSnow } from '../../lib/snow';
import { getCommentMediaInfo, getHasThumbnail } from '../../lib/utils/media-utils';
import { isAllView, isSubscriptionsView } from '../../lib/utils/view-utils';
import { isAllView, isSubscriptionsView, isModView } from '../../lib/utils/view-utils';
import { useDefaultSubplebbitAddresses } from '../../hooks/use-default-subplebbits';
import { useFeedStateString } from '../../hooks/use-state-string';
import useTimeFilter from '../../hooks/use-time-filter';
@@ -41,6 +41,10 @@ const Board = () => {
const subscriptions = account?.subscriptions;
const isInSubscriptionsView = isSubscriptionsView(location.pathname, useParams());
const isInModView = isModView(location.pathname);
const { accountSubplebbits } = useAccountSubplebbits();
const accountSubplebbitAddresses = Object.keys(accountSubplebbits);
const subplebbitAddresses = useMemo(() => {
if (isInAllView) {
return defaultSubplebbitAddresses;
@@ -48,8 +52,11 @@ const Board = () => {
if (isInSubscriptionsView) {
return subscriptions || [];
}
if (isInModView) {
return accountSubplebbitAddresses;
}
return [subplebbitAddress];
}, [isInAllView, isInSubscriptionsView, subplebbitAddress, defaultSubplebbitAddresses, subscriptions]);
}, [isInAllView, isInSubscriptionsView, isInModView, subplebbitAddress, defaultSubplebbitAddresses, subscriptions, accountSubplebbitAddresses]);
const { sortType } = useSortingStore();
const { timeFilterSeconds, timeFilterName } = useTimeFilter();
@@ -57,8 +64,8 @@ const Board = () => {
const feedOptions = {
subplebbitAddresses,
sortType,
postsPerPage: isInAllView || isInSubscriptionsView ? 5 : 25,
...(isInAllView || isInSubscriptionsView ? { newerThan: timeFilterSeconds } : {}),
postsPerPage: isInAllView || isInSubscriptionsView || isInModView ? 5 : 25,
...(isInAllView || isInSubscriptionsView || isInModView ? { newerThan: timeFilterSeconds } : {}),
filter: hideThreadsWithoutImages ? threadsWithoutImagesFilter : undefined,
};
@@ -111,7 +118,7 @@ const Board = () => {
const subplebbit = useSubplebbit({ subplebbitAddress });
const { createdAt, description, error, rules, shortAddress, state, suggested } = subplebbit || {};
const title = isInAllView ? t('all') : isInSubscriptionsView ? t('subscriptions') : subplebbit?.title;
const title = isInAllView ? t('all') : isInSubscriptionsView ? t('subscriptions') : isInModView ? t('mod') : subplebbit?.title;
const { blocked, unblock } = useBlock({ address: subplebbitAddress });
@@ -174,7 +181,7 @@ const Board = () => {
/>
</div>
) : (
(isInAllView || isInSubscriptionsView) &&
(isInAllView || isInSubscriptionsView || isInModView) &&
showMorePostsSuggestion &&
monthlyFeed.length > feed.length &&
(weeklyFeed.length > feed.length ? (
@@ -183,7 +190,7 @@ const Board = () => {
i18nKey='more_threads_last_week'
values={{ currentTimeFilterName, count: feed.length }}
components={{
1: <Link to={(isInAllView ? '/p/all' : isInSubscriptionsView ? '/p/subscriptions' : `/p/${subplebbitAddress}`) + '/1w'} />,
1: <Link to={(isInAllView ? '/p/all' : isInSubscriptionsView ? '/p/subscriptions' : isInModView ? '/p/mod' : `/p/${subplebbitAddress}`) + '/1w'} />,
}}
/>
</div>
@@ -193,7 +200,7 @@ const Board = () => {
i18nKey='more_threads_last_month'
values={{ currentTimeFilterName, count: feed.length }}
components={{
1: <Link to={(isInAllView ? '/p/all' : isInSubscriptionsView ? '/p/subscriptions' : `/p/${subplebbitAddress}`) + '/1m'} />,
1: <Link to={(isInAllView ? '/p/all' : isInSubscriptionsView ? '/p/subscriptions' : isInModView ? '/p/mod' : `/p/${subplebbitAddress}`) + '/1m'} />,
}}
/>
</div>
@@ -209,9 +216,11 @@ const Board = () => {
{state === 'failed' ? (
<span className='red'>{state}</span>
) : isInSubscriptionsView && subscriptions?.length === 0 ? (
t('not_subscribed_to_any_board')
<span className='red'>{t('not_subscribed_to_any_board')}</span>
) : isInModView && accountSubplebbitAddresses?.length === 0 ? (
<span className='red'>{t('not_mod_of_any_board')}</span>
) : blocked ? (
t('you_have_blocked_this_board')
<span className='red'>{t('you_have_blocked_this_board')}</span>
) : (
hasMore && <LoadingEllipsis string={loadingStateString} />
)}