diff --git a/src/providers/PollMutationQueueProvider.tsx b/src/providers/PollMutationQueueProvider.tsx index 26e0722..d6dc904 100644 --- a/src/providers/PollMutationQueueProvider.tsx +++ b/src/providers/PollMutationQueueProvider.tsx @@ -295,47 +295,51 @@ export function usePollMutationQueue() { return context; } -function usePollSelfVotes(pollUri: string) { +function usePollSelfVotes(pollUri: string, enabled?: boolean) { const { agent } = useAuth(); const agentDid = agent?.did; const { uris: userVotesA } = useGetOneToOneState( - agentDid + agentDid && enabled ? { target: pollUri, user: agentDid, collection: "app.reddwarf.poll.vote.a", path: ".subject.uri", + enabled: enabled } : undefined, ); const { uris: userVotesB } = useGetOneToOneState( - agentDid + agentDid && enabled ? { target: pollUri, user: agentDid, collection: "app.reddwarf.poll.vote.b", path: ".subject.uri", + enabled: enabled } : undefined, ); const { uris: userVotesC } = useGetOneToOneState( - agentDid + agentDid && enabled ? { target: pollUri, user: agentDid, collection: "app.reddwarf.poll.vote.c", path: ".subject.uri", + enabled: enabled } : undefined, ); const { uris: userVotesD } = useGetOneToOneState( - agentDid + agentDid && enabled ? { target: pollUri, user: agentDid, collection: "app.reddwarf.poll.vote.d", path: ".subject.uri", + enabled: enabled } : undefined, ); @@ -361,7 +365,7 @@ export function usePollData( const myDid = agent?.did; const { castVoteRaw, getLocalVotes } = usePollMutationQueue(); - const serverUserVotes = usePollSelfVotes(pollUri); // Our own votes from server + const serverUserVotes = usePollSelfVotes(pollUri, enabled); // Our own votes from server const localVotes = getLocalVotes(pollUri); // Pending local actions // 1. FETCHING - Move the logic here diff --git a/src/routes/about.tsx b/src/routes/about.tsx index 6cea2de..e88e5b6 100644 --- a/src/routes/about.tsx +++ b/src/routes/about.tsx @@ -1,4 +1,5 @@ import { createFileRoute } from '@tanstack/react-router' +import React from 'react'; import { FORCED_LABELER_DIDS, HOST_ABOUT_MARKDOWN, HOST_ADMIN, HOST_DESCRIPTION, HOST_HERO, HOST_LABELMERGE, HOST_SIGNUP_PDS } from '~/../policy'; import { Header } from '~/components/Header'; @@ -173,7 +174,7 @@ function PolicyRenderer(){ // endorsed feeds (should be shown in the explore tab too in lieu of feed discovery) // - [ ] HOST_UNAUTHED_DEFAULT_FEEDS // endorsed PDS - // - [ ] HOST_SIGNUP_PDS + // - [x] HOST_SIGNUP_PDS // todo move the other default services into policy.ts // todo re- sort policy.ts according to this component // also the default services used like microcosm stuff and lycan and maybe the reliance of an appview for search or some other hting @@ -181,7 +182,7 @@ function PolicyRenderer(){ // default general host moderation policies // todo: layerd moderataion later pls thanks // show the labelmerge insstance responsible - // - [ ] HOST_LABELMERGE + // - [x] HOST_LABELMERGE // show both the whitelisted source and labeler dids in the same spot. // like on hover / click it opens a dialog / popover to show what authority the labeler has // - [x] FORCED_LABELER_DIDS @@ -197,32 +198,49 @@ function PolicyRenderer(){ return ( <> {/* settings heading or about heading? */} + + -
- PDS (User Account Storage): - {HOST_SIGNUP_PDS || "not set"} - - Labelmerge (Label Cache): - {HOST_LABELMERGE || "not set"} - - Constellation (Backlink Index): - {defaultconstellationURL || "not set"} - - Slingshot (Record Cache): - {defaultslingshotURL || "not set"} - - Image Provider (CDN): - {defaultImgCDN || "not set"} - - Video Provider (CDN): - {defaultVideoCDN || "not set"} - - Lycan (Personal Search): - {defaultLycanURL || "not set"} - - AppView (Bluesky Index): - {defaultAppviewURL || "not set"} -
+ {/* {hostmandate && ()} */} {hostmandate && ()} @@ -241,4 +259,47 @@ function PolicyRenderer(){ ) +} + +type KeyValueItem = { + label: string + value?: string | null + //italicIfEmpty?: boolean +} + +interface KeyValueGridProps { + items: KeyValueItem[] + className?: string +} + +export function KeyValueGrid({ items, className = "" }: KeyValueGridProps) { + return ( +
+ {items.map((item, i) => { + const isEmpty = !item.value + + return ( + + {/* Label */} + + {item.label} + + + {/* Value */} + + {item.value || "not set"} + + + ) + })} +
+ ) } \ No newline at end of file diff --git a/src/routes/profile.$did/post.$rkey.tsx b/src/routes/profile.$did/post.$rkey.tsx index 14654dd..6dab134 100644 --- a/src/routes/profile.$did/post.$rkey.tsx +++ b/src/routes/profile.$did/post.$rkey.tsx @@ -1,19 +1,22 @@ import { AtUri } from "@atproto/api"; -import { useInfiniteQuery, useQueryClient } from "@tanstack/react-query"; +import { QueryClient, useInfiniteQuery, useQueryClient } from "@tanstack/react-query"; import { createFileRoute, Outlet, useMatchRoute } from "@tanstack/react-router"; -import { useAtom } from "jotai"; +import { useAtom, useAtomValue } from "jotai"; +import { loadable } from "jotai/utils"; import React, { useLayoutEffect } from "react"; import { Header } from "~/components/Header"; import { UniversalPostRendererATURILoader } from "~/components/UniversalPostRenderer"; -import { constellationURLAtom, slingshotURLAtom } from "~/utils/atoms"; +import { appviewUrlAtom, constellationURLAtom, enableAppViewAtom, slingshotURLAtom } from "~/utils/atoms"; //import { usePersistentStore } from '~/providers/PersistentStoreProvider'; import { constructPostQuery, + constructSingularAVPostQuery, type linksAllResponse, type linksRecordsResponse, useQueryConstellation, - useQueryIdentity, + useQueryFastAVIdentity, + //useQueryIdentity, useQueryPost, yknowIReallyHateThisButWhateverGuardedConstructConstellationInfiniteQueryLinks, } from "~/utils/useQuery"; @@ -189,11 +192,13 @@ export function ProfilePostComponent({ // }; // }, [atUri]); + const [slingshoturl] = useAtom(slingshotURLAtom); + const { data: identity, isLoading: isIdentityLoading, error: identityError, - } = useQueryIdentity(showMainPostRoute ? did : undefined); + } = useQueryFastAVIdentity(showMainPostRoute ? did : undefined, slingshoturl, queryClient, true); const resolvedDid = did.startsWith("did:") ? did : identity?.did; @@ -207,8 +212,8 @@ export function ProfilePostComponent({ const { data: mainPost } = useQueryPost(showMainPostRoute ? atUri : undefined); - console.log("atUri",atUri) - + console.log("atUri", atUri) + const opdid = React.useMemo( () => atUri @@ -218,13 +223,13 @@ export function ProfilePostComponent({ ); // @ts-expect-error i hate overloads - const { data: links } = useQueryConstellation(atUri&&showMainPostRoute?{ + const { data: links } = useQueryConstellation(atUri && showMainPostRoute ? { method: "/links/all", target: atUri, } : { method: "undefined", target: "" - })as { data: linksAllResponse | undefined }; + }) as { data: linksAllResponse | undefined }; //const [likes, setLikes] = React.useState(null); //const [reposts, setReposts] = React.useState(null); @@ -245,7 +250,7 @@ export function ProfilePostComponent({ setReplyCount( links ? links?.links?.["app.bsky.feed.post"]?.[".reply.parent.uri"] - ?.records || 0 + ?.records || 0 : null ); }, [links]); @@ -388,7 +393,7 @@ export function ProfilePostComponent({ hasPerformedInitialLayout.current = true; } - + // todo idk what to do with this // eslint-disable-next-line react-hooks/set-state-in-effect setLayoutReady(true); @@ -396,8 +401,14 @@ export function ProfilePostComponent({ }, [parents, layoutReady, showMainPostRoute]); - const [slingshoturl] = useAtom(slingshotURLAtom) - + const [isAppviewEnabled] = useAtom(enableAppViewAtom); + const loadablePrefs = useAtomValue(loadable(enableAppViewAtom)) + React.useEffect(() => { + console.log("why is this fucked isAppviewEnabled?:", isAppviewEnabled); + },[isAppviewEnabled]) + const [appviewUrl] = useAtom(appviewUrlAtom); + //const [slingshoturl] = useAtom(slingshotURLAtom) + React.useEffect(() => { if (parentsLoading || !showMainPostRoute) { setLayoutReady(false); @@ -412,6 +423,11 @@ export function ProfilePostComponent({ const directparent = mainPost?.value.reply?.parent.uri; React.useEffect(() => { + console.log("parent fetching useeffect called!") + // if (loadablePrefs.state !== "hasData") { + // setParentsLoading(true); + // return; + // } if (!mainPost?.value?.reply?.parent?.uri) { setParents([]); return; @@ -420,23 +436,21 @@ export function ProfilePostComponent({ let ignore = false; const fetchParents = async () => { setParentsLoading(true); - const parentChain: ({uri: string;cid: string;value: any;} | undefined)[] = []; + const parentChain: ({ uri: string; cid: string; value: any; } | undefined)[] = []; let currentParentUri = mainPost?.value.reply?.parent.uri; const MAX_PARENTS = 25; let safetyCounter = 0; while (currentParentUri && safetyCounter < MAX_PARENTS) { try { - const parentPost = await queryClient.fetchQuery( - constructPostQuery(currentParentUri, slingshoturl) - ); + const parentPost = await getProfilePostTryFail({isAppviewEnabled, appviewUrl, queryClient, currentParentUri, slingshoturl}) if (!parentPost) break; parentChain.push(parentPost); currentParentUri = parentPost.value?.reply?.parent?.uri; } catch (error) { console.error("Failed to fetch a parent post:", error); // its okay to always add one invalid parent then stop - if (currentParentUri){ + if (currentParentUri) { parentChain.push({ uri: currentParentUri, cid: "sorry", @@ -458,7 +472,7 @@ export function ProfilePostComponent({ return () => { ignore = true; }; - }, [mainPost, queryClient, slingshoturl]); + }, [appviewUrl, isAppviewEnabled, loadablePrefs.state, mainPost, queryClient, slingshoturl]); if ((!did || !rkey) && showMainPostRoute) return
Invalid post URI
; if (isIdentityLoading && showMainPostRoute) return
Resolving handle...
; @@ -545,7 +559,7 @@ export function ProfilePostComponent({ /> ); })} - {hasNextPage && ( + {hasNextPage && (