feat(post): clicking "+" button next to "omitted replies" message shows all replies

This commit is contained in:
Tom (plebeius.eth)
2024-07-01 10:26:38 +02:00
parent 06e18289a4
commit d78ce84db4
41 changed files with 132 additions and 80 deletions
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "جار التحميل", "loading": "جار التحميل",
"posted_by": "نشر بواسطة", "posted_by": "نشر بواسطة",
"by": "بواسطة", "by": "بواسطة",
"last_reply_by": "آخر رد بواسطة" "last_reply_by": "آخر رد بواسطة",
"showing_all_replies": "عرض جميع الردود."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "লোড হচ্ছে", "loading": "লোড হচ্ছে",
"posted_by": "পোস্ট করেছেন", "posted_by": "পোস্ট করেছেন",
"by": "দ্বারা", "by": "দ্বারা",
"last_reply_by": "শেষ উত্তর দেননি" "last_reply_by": "শেষ উত্তর দেননি",
"showing_all_replies": "সব উত্তর দেখাচ্ছি।"
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Načítání", "loading": "Načítání",
"posted_by": "Publikoval(a)", "posted_by": "Publikoval(a)",
"by": "od", "by": "od",
"last_reply_by": "Poslední odpověď od" "last_reply_by": "Poslední odpověď od",
"showing_all_replies": "Zobrazuji všechny odpovědi."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Indlæser", "loading": "Indlæser",
"posted_by": "Skrevet af", "posted_by": "Skrevet af",
"by": "af", "by": "af",
"last_reply_by": "Seneste svar fra" "last_reply_by": "Seneste svar fra",
"showing_all_replies": "Viser alle svar."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Laden", "loading": "Laden",
"posted_by": "Geschrieben von", "posted_by": "Geschrieben von",
"by": "von", "by": "von",
"last_reply_by": "Letzte Antwort von" "last_reply_by": "Letzte Antwort von",
"showing_all_replies": "Zeige alle Antworten."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Φόρτωση", "loading": "Φόρτωση",
"posted_by": "Δημοσιεύτηκε από", "posted_by": "Δημοσιεύτηκε από",
"by": "από", "by": "από",
"last_reply_by": "Τελευταία απάντηση από" "last_reply_by": "Τελευταία απάντηση από",
"showing_all_replies": "Εμφανίζονται όλες οι απαντήσεις."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Loading", "loading": "Loading",
"posted_by": "Posted by", "posted_by": "Posted by",
"by": "by", "by": "by",
"last_reply_by": "Last reply by" "last_reply_by": "Last reply by",
"showing_all_replies": "Showing all replies."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Cargando", "loading": "Cargando",
"posted_by": "Publicado por", "posted_by": "Publicado por",
"by": "por", "by": "por",
"last_reply_by": "Última respuesta de" "last_reply_by": "Última respuesta de",
"showing_all_replies": "Mostrando todas las respuestas."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "در حال بارگذاری", "loading": "در حال بارگذاری",
"posted_by": "ارسال شده توسط", "posted_by": "ارسال شده توسط",
"by": "توسط", "by": "توسط",
"last_reply_by": "آخرین پاسخ توسط" "last_reply_by": "آخرین پاسخ توسط",
"showing_all_replies": "نمایش تمام پاسخ‌ها."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Lataa", "loading": "Lataa",
"posted_by": "Lähettäjä", "posted_by": "Lähettäjä",
"by": "kirjoittanut", "by": "kirjoittanut",
"last_reply_by": "Viimeisin vastaus" "last_reply_by": "Viimeisin vastaus",
"showing_all_replies": "Näytetään kaikki vastaukset."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Naglo-load", "loading": "Naglo-load",
"posted_by": "Nai-post ni", "posted_by": "Nai-post ni",
"by": "ni", "by": "ni",
"last_reply_by": "Huling sagot ni" "last_reply_by": "Huling sagot ni",
"showing_all_replies": "Nagpapakita ng lahat ng mga sagot."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Chargement", "loading": "Chargement",
"posted_by": "Posté par", "posted_by": "Posté par",
"by": "par", "by": "par",
"last_reply_by": "Dernière réponse par" "last_reply_by": "Dernière réponse par",
"showing_all_replies": "Affichage de toutes les réponses."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "טוען", "loading": "טוען",
"posted_by": "פורסם על ידי", "posted_by": "פורסם על ידי",
"by": "על ידי", "by": "על ידי",
"last_reply_by": "תגובה אחרונה מאת" "last_reply_by": "תגובה אחרונה מאת",
"showing_all_replies": "מציג את כל התגובות."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "लोड हो रहा है", "loading": "लोड हो रहा है",
"posted_by": "द्वारा लिखित", "posted_by": "द्वारा लिखित",
"by": "द्वारा", "by": "द्वारा",
"last_reply_by": "अंतिम उत्तर दिया गया है" "last_reply_by": "अंतिम उत्तर दिया गया है",
"showing_all_replies": "सभी उत्तर दिखा रहा है।"
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Betöltés", "loading": "Betöltés",
"posted_by": "Írta", "posted_by": "Írta",
"by": "által", "by": "által",
"last_reply_by": "Utolsó válasz írta" "last_reply_by": "Utolsó válasz írta",
"showing_all_replies": "Az összes válasz megjelenítése."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Memuat", "loading": "Memuat",
"posted_by": "Diposting oleh", "posted_by": "Diposting oleh",
"by": "oleh", "by": "oleh",
"last_reply_by": "Balasan terakhir oleh" "last_reply_by": "Balasan terakhir oleh",
"showing_all_replies": "Menampilkan semua balasan."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Caricamento", "loading": "Caricamento",
"posted_by": "Pubblicato da", "posted_by": "Pubblicato da",
"by": "da", "by": "da",
"last_reply_by": "Ultima risposta da" "last_reply_by": "Ultima risposta da",
"showing_all_replies": "Mostrando tutte le risposte."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "読み込み中", "loading": "読み込み中",
"posted_by": "投稿者", "posted_by": "投稿者",
"by": "によって", "by": "によって",
"last_reply_by": "最後の返信者" "last_reply_by": "最後の返信者",
"showing_all_replies": "すべての返信を表示しています。"
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "로딩 중", "loading": "로딩 중",
"posted_by": "작성자", "posted_by": "작성자",
"by": "작성자:", "by": "작성자:",
"last_reply_by": "마지막 답글 작성자:" "last_reply_by": "마지막 답글 작성자:",
"showing_all_replies": "모든 답글을 표시합니다."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "लोड होत आहे", "loading": "लोड होत आहे",
"posted_by": "ने टप्पल केला", "posted_by": "ने टप्पल केला",
"by": "व्यक्ती", "by": "व्यक्ती",
"last_reply_by": "शेवटचा प्रतिसाद व्यक्ती" "last_reply_by": "शेवटचा प्रतिसाद व्यक्ती",
"showing_all_replies": "सर्व प्रतिसाद दाखवत आहे."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Laden", "loading": "Laden",
"posted_by": "Geplaatst door", "posted_by": "Geplaatst door",
"by": "door", "by": "door",
"last_reply_by": "Laatste reactie door" "last_reply_by": "Laatste reactie door",
"showing_all_replies": "Alle antwoorden weergeven."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Laster", "loading": "Laster",
"posted_by": "Skrevet av", "posted_by": "Skrevet av",
"by": "av", "by": "av",
"last_reply_by": "Siste svar fra" "last_reply_by": "Siste svar fra",
"showing_all_replies": "Viser alle svar."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Ładowanie", "loading": "Ładowanie",
"posted_by": "Opublikowane przez", "posted_by": "Opublikowane przez",
"by": "przez", "by": "przez",
"last_reply_by": "Ostatnia odpowiedź od" "last_reply_by": "Ostatnia odpowiedź od",
"showing_all_replies": "Wyświetlanie wszystkich odpowiedzi."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Carregando", "loading": "Carregando",
"posted_by": "Postado por", "posted_by": "Postado por",
"by": "por", "by": "por",
"last_reply_by": "Última resposta por" "last_reply_by": "Última resposta por",
"showing_all_replies": "Mostrando todas as respostas."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Încărcare", "loading": "Încărcare",
"posted_by": "Postat de", "posted_by": "Postat de",
"by": "de către", "by": "de către",
"last_reply_by": "Ultima răspuns de la" "last_reply_by": "Ultima răspuns de la",
"showing_all_replies": "Afișare toate răspunsurile."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Загрузка", "loading": "Загрузка",
"posted_by": "Опубликовано", "posted_by": "Опубликовано",
"by": "от", "by": "от",
"last_reply_by": "Последний ответ от" "last_reply_by": "Последний ответ от",
"showing_all_replies": "Показываются все ответы."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Ngarkimi", "loading": "Ngarkimi",
"posted_by": "Postuar nga", "posted_by": "Postuar nga",
"by": "nga", "by": "nga",
"last_reply_by": "Përgjigje e fundit nga" "last_reply_by": "Përgjigje e fundit nga",
"showing_all_replies": "Duke treguar të gjitha përgjigjet."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Laddar", "loading": "Laddar",
"posted_by": "Postat av", "posted_by": "Postat av",
"by": "av", "by": "av",
"last_reply_by": "Senaste svar av" "last_reply_by": "Senaste svar av",
"showing_all_replies": "Visar alla svar."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "లోడ్ అవుతోంది", "loading": "లోడ్ అవుతోంది",
"posted_by": "పోస్ట్ చేసినవాడు", "posted_by": "పోస్ట్ చేసినవాడు",
"by": "ద్వారా", "by": "ద్వారా",
"last_reply_by": "చివరి సమాధానం ఇచ్చింది" "last_reply_by": "చివరి సమాధానం ఇచ్చింది",
"showing_all_replies": "అన్ని సమాధానాలను చూపుతుంది."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "กำลังโหลด", "loading": "กำลังโหลด",
"posted_by": "โพสต์โดย", "posted_by": "โพสต์โดย",
"by": "โดย", "by": "โดย",
"last_reply_by": "การตอบคำถามล่าสุดโดย" "last_reply_by": "การตอบคำถามล่าสุดโดย",
"showing_all_replies": "กำลังแสดงคำตอบทั้งหมด"
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Yükleniyor", "loading": "Yükleniyor",
"posted_by": "Tarafından gönderildi", "posted_by": "Tarafından gönderildi",
"by": "tarafından", "by": "tarafından",
"last_reply_by": "Son cevap" "last_reply_by": "Son cevap",
"showing_all_replies": "Tüm yanıtlar gösteriliyor."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Завантаження", "loading": "Завантаження",
"posted_by": "Опубліковано", "posted_by": "Опубліковано",
"by": "від", "by": "від",
"last_reply_by": "Остання відповідь від" "last_reply_by": "Остання відповідь від",
"showing_all_replies": "Показуються всі відповіді."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "لوڈ ہو رہا ہے", "loading": "لوڈ ہو رہا ہے",
"posted_by": "پوسٹ کیا گیا", "posted_by": "پوسٹ کیا گیا",
"by": "کے ذریعے", "by": "کے ذریعے",
"last_reply_by": "آخری جواب دیا گیا" "last_reply_by": "آخری جواب دیا گیا",
"showing_all_replies": "تمام جوابات دکھا رہا ہے۔"
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "Đang tải", "loading": "Đang tải",
"posted_by": "Được đăng bởi", "posted_by": "Được đăng bởi",
"by": "bởi", "by": "bởi",
"last_reply_by": "Trả lời cuối cùng bởi" "last_reply_by": "Trả lời cuối cùng bởi",
"showing_all_replies": "Đang hiển thị tất cả các phản hồi."
} }
+2 -1
View File
@@ -202,5 +202,6 @@
"loading": "加载中", "loading": "加载中",
"posted_by": "由...发布", "posted_by": "由...发布",
"by": "由...发布", "by": "由...发布",
"last_reply_by": "最后回复者" "last_reply_by": "最后回复者",
"showing_all_replies": "显示所有回复。"
} }
+34 -16
View File
@@ -23,9 +23,20 @@ import PostMenuDesktop from './post-menu-desktop';
import ReplyQuotePreview from '../reply-quote-preview'; import ReplyQuotePreview from '../reply-quote-preview';
import Tooltip from '../tooltip'; import Tooltip from '../tooltip';
import { PostProps } from '../../views/post/post'; import { PostProps } from '../../views/post/post';
import { create } from 'zustand';
import _ from 'lodash'; import _ from 'lodash';
const PostInfo = ({ openReplyModal, post, roles, isHidden }: PostProps) => { interface ShowOmittedRepliesState {
showOmittedReplies: boolean;
setShowOmittedReplies: (showOmittedReplies: boolean) => void;
}
const useShowOmittedReplies = create<ShowOmittedRepliesState>((set) => ({
showOmittedReplies: false,
setShowOmittedReplies: (showOmittedReplies: boolean) => set({ showOmittedReplies }),
}));
const PostInfo = ({ openReplyModal, post, postReplyCount = 0, roles, isHidden }: PostProps) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { author, cid, locked, pinned, parentCid, postCid, replyCount, shortCid, state, subplebbitAddress, timestamp } = post || {}; const { author, cid, locked, pinned, parentCid, postCid, replyCount, shortCid, state, subplebbitAddress, timestamp } = post || {};
const title = post?.title?.trim(); const title = post?.title?.trim();
@@ -36,6 +47,7 @@ const PostInfo = ({ openReplyModal, post, roles, isHidden }: PostProps) => {
const { isDescription, isRules } = post || {}; // custom properties, not from api const { isDescription, isRules } = post || {}; // custom properties, not from api
const stateString = useStateString(post); const stateString = useStateString(post);
const isReply = parentCid; const isReply = parentCid;
const { showOmittedReplies } = useShowOmittedReplies();
const params = useParams(); const params = useParams();
const location = useLocation(); const location = useLocation();
@@ -49,7 +61,7 @@ const PostInfo = ({ openReplyModal, post, roles, isHidden }: PostProps) => {
const { isCommentAuthorMod, isAccountMod, isAccountCommentAuthor } = useEditCommentPrivileges({ commentAuthorAddress: address, subplebbitAddress }); const { isCommentAuthorMod, isAccountMod, isAccountCommentAuthor } = useEditCommentPrivileges({ commentAuthorAddress: address, subplebbitAddress });
const handleUserAddressClick = useAuthorAddressClick(); const handleUserAddressClick = useAuthorAddressClick();
let numberOfPostsByAuthor = document.querySelectorAll(`[data-author-address="${shortAddress}"]`).length; const numberOfPostsByAuthor = document.querySelectorAll(`[data-author-address="${shortAddress}"][data-post-cid="${postCid}"]`).length;
return ( return (
<div className={styles.postInfo}> <div className={styles.postInfo}>
@@ -87,13 +99,13 @@ const PostInfo = ({ openReplyModal, post, roles, isHidden }: PostProps) => {
<span <span
title='Highlight posts by this user address' title='Highlight posts by this user address'
className={styles.userAddress} className={styles.userAddress}
onClick={() => handleUserAddressClick(shortAddress || accountShortAddress)} onClick={() => handleUserAddressClick(shortAddress || accountShortAddress, postCid)}
> >
{shortAddress || accountShortAddress} {shortAddress || accountShortAddress}
</span> </span>
} }
content={`${numberOfPostsByAuthor} ${numberOfPostsByAuthor === 1 ? 'post' : 'posts'} by this user address`} content={`${numberOfPostsByAuthor} ${numberOfPostsByAuthor === 1 ? 'post' : 'posts'} by this user address`}
showTooltip={isInPostPageView} showTooltip={isInPostPageView || showOmittedReplies || postReplyCount < 6}
/> />
){' '} ){' '}
</> </>
@@ -279,7 +291,7 @@ const PostMessage = ({ post }: PostProps) => {
); );
}; };
const Reply = ({ openReplyModal, reply, roles }: PostProps) => { const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => {
let post = reply; let post = reply;
// handle pending mod or author edit // handle pending mod or author edit
const { editedComment } = useEditedComment({ comment: reply }); const { editedComment } = useEditedComment({ comment: reply });
@@ -287,7 +299,7 @@ const Reply = ({ openReplyModal, reply, roles }: PostProps) => {
post = editedComment; post = editedComment;
} }
const { cid, content, link, subplebbitAddress } = post || {}; const { author, cid, content, link, postCid, subplebbitAddress } = post || {};
const isRouteLinkToReply = useLocation().pathname.startsWith(`/p/${subplebbitAddress}/c/${cid}`); const isRouteLinkToReply = useLocation().pathname.startsWith(`/p/${subplebbitAddress}/c/${cid}`);
const { hidden } = useHide({ cid }); const { hidden } = useHide({ cid });
@@ -297,9 +309,10 @@ const Reply = ({ openReplyModal, reply, roles }: PostProps) => {
<div <div
className={`${styles.reply} ${isRouteLinkToReply && styles.highlight} ${hidden && styles.postDesktopHidden}`} className={`${styles.reply} ${isRouteLinkToReply && styles.highlight} ${hidden && styles.postDesktopHidden}`}
data-cid={cid} data-cid={cid}
data-author-address={post?.author?.shortAddress} data-author-address={author?.shortAddress}
data-post-cid={postCid}
> >
<PostInfo openReplyModal={openReplyModal} post={post} roles={roles} /> <PostInfo openReplyModal={openReplyModal} post={post} postReplyCount={postReplyCount} roles={roles} />
{link && !hidden && isValidURL(link) && <PostMedia post={post} />} {link && !hidden && isValidURL(link) && <PostMedia post={post} />}
{content && !hidden && <PostMessage post={post} />} {content && !hidden && <PostMessage post={post} />}
</div> </div>
@@ -308,7 +321,8 @@ const Reply = ({ openReplyModal, reply, roles }: PostProps) => {
}; };
const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies = true }: PostProps) => { const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies = true }: PostProps) => {
const { cid, content, link, pinned, replyCount, subplebbitAddress } = post || {}; const { t } = useTranslation();
const { author, cid, content, link, pinned, postCid, replyCount, subplebbitAddress } = post || {};
const { isDescription, isRules } = post || {}; // custom properties, not from api const { isDescription, isRules } = post || {}; // custom properties, not from api
const params = useParams(); const params = useParams();
const location = useLocation(); const location = useLocation();
@@ -323,6 +337,7 @@ const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies
const totallinksCount = useCountLinksInReplies(post); const totallinksCount = useCountLinksInReplies(post);
const repliesCount = pinned ? replyCount : replyCount - 5; const repliesCount = pinned ? replyCount : replyCount - 5;
const linksCount = pinned ? totallinksCount : totallinksCount - visiblelinksCount; const linksCount = pinned ? totallinksCount : totallinksCount - visiblelinksCount;
const { showOmittedReplies, setShowOmittedReplies } = useShowOmittedReplies();
// scroll to reply if pathname is reply permalink (backlink) // scroll to reply if pathname is reply permalink (backlink)
const replyRefs = useRef<(HTMLDivElement | null)[]>([]); const replyRefs = useRef<(HTMLDivElement | null)[]>([]);
@@ -348,7 +363,7 @@ const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies
<span className={`${styles.hideButton} ${hidden ? styles.unhideThread : styles.hideThread}`} onClick={hidden ? unhide : hide} /> <span className={`${styles.hideButton} ${hidden ? styles.unhideThread : styles.hideThread}`} onClick={hidden ? unhide : hide} />
</span> </span>
)} )}
<div data-cid={cid} data-author-address={post?.author?.shortAddress}> <div data-cid={cid} data-author-address={author?.shortAddress} data-post-cid={postCid}>
{link && !isHidden && isValidURL(link) && <PostMedia post={post} />} {link && !isHidden && isValidURL(link) && <PostMedia post={post} />}
<PostInfo isHidden={isHidden} openReplyModal={openReplyModal} post={post} roles={roles} /> <PostInfo isHidden={isHidden} openReplyModal={openReplyModal} post={post} roles={roles} />
{!isHidden && !content && <div className={styles.spacer} />} {!isHidden && !content && <div className={styles.spacer} />}
@@ -356,10 +371,13 @@ const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies
</div> </div>
{!isHidden && !isDescription && !isRules && !isInPendingPostView && (replies.length > 5 || (pinned && replies.length > 0)) && !isInPostPageView && ( {!isHidden && !isDescription && !isRules && !isInPendingPostView && (replies.length > 5 || (pinned && replies.length > 0)) && !isInPostPageView && (
<span className={styles.summary}> <span className={styles.summary}>
<span className={styles.expandButtonWrapper}> <span
<span className={styles.expandButton} /> className={`${showOmittedReplies ? styles.hideOmittedReplies : styles.showOmittedReplies} ${styles.omittedRepliesButtonWrapper}`}
</span> onClick={() => setShowOmittedReplies(!showOmittedReplies)}
{linksCount > 0 ? ( />
{showOmittedReplies ? (
t('showing_all_replies')
) : linksCount > 0 ? (
<Trans <Trans
i18nKey={'replies_and_links_omitted'} i18nKey={'replies_and_links_omitted'}
shouldUnescape={true} shouldUnescape={true}
@@ -378,9 +396,9 @@ const PostDesktop = ({ openReplyModal, post, roles, showAllReplies, showReplies
!isRules && !isRules &&
replies && replies &&
showReplies && showReplies &&
(showAllReplies ? replies : replies.slice(-5)).map((reply, index) => ( (showAllReplies || showOmittedReplies ? replies : replies.slice(-5)).map((reply, index) => (
<div key={index} className={styles.replyContainer} ref={(el) => (replyRefs.current[index] = el)}> <div key={index} className={styles.replyContainer} ref={(el) => (replyRefs.current[index] = el)}>
<Reply openReplyModal={openReplyModal} reply={reply} roles={roles} /> <Reply openReplyModal={openReplyModal} reply={reply} roles={roles} postReplyCount={replyCount} />
</div> </div>
))} ))}
</div> </div>
+14 -13
View File
@@ -21,9 +21,9 @@ import Tooltip from '../tooltip';
import { PostProps } from '../../views/post/post'; import { PostProps } from '../../views/post/post';
import _ from 'lodash'; import _ from 'lodash';
const PostInfoAndMedia = ({ openReplyModal, post, roles }: PostProps) => { const PostInfoAndMedia = ({ openReplyModal, post, postReplyCount = 0, roles }: PostProps) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { author, cid, link, locked, parentCid, pinned, shortCid, state, subplebbitAddress, timestamp } = post || {}; const { author, cid, link, locked, parentCid, pinned, postCid, shortCid, state, subplebbitAddress, timestamp } = post || {};
const title = post?.title?.trim(); const title = post?.title?.trim();
const { isDescription, isRules } = post || {}; // custom properties, not from api const { isDescription, isRules } = post || {}; // custom properties, not from api
const { address, shortAddress } = author || {}; const { address, shortAddress } = author || {};
@@ -49,7 +49,7 @@ const PostInfoAndMedia = ({ openReplyModal, post, roles }: PostProps) => {
const stateString = useStateString(post); const stateString = useStateString(post);
const handleUserAddressClick = useAuthorAddressClick(); const handleUserAddressClick = useAuthorAddressClick();
const numberOfPostsByAuthor = document.querySelectorAll(`[data-author-address="${shortAddress}"]`).length; const numberOfPostsByAuthor = document.querySelectorAll(`[data-author-address="${shortAddress}"][data-post-cid="${postCid}"]`).length;
return ( return (
<> <>
@@ -79,13 +79,13 @@ const PostInfoAndMedia = ({ openReplyModal, post, roles }: PostProps) => {
<span <span
title='Highlight posts by this user address' title='Highlight posts by this user address'
className={styles.userAddress} className={styles.userAddress}
onClick={() => handleUserAddressClick(shortAddress || accountShortAddress)} onClick={() => handleUserAddressClick(shortAddress || accountShortAddress, postCid)}
> >
{shortAddress || accountShortAddress} {shortAddress || accountShortAddress}
</span> </span>
} }
content={`${numberOfPostsByAuthor} ${numberOfPostsByAuthor === 1 ? 'post' : 'posts'} by this user address`} content={`${numberOfPostsByAuthor} ${numberOfPostsByAuthor === 1 ? 'post' : 'posts'} by this user address`}
showTooltip={isInPostPageView} showTooltip={isInPostPageView || postReplyCount < 6}
/> />
){' '} ){' '}
</> </>
@@ -234,14 +234,14 @@ const PostMessageMobile = ({ post }: PostProps) => {
); );
}; };
const Reply = ({ openReplyModal, reply, roles }: PostProps) => { const Reply = ({ openReplyModal, postReplyCount, reply, roles }: PostProps) => {
let post = reply; let post = reply;
// handle pending mod or author edit // handle pending mod or author edit
const { editedComment } = useEditedComment({ comment: reply }); const { editedComment } = useEditedComment({ comment: reply });
if (editedComment) { if (editedComment) {
post = editedComment; post = editedComment;
} }
const { cid, content, subplebbitAddress } = post || {}; const { author, cid, content, postCid, subplebbitAddress } = post || {};
const isRouteLinkToReply = useLocation().pathname.startsWith(`/p/${subplebbitAddress}/c/${cid}`); const isRouteLinkToReply = useLocation().pathname.startsWith(`/p/${subplebbitAddress}/c/${cid}`);
const { hidden } = useHide({ cid }); const { hidden } = useHide({ cid });
@@ -251,9 +251,10 @@ const Reply = ({ openReplyModal, reply, roles }: PostProps) => {
<div <div
className={`${styles.replyContainer} ${isRouteLinkToReply && styles.highlight} ${hidden && styles.postDesktopHidden}`} className={`${styles.replyContainer} ${isRouteLinkToReply && styles.highlight} ${hidden && styles.postDesktopHidden}`}
data-cid={cid} data-cid={cid}
data-author-address={post?.author?.shortAddress} data-author-address={author?.shortAddress}
data-post-cid={postCid}
> >
<PostInfoAndMedia openReplyModal={openReplyModal} post={post} roles={roles} /> <PostInfoAndMedia openReplyModal={openReplyModal} post={post} postReplyCount={postReplyCount} roles={roles} />
{content && !hidden && <PostMessageMobile post={post} />} {content && !hidden && <PostMessageMobile post={post} />}
<ReplyBacklinks post={reply} /> <ReplyBacklinks post={reply} />
</div> </div>
@@ -264,7 +265,7 @@ const Reply = ({ openReplyModal, reply, roles }: PostProps) => {
const PostMobile = ({ openReplyModal, post, roles, showAllReplies, showReplies = true }: PostProps) => { const PostMobile = ({ openReplyModal, post, roles, showAllReplies, showReplies = true }: PostProps) => {
const { t } = useTranslation(); const { t } = useTranslation();
const { cid, content, pinned, replyCount, subplebbitAddress } = post || {}; const { author, cid, content, pinned, postCid, replyCount, subplebbitAddress } = post || {};
const { isDescription, isRules } = post || {}; // custom properties, not from api const { isDescription, isRules } = post || {}; // custom properties, not from api
const params = useParams(); const params = useParams();
const location = useLocation(); const location = useLocation();
@@ -306,8 +307,8 @@ const PostMobile = ({ openReplyModal, post, roles, showAllReplies, showReplies =
)} )}
<div className={showReplies ? styles.thread : styles.quotePreview}> <div className={showReplies ? styles.thread : styles.quotePreview}>
<div className={styles.postContainer}> <div className={styles.postContainer}>
<div className={styles.postOp} data-cid={cid} data-author-address={post?.author?.shortAddress}> <div className={styles.postOp} data-cid={cid} data-author-address={author?.shortAddress} data-post-cid={postCid}>
<PostInfoAndMedia openReplyModal={openReplyModal} post={post} roles={roles} /> <PostInfoAndMedia openReplyModal={openReplyModal} post={post} postReplyCount={replyCount} roles={roles} />
{content && <PostMessageMobile post={post} />} {content && <PostMessageMobile post={post} />}
</div> </div>
{!isInPostView && !isInPendingPostView && showReplies && ( {!isInPostView && !isInPendingPostView && showReplies && (
@@ -333,7 +334,7 @@ const PostMobile = ({ openReplyModal, post, roles, showAllReplies, showReplies =
showReplies && showReplies &&
(showAllReplies ? replies : replies.slice(-5)).map((reply, index) => ( (showAllReplies ? replies : replies.slice(-5)).map((reply, index) => (
<div key={index} className={styles.replyContainer} ref={(el) => (replyRefs.current[index] = el)}> <div key={index} className={styles.replyContainer} ref={(el) => (replyRefs.current[index] = el)}>
<Reply openReplyModal={openReplyModal} reply={reply} roles={roles} /> <Reply openReplyModal={openReplyModal} postReplyCount={replyCount} reply={reply} roles={roles} />
</div> </div>
))} ))}
</div> </div>
+3 -7
View File
@@ -1,11 +1,7 @@
import { useParams } from 'react-router-dom';
const useAuthorAddressClick = () => { const useAuthorAddressClick = () => {
const { commentCid } = useParams<{ commentCid: string }>(); const handleUserAddressClick = (shortAddress: string, postCid: string) => {
const handleUserAddressClick = (shortAddress: string) => {
// Select the elements corresponding to the clicked short address // Select the elements corresponding to the clicked short address
const elements = document.querySelectorAll(`[data-author-address="${shortAddress}"]`); const elements = document.querySelectorAll(`[data-author-address="${shortAddress}"][data-post-cid="${postCid}"]`);
// Check if the clicked address is already highlighted // Check if the clicked address is already highlighted
const isAlreadyHighlighted = Array.from(elements).some((element) => element.classList.contains('highlight')); const isAlreadyHighlighted = Array.from(elements).some((element) => element.classList.contains('highlight'));
@@ -21,7 +17,7 @@ const useAuthorAddressClick = () => {
// Highlight the new elements, excluding the element matching the cid if it is the OP post // Highlight the new elements, excluding the element matching the cid if it is the OP post
elements.forEach((element) => { elements.forEach((element) => {
if (element.getAttribute('data-cid') !== commentCid) { if (element.getAttribute('data-cid') !== element.getAttribute('data-post-cid')) {
element.classList.add('highlight'); element.classList.add('highlight');
} }
}); });
-6
View File
@@ -103,7 +103,6 @@
--post-menu-desktop-btn-opacity: 0.8; --post-menu-desktop-btn-opacity: 0.8;
--post-menu-desktop-button-color-hover: red; --post-menu-desktop-button-color-hover: red;
--post-greentext-color: #789922; --post-greentext-color: #789922;
--post-replies-expand-button-background-image: url("/public/assets/buttons/plus-red.png");
/* post form */ /* post form */
--post-form-toggle-font-size: 22px; --post-form-toggle-font-size: 22px;
@@ -309,7 +308,6 @@
--post-menu-desktop-btn-opacity: 0.8; --post-menu-desktop-btn-opacity: 0.8;
--post-menu-desktop-button-color-hover: #d00; --post-menu-desktop-button-color-hover: #d00;
--post-greentext-color: #789922; --post-greentext-color: #789922;
--post-replies-expand-button-background-image: url("/public/assets/buttons/plus-blue.png");
/* post form */ /* post form */
--post-form-toggle-font-size: 22px; --post-form-toggle-font-size: 22px;
@@ -496,7 +494,6 @@
--post-menu-desktop-btn-opacity: 0.8; --post-menu-desktop-btn-opacity: 0.8;
--post-menu-desktop-button-color-hover: red; --post-menu-desktop-button-color-hover: red;
--post-greentext-color: #789922; --post-greentext-color: #789922;
--post-replies-expand-button-background-image: url("/public/assets/buttons/plus-red.png");
/* post form */ /* post form */
--post-form-toggle-font-size: 22px; --post-form-toggle-font-size: 22px;
@@ -679,7 +676,6 @@
--post-menu-desktop-btn-opacity: 0.8; --post-menu-desktop-btn-opacity: 0.8;
--post-menu-desktop-button-color-hover: #d00; --post-menu-desktop-button-color-hover: #d00;
--post-greentext-color: #789922; --post-greentext-color: #789922;
--post-replies-expand-button-background-image: url("/public/assets/buttons/plus-blue.png");
/* post form */ /* post form */
--post-form-toggle-font-size: 22px; --post-form-toggle-font-size: 22px;
@@ -867,7 +863,6 @@
--post-menu-desktop-btn-opacity: 0.8; --post-menu-desktop-btn-opacity: 0.8;
--post-menu-desktop-button-color-hover: #81a2be; --post-menu-desktop-button-color-hover: #81a2be;
--post-greentext-color: #b5bd68; --post-greentext-color: #b5bd68;
--post-replies-expand-button-background-image: url("/public/assets/buttons/plus-dark.png");
/* post form */ /* post form */
--post-form-toggle-font-size: 22px; --post-form-toggle-font-size: 22px;
@@ -1069,7 +1064,6 @@
--post-menu-desktop-btn-opacity: 0.8; --post-menu-desktop-btn-opacity: 0.8;
--post-menu-desktop-button-color-hover: #FF3300; --post-menu-desktop-button-color-hover: #FF3300;
--post-greentext-color: #789922; --post-greentext-color: #789922;
--post-replies-expand-button-background-image: url("/public/assets/buttons/plus-photon.png");
/* post mobile */ /* post mobile */
--post-mobile-background-color: #eee; --post-mobile-background-color: #eee;
+10 -3
View File
@@ -179,14 +179,13 @@
color: var(--post-mobile-abbr-text-color); color: var(--post-mobile-abbr-text-color);
} }
.postDesktop .summary .expandButtonWrapper { .postDesktop .summary .omittedRepliesButtonWrapper {
position: absolute; position: absolute;
top: 8px; top: 8px;
left: 2px; left: 2px;
} }
.postDesktop .summary .expandButton { .postDesktop .summary .omittedRepliesButtonWrapper {
background-image: var(--post-replies-expand-button-background-image);
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
width: 18px; width: 18px;
@@ -196,6 +195,14 @@
cursor: pointer; cursor: pointer;
} }
.postDesktop .summary .hideOmittedReplies {
background-image: var(--post-hide-button-background-image);
}
.postDesktop .summary .showOmittedReplies {
background-image: var(--post-unhide-button-background-image);
}
.postDesktop .summary a { .postDesktop .summary a {
color: var(--post-link-text-color); color: var(--post-link-text-color);
text-decoration: var(--post-content-link-text-decoration); text-decoration: var(--post-content-link-text-decoration);
+1
View File
@@ -17,6 +17,7 @@ export interface PostProps {
index?: number; index?: number;
isHidden?: boolean; isHidden?: boolean;
post?: any; post?: any;
postReplyCount?: number;
reply?: any; reply?: any;
roles?: Role[]; roles?: Role[];
showAllReplies?: boolean; showAllReplies?: boolean;