diff --git a/src/components/InfiniteCustomFeed.tsx b/src/components/InfiniteCustomFeed.tsx index 27737c5..1fdda3f 100644 --- a/src/components/InfiniteCustomFeed.tsx +++ b/src/components/InfiniteCustomFeed.tsx @@ -2,7 +2,11 @@ import * as React from "react"; //import { useInView } from "react-intersection-observer"; import { UniversalPostRendererATURILoader } from "~/components/UniversalPostRenderer"; import { useAuth } from "~/providers/PassAuthProvider"; -import { useQueryArbitrary, useQueryIdentity, useInfiniteQueryFeedSkeleton } from "~/utils/useQuery"; +import { + useQueryArbitrary, + useQueryIdentity, + useInfiniteQueryFeedSkeleton, +} from "~/utils/useQuery"; interface InfiniteCustomFeedProps { feedUri: string; @@ -10,9 +14,13 @@ interface InfiniteCustomFeedProps { feedServiceDid?: string; } -export function InfiniteCustomFeed({ feedUri, pdsUrl, feedServiceDid }: InfiniteCustomFeedProps) { +export function InfiniteCustomFeed({ + feedUri, + pdsUrl, + feedServiceDid, +}: InfiniteCustomFeedProps) { const { agent, authed } = useAuth(); - + // const identityresultmaybe = useQueryIdentity(agent?.did); // const identity = identityresultmaybe?.data; // const feedGenGetRecordQuery = useQueryArbitrary(feedUri); @@ -46,21 +54,37 @@ export function InfiniteCustomFeed({ feedUri, pdsUrl, feedServiceDid }: Infinite } if (isError) { - return
Error: {error.message}
; + return ( +
Error: {error.message}
+ ); } - const allPosts = data?.pages.flatMap((page) => {if (page) return page.feed}) ?? []; + const allPosts = + data?.pages.flatMap((page) => { + if (page) return page.feed; + }) ?? []; if (!allPosts || typeof allPosts !== "object" || allPosts.length === 0) { - return
No posts in this feed.
; + return ( +
+ No posts in this feed. +
+ ); } return ( <> {allPosts.map((item, i) => { - if (item) return ( - - )})} + if (item) + return ( + + ); + })} {/* allPosts?: {allPosts ? "true" : "false"} hasNextPage?: {hasNextPage ? "true" : "false"} isFetchingNextPage?: {isFetchingNextPage ? "true" : "false"} */} diff --git a/src/components/UniversalPostRenderer.tsx b/src/components/UniversalPostRenderer.tsx index 481b822..3f3acab 100644 --- a/src/components/UniversalPostRenderer.tsx +++ b/src/components/UniversalPostRenderer.tsx @@ -25,6 +25,7 @@ export interface UniversalPostRendererATURILoaderProps { topReplyLine?: boolean; bottomBorder?: boolean; feedviewpost?: boolean; + repostedby?: string; } // export async function cachedGetRecord({ @@ -128,6 +129,7 @@ export function UniversalPostRendererATURILoader({ topReplyLine, bottomBorder = true, feedviewpost = false, + repostedby, }: UniversalPostRendererATURILoaderProps) { console.log("atUri", atUri); //const { get, set } = usePersistentStore(); @@ -381,6 +383,10 @@ export function UniversalPostRendererATURILoader({ // }); // } // }; + if (!postQuery?.value) { + // deleted post more often than a non-resolvable post + return (<>) + } return ( ); } @@ -413,6 +420,7 @@ export function UniversalPostRendererRawRecordShim({ topReplyLine = false, bottomBorder = true, feedviewpost = false, + repostedby, }: { postRecord: any; profileRecord: any; @@ -426,6 +434,7 @@ export function UniversalPostRendererRawRecordShim({ topReplyLine?: boolean; bottomBorder?: boolean; feedviewpost?: boolean; + repostedby?: string; }) { console.log(`received aturi: ${aturi} of post content: ${postRecord}`); const navigate = useNavigate(); @@ -583,6 +592,13 @@ export function UniversalPostRendererRawRecordShim({ feedviewpost ? feedviewpostreplydid : undefined ); const feedviewpostreplyhandle = replyhookvalue?.data?.handle; + + + const aturirepostbydid = repostedby ? new AtUri(repostedby).host : undefined + const repostedbyhookvalue = useQueryIdentity( + repostedby ? aturirepostbydid : undefined + ); + const feedviewpostrepostedbyhandle = repostedbyhookvalue?.data?.handle; return ( <> {/*

@@ -616,6 +632,7 @@ export function UniversalPostRendererRawRecordShim({ bottomBorder={bottomBorder} //extraOptionalItemInfo={{reply: postRecord?.value?.reply as AppBskyFeedDefs.ReplyRef, post: fakepost}} feedviewpostreplyhandle={feedviewpostreplyhandle} + repostedby={feedviewpostrepostedbyhandle} /> ); @@ -1058,6 +1075,7 @@ function UniversalPostRenderer({ bottomBorder = true, feedviewpostreplyhandle, depth = 0, + repostedby, }: { post: PostView; // optional for now because i havent ported every use to this yet @@ -1076,6 +1094,7 @@ function UniversalPostRenderer({ bottomBorder?: boolean; feedviewpostreplyhandle?: string; depth?: number; + repostedby?: string; }) { const navigate = useNavigate(); const [hasRetweeted, setHasRetweeted] = useState( @@ -1124,7 +1143,7 @@ function UniversalPostRenderer({ } }; - const isRepost = extraOptionalItemInfo + const isRepost = repostedby ? repostedby : extraOptionalItemInfo ? AppBskyFeedDefs.isReasonRepost(extraOptionalItemInfo.reason) ? extraOptionalItemInfo.reason?.by.displayName : undefined @@ -1190,7 +1209,7 @@ function UniversalPostRenderer({ }} className="text-gray-500 dark:text-gray-400" > - Reposted by {isRepost}{" "} + Reposted by @{isRepost}{" "} )} {!isQuote && ( @@ -1292,7 +1311,7 @@ function UniversalPostRenderer({ maxWidth: `calc(100% - ${!expanded ? (isQuote ? 26 : 0) : 54}px)`, width: `calc(100% - ${!expanded ? (isQuote ? 26 : 0) : 54}px)`, marginLeft: !expanded ? (isQuote ? 26 : 0) : 54, - marginBottom: !expanded ? 4 : 0, + marginBottom: !expanded ? 4 : 6, }} >

- Reply to {feedviewpostreplyhandle} + Reply to @{feedviewpostreplyhandle}
)}
0 && ( <> -
+
(there is an embed here thats too deep to render)