diff --git a/src/components/UniversalPostRenderer.tsx b/src/components/UniversalPostRenderer.tsx index 2de1a06..ac63617 100644 --- a/src/components/UniversalPostRenderer.tsx +++ b/src/components/UniversalPostRenderer.tsx @@ -1,4 +1,4 @@ -import * as ATPAPI from "@atproto/api" +import * as ATPAPI from "@atproto/api"; import { useNavigate } from "@tanstack/react-router"; import DOMPurify from "dompurify"; import { useAtom } from "jotai"; @@ -10,6 +10,8 @@ import { type SVGProps } from "react"; import { composerAtom, constellationURLAtom, + enableBridgyTextAtom, + enableWafrnTextAtom, imgCDNAtom, } from "~/utils/atoms"; import { useHydratedEmbed } from "~/utils/useHydrated"; @@ -162,7 +164,7 @@ export function UniversalPostRendererATURILoader({ isQuote, filterNoReplies, filterMustHaveMedia, - filterMustBeReply + filterMustBeReply, }: UniversalPostRendererATURILoaderProps) { // todo remove this once tree rendering is implemented, use a prop like isTree const TEMPLINEAR = true; @@ -526,7 +528,9 @@ export function UniversalPostRendererATURILoader({ ? true : maxReplies && !oldestOpsReplyElseNewestNonOpsReply ? false - : (maxReplies === 0 && (!replies || (!!replies && replies === 0))) ? false : bottomReplyLine + : maxReplies === 0 && (!replies || (!!replies && replies === 0)) + ? false + : bottomReplyLine } topReplyLine={topReplyLine} //bottomBorder={maxReplies&&oldestOpsReplyElseNewestNonOpsReply ? false : bottomBorder} @@ -553,12 +557,14 @@ export function UniversalPostRendererATURILoader({ filterMustBeReply={filterMustBeReply} /> <> - {(maxReplies && maxReplies === 0 && replies && replies > 0) ? ( + {maxReplies && maxReplies === 0 && replies && replies > 0 ? ( <> - {/*
hello
*/} - + {/*
hello
*/} + - ) : (<>)} + ) : ( + <> + )} {!isQuote && oldestOpsReplyElseNewestNonOpsReply && ( <> @@ -755,10 +761,18 @@ export function UniversalPostRendererRawRecordShim({ const hasImages = hasEmbed?.$type === "app.bsky.embed.images"; const hasVideo = hasEmbed?.$type === "app.bsky.embed.video"; const isquotewithmedia = hasEmbed?.$type === "app.bsky.embed.recordWithMedia"; - const isQuotewithImages = isquotewithmedia && (hasEmbed as ATPAPI.AppBskyEmbedRecordWithMedia.Main)?.media?.$type === "app.bsky.embed.images"; - const isQuotewithVideo = isquotewithmedia && (hasEmbed as ATPAPI.AppBskyEmbedRecordWithMedia.Main)?.media?.$type === "app.bsky.embed.video"; - - const hasMedia = hasEmbed && (hasImages || hasVideo || isQuotewithImages || isQuotewithVideo); + const isQuotewithImages = + isquotewithmedia && + (hasEmbed as ATPAPI.AppBskyEmbedRecordWithMedia.Main)?.media?.$type === + "app.bsky.embed.images"; + const isQuotewithVideo = + isquotewithmedia && + (hasEmbed as ATPAPI.AppBskyEmbedRecordWithMedia.Main)?.media?.$type === + "app.bsky.embed.video"; + + const hasMedia = + hasEmbed && + (hasImages || hasVideo || isQuotewithImages || isQuotewithVideo); const { data: hydratedEmbed, @@ -854,7 +868,8 @@ export function UniversalPostRendererRawRecordShim({ // }, [fakepost, get, set]); const thereply = (fakepost?.record as AppBskyFeedPost.Record)?.reply?.parent ?.uri; - const feedviewpostreplydid = thereply&&!filterNoReplies ? new AtUri(thereply).host : undefined; + const feedviewpostreplydid = + thereply && !filterNoReplies ? new AtUri(thereply).host : undefined; const replyhookvalue = useQueryIdentity( feedviewpost ? feedviewpostreplydid : undefined ); @@ -1237,7 +1252,11 @@ import ReactPlayer from "react-player"; import defaultpfp from "~/../public/favicon.png"; import { useAuth } from "~/providers/UnifiedAuthProvider"; -import { FeedItemRenderAturiLoader, FollowButton, Mutual } from "~/routes/profile.$did"; +import { + FeedItemRenderAturiLoader, + FollowButton, + Mutual, +} from "~/routes/profile.$did"; import type { LightboxProps } from "~/routes/profile.$did/post.$rkey.image.$i"; import { useFastLike } from "~/utils/likeMutationQueue"; // import type { OutputSchema } from "@atproto/api/dist/client/types/app/bsky/feed/getFeed"; @@ -1446,8 +1465,44 @@ function UniversalPostRenderer({ : undefined; const emergencySalt = randomString(); - const fedi = (post.record as { bridgyOriginalText?: string }) + + const [showBridgyText] = useAtom(enableBridgyTextAtom); + const [showWafrnText] = useAtom(enableWafrnTextAtom); + + const unfedibridgy = (post.record as { bridgyOriginalText?: string }) .bridgyOriginalText; + const unfediwafrnPartial = (post.record as { fullText?: string }).fullText; + const unfediwafrnTags = (post.record as { fullTags?: string }).fullTags; + const unfediwafrnUnHost = (post.record as { fediverseId?: string }) + .fediverseId; + + const undfediwafrnHost = unfediwafrnUnHost + ? new URL(unfediwafrnUnHost).hostname + : undefined; + + const tags = unfediwafrnTags + ? unfediwafrnTags + .split("\n") + .map((t) => t.trim()) + .filter(Boolean) + : undefined; + + const links = tags + ? tags + .map((tag) => { + const encoded = encodeURIComponent(tag); + return `#${tag.replaceAll(' ','-')}`; + }) + .join("
") + : ""; + + const unfediwafrn = unfediwafrnPartial + ? unfediwafrnPartial + (links ? `
${links}` : "") + : undefined; + + const fedi = + (showBridgyText ? unfedibridgy : undefined) ?? + (showWafrnText ? unfediwafrn : undefined); /* fuck you */ const isMainItem = false; @@ -1586,7 +1641,8 @@ function UniversalPostRenderer({ {post.author.displayName || post.author.handle}{" "}
- @{post.author.handle}{" "} + @ + {post.author.handle}{" "}
{uprrrsauthor?.description && ( @@ -1834,7 +1890,11 @@ function UniversalPostRenderer({ )} -
+
<> {expanded && (
//
// ) - } else if (!!reallybaduri && !!reallybadaturi && reallybadaturi.collection === "app.bsky.feed.generator") { - return
+ } else if ( + !!reallybaduri && + !!reallybadaturi && + reallybadaturi.collection === "app.bsky.feed.generator" + ) { + return ( +
+ +
+ ); } // list embed @@ -2216,8 +2284,21 @@ function PostEmbeds({ // //
// ) - } else if (!!reallybaduri && !!reallybadaturi && reallybadaturi.collection === "app.bsky.graph.list") { - return
+ } else if ( + !!reallybaduri && + !!reallybadaturi && + reallybadaturi.collection === "app.bsky.graph.list" + ) { + return ( +
+ +
+ ); } // starter pack embed @@ -2229,8 +2310,21 @@ function PostEmbeds({ // //
// ) - } else if (!!reallybaduri && !!reallybadaturi && reallybadaturi.collection === "app.bsky.graph.starterpack") { - return
+ } else if ( + !!reallybaduri && + !!reallybadaturi && + reallybadaturi.collection === "app.bsky.graph.starterpack" + ) { + return ( +
+ +
+ ); } // quote post diff --git a/src/routes/settings.tsx b/src/routes/settings.tsx index 8ba6bf5..2b7cc1e 100644 --- a/src/routes/settings.tsx +++ b/src/routes/settings.tsx @@ -13,6 +13,8 @@ import { defaultslingshotURL, defaultVideoCDN, enableBitesAtom, + enableBridgyTextAtom, + enableWafrnTextAtom, hueAtom, imgCDNAtom, slingshotURLAtom, @@ -84,7 +86,25 @@ export function Settings() { +
+ +
+

@@ -137,19 +157,17 @@ export function SwitchSetting({ return (

-
- - - {description} - -
- -
+ setValue(v)} className="m3switch root" diff --git a/src/utils/atoms.ts b/src/utils/atoms.ts index e831180..536d82a 100644 --- a/src/utils/atoms.ts +++ b/src/utils/atoms.ts @@ -137,3 +137,13 @@ export const enableBitesAtom = atomWithStorage( "enableBitesAtom", false ); + +export const enableBridgyTextAtom = atomWithStorage( + "enableBridgyTextAtom", + false +); + +export const enableWafrnTextAtom = atomWithStorage( + "enableWafrnTextAtom", + false +);