From cde0d3df87971f7d23abb5245efc0610caa108c2 Mon Sep 17 00:00:00 2001 From: whey.party Date: Tue, 20 Jan 2026 07:40:48 +0000 Subject: [PATCH] post content hider --- src/auto-imports.d.ts | 2 ++ src/components/LogoSvg.tsx | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/components/UniversalPostRenderer.tsx | 258 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------- 3 file(s) changed, 251 insertion(s)(+), 86 deletion(s)(-) diff --git a/src/auto-imports.d.ts b/src/auto-imports.d.ts --- a/src/auto-imports.d.ts +++ b/src/auto-imports.d.ts @@ -24,6 +24,7 @@ const IconMdiCheck: typeof import('~icons/mdi/check.jsx').default const IconMdiCheckCircle: typeof import('~icons/mdi/check-circle.jsx').default const IconMdiCheckboxMultipleMarked: typeof import('~icons/mdi/checkbox-multiple-marked.jsx').default + const IconMdiChevronDown: typeof import('~icons/mdi/chevron-down.jsx').default const IconMdiClock: typeof import('~icons/mdi/clock.jsx').default const IconMdiClockOutline: typeof import('~icons/mdi/clock-outline.jsx').default const IconMdiClose: typeof import('~icons/mdi/close.jsx').default @@ -42,4 +43,5 @@ const IconMdiShield: typeof import('~icons/mdi/shield.jsx').default const IconMdiShieldOutline: typeof import('~icons/mdi/shield-outline.jsx').default const IconMdiVerified: typeof import('~icons/mdi/verified.jsx').default + const IconMdiWarning: typeof import('~icons/mdi/warning.jsx').default } diff --git a/src/components/LogoSvg.tsx b/src/components/LogoSvg.tsx --- a/src/components/LogoSvg.tsx +++ b/src/components/LogoSvg.tsx @@ -76,6 +76,83 @@ ) } +// candidate for default +export function WheyMadeModernistMonogram2Partial(props: SVGProps) { + return ( + + Logotype 2partial + + + + + + + + + +) +} + +export function WheyMade5Square(props: SVGProps) { + return ( + + + + + + + +) +} + + +export function WheyMadeBoubaKiki(props: SVGProps) { + return ( + + Logotype-1.5Nonequal15nonequal + + + + + + +) +} + +export function WheyMadeBoubaKikiLarge(props: SVGProps) { + return ( + + Logotype-Large1.5Nonequall15nonequal + + + + + + +) +} + // defaultpfp export function DefaultPFP(props: SVGProps) { return ( diff --git a/src/components/UniversalPostRenderer.tsx b/src/components/UniversalPostRenderer.tsx --- a/src/components/UniversalPostRenderer.tsx +++ b/src/components/UniversalPostRenderer.tsx @@ -21,10 +21,7 @@ import { useAuth } from "~/providers/UnifiedAuthProvider"; import { renderSnack } from "~/routes/__root"; //import { ModerationInner } from "~/routes/moderation"; -import { - FollowButton, - Mutual, -} from "~/routes/profile.$did"; +import { FollowButton, Mutual } from "~/routes/profile.$did"; import type { LightboxProps } from "~/routes/profile.$did/post.$rkey.image.$i"; import type { ContentLabel } from "~/types/moderation"; import { @@ -580,13 +577,21 @@ const { isLoading: authorModLoading, labels: authorLabels } = useModeration( post.author.did, ); + const { isLoading: contentModLoading, labels: contentLabels } = useModeration( + post.uri, + ); const hideAuthorLabels = authorLabels.filter( - label => label.preference === 'hide' + (label) => label.preference === "hide", ); const warnAuthorLabels = authorLabels.filter( - label => label.preference === 'warn' + (label) => label.preference === "warn", ); - + const hideContentLabels = contentLabels.filter( + (label) => label.preference === "hide", + ); + const warnContentLabels = contentLabels.filter( + (label) => label.preference === "warn", + ); const parsed = new AtUri(post.uri); const navigate = useNavigate(); @@ -671,8 +676,13 @@ const isMainItem = false; const setMainItem = (any: any) => { }; - if (hideAuthorLabels.length > 0 ) { - return null + const showContentWarning = warnContentLabels.length > 0; + + const [isOpen, setIsOpen] = useState(!showContentWarning); + + + if (hideAuthorLabels.length > 0 || hideContentLabels.length > 0) { + return null; } return ( @@ -917,13 +927,10 @@ {/* */} - {authorModLoading ? - ( + {authorModLoading ? (
-
- {/* + {/* avatar */} - loading badges... -
+ loading badges...
- ) - : - ( -
- {warnAuthorLabels.map((label, index) => ( - - ))} -
- ) - } + + ) : ( +
+ {warnAuthorLabels.map((label, index) => ( + + ))} +
+ )} {!!feedviewpostreplyhandle && (
)} {/* */} -
- {fedi ? ( + {showContentWarning && ( + { + e.stopPropagation(); + setIsOpen(!isOpen) + }} + /> + )} + {isOpen && (<> +
+ {fedi ? ( + <> + + + ) : ( + <> + {renderTextWithFacets({ + text: (post.record as { text?: string }).text ?? "", + facets: (post.record.facets as Facet[]) ?? [], + navigate: navigate, + })} + + )} +
+ {post.embed && depth < 1 && !concise ? ( + + ) : null} + {post.embed && depth > 0 && ( <> - - - ) : ( - <> - {renderTextWithFacets({ - text: (post.record as { text?: string }).text ?? "", - facets: (post.record.facets as Facet[]) ?? [], - navigate: navigate, - })} +
+ (there is an embed here thats too deep to render) +
)} -
- {post.embed && depth < 1 && !concise ? ( - - ) : null} - {post.embed && depth > 0 && ( - <> -
- (there is an embed here thats too deep to render) -
- - )} + )}
- {hasRetweeted ? : } + {hasRetweeted ? ( + + ) : ( + + )} {post.repostCount ?? 0}
@@ -1123,7 +1146,11 @@ ...(liked ? { color: "#EC4899" } : {}), }} > - {liked ? : } + {liked ? ( + + ) : ( + + )} {(post.likeCount || 0) + (liked ? 1 : 0)}
@@ -1186,8 +1213,68 @@ FeedEmbedRecordWithMedia = "FeedEmbedRecordWithMedia", } +export function ContentWarning({ + labels, + isOpen, + onPress, +}: { + labels: ContentLabel[]; + isOpen: boolean; + onPress: React.MouseEventHandler; +}) { + const { getLabelInfo } = useLabelInfo(); -export function SmallAuthorLabelBadge({ label, large }: { label: ContentLabel, large?: boolean }) { + // Pre-calculate text for cleaner JSX + const labelText = labels + .map((label) => getLabelInfo(label.sourceDid, label.val).name) + .join(", "); + + return ( +
+
+
+ {/* Icon Container */} +
+ +
+ + {/* Label Text */} + + {labelText} + +
+ + {/* Chevron */} +
+ {isOpen ? "hide" : "show"} + +
+
+
+ ); +} + +export function SmallAuthorLabelBadge({ + label, + large, +}: { + label: ContentLabel; + large?: boolean; +}) { /* -{" "} {label.preference} (from {label.sourceDid}) @@ -1197,12 +1284,11 @@ const [imgcdn] = useAtom(imgCDNAtom); - const { data: opProfile } = useQueryProfile( `at://${label.sourceDid}/app.bsky.actor.profile/self`, ); - const resolvedpfp = getAvatarUrl(opProfile, label.sourceDid, imgcdn) + const resolvedpfp = getAvatarUrl(opProfile, label.sourceDid, imgcdn); return (
{info.name || label.val}
- ) -} \ No newline at end of file + ); +} -- tangled.sh