diff --git a/app/(home-pages)/reader/InboxContent.tsx b/app/(home-pages)/reader/InboxContent.tsx index 0770dbc4..1deb67a9 100644 --- a/app/(home-pages)/reader/InboxContent.tsx +++ b/app/(home-pages)/reader/InboxContent.tsx @@ -10,7 +10,16 @@ import { PostListing } from "components/PostListing"; import { SortSmall } from "components/Icons/SortSmall"; import { Input } from "components/Input"; import { useHasBackgroundImage } from "components/Pages/useHasBackgroundImage"; -import { InteractionDrawer } from "app/lish/[did]/[publication]/[rkey]/Interactions/InteractionDrawer"; +import { + SelectedPostListing, + useSelectedPostListing, +} from "src/useSelectedPostState"; +import { AtUri } from "@atproto/api"; +import { MentionsDrawerContent } from "app/lish/[did]/[publication]/[rkey]/Interactions/Quotes"; +import { CommentsDrawerContent } from "app/lish/[did]/[publication]/[rkey]/Interactions/Comments"; +import { CloseTiny } from "components/Icons/CloseTiny"; +import { SpeedyLink } from "components/SpeedyLink"; +import { GoToArrow } from "components/Icons/GoToArrow"; export const InboxContent = (props: { posts: Post[]; @@ -86,7 +95,7 @@ export const InboxContent = (props: { let hasBackgroundImage = useHasBackgroundImage(); return ( -
+
)}
+ +
); }; +const MobileInteractionPreviewDrawer = () => { + let selectedPost = useSelectedPostListing((s) => s.selectedPostListing); + + return ( +
+ +
+ ); +}; +const DesktopInteractionPreviewDrawer = () => { + let selectedPost = useSelectedPostListing((s) => s.selectedPostListing); + + return ( +
+ +
+ ); +}; + +const PreviewDrawerContent = (props: { + selectedPost: SelectedPostListing | null; +}) => { + if (!props.selectedPost || !props.selectedPost.document) return; + + if (props.selectedPost.drawer === "quotes") { + return ( + <> + {/**/} + + ); + } else + return ( + <> +
+
+ Comments for {props.selectedPost.document.title} +
+ +
+ + + See Full Post + + + + ); +}; + export const ReaderEmpty = () => { return (
diff --git a/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx b/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx index 34608196..65a72f7a 100644 --- a/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx +++ b/app/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx @@ -29,6 +29,7 @@ export function CommentsDrawerContent(props: { document_uri: string; comments: Comment[]; pageId?: string; + noCommentBox?: boolean; }) { let { identity } = useIdentityData(); let { localComments } = useInteractionState(props.document_uri); @@ -55,26 +56,19 @@ export function CommentsDrawerContent(props: { id={"commentsDrawer"} className="flex flex-col gap-2 relative text-sm text-secondary" > -
-

Comments

- -
- {identity?.atp_did ? ( - - ) : ( -
- Connect a Bluesky account to comment - -
+ {!props.noCommentBox && ( + <> + {identity?.atp_did ? ( + + ) : ( +
+ Connect a Bluesky account to comment + +
+ )} +
+ )} -
{comments .sort((a, b) => { diff --git a/app/lish/[did]/[publication]/[rkey]/Interactions/InteractionDrawer.tsx b/app/lish/[did]/[publication]/[rkey]/Interactions/InteractionDrawer.tsx index b690925b..d15088e6 100644 --- a/app/lish/[did]/[publication]/[rkey]/Interactions/InteractionDrawer.tsx +++ b/app/lish/[did]/[publication]/[rkey]/Interactions/InteractionDrawer.tsx @@ -1,12 +1,17 @@ "use client"; import { Media } from "components/Media"; import { MentionsDrawerContent } from "./Quotes"; -import { InteractionState, useInteractionState } from "./Interactions"; +import { + InteractionState, + setInteractionState, + useInteractionState, +} from "./Interactions"; import { Json } from "supabase/database.types"; import { Comment, CommentsDrawerContent } from "./Comments"; import { useSearchParams } from "next/navigation"; import { SandwichSpacer } from "components/LeafletLayout"; import { decodeQuotePosition } from "../quotePosition"; +import { CloseTiny } from "components/Icons/CloseTiny"; export const InteractionDrawer = (props: { showPageBackground: boolean | undefined; @@ -39,19 +44,44 @@ export const InteractionDrawer = (props: {
{drawer.drawer === "quotes" ? ( - + <> + + + ) : ( - + <> +
+

Comments

+ +
+ + )}
diff --git a/app/lish/[did]/[publication]/[rkey]/Interactions/Quotes.tsx b/app/lish/[did]/[publication]/[rkey]/Interactions/Quotes.tsx index a1190b32..1c39cde9 100644 --- a/app/lish/[did]/[publication]/[rkey]/Interactions/Quotes.tsx +++ b/app/lish/[did]/[publication]/[rkey]/Interactions/Quotes.tsx @@ -86,13 +86,7 @@ export const MentionsDrawerContent = (props: { }); return ( -
- + <> {props.quotesAndMentions.length === 0 ? (
no quotes yet!
@@ -160,7 +154,7 @@ export const MentionsDrawerContent = (props: { )}
)} -
+ ); }; diff --git a/app/lish/[did]/[publication]/[rkey]/getPostPageData.ts b/app/lish/[did]/[publication]/[rkey]/getPostPageData.ts index 9f7f44a2..bbf8ef25 100644 --- a/app/lish/[did]/[publication]/[rkey]/getPostPageData.ts +++ b/app/lish/[did]/[publication]/[rkey]/getPostPageData.ts @@ -3,8 +3,6 @@ import { AtUri } from "@atproto/syntax"; import { normalizeDocumentRecord, normalizePublicationRecord, - type NormalizedDocument, - type NormalizedPublication, } from "src/utils/normalizeRecords"; import { PubLeafletPublication, SiteStandardPublication } from "lexicons/api"; import { documentUriFilter } from "src/utils/uriHelpers"; @@ -33,12 +31,15 @@ export async function getPostPageData(did: string, rkey: string) { if (!document) return null; // Normalize the document record - this is the primary way consumers should access document data - const normalizedDocument = normalizeDocumentRecord(document.data, document.uri); + const normalizedDocument = normalizeDocumentRecord( + document.data, + document.uri, + ); if (!normalizedDocument) return null; // Normalize the publication record - this is the primary way consumers should access publication data const normalizedPublication = normalizePublicationRecord( - document.documents_in_publications[0]?.publications?.record + document.documents_in_publications[0]?.publications?.record, ); // Fetch constellation backlinks for mentions @@ -83,7 +84,10 @@ export async function getPostPageData(did: string, rkey: string) { // Filter and sort documents by publishedAt const sortedDocs = allDocs .map((dip) => { - const normalizedData = normalizeDocumentRecord(dip?.documents?.data, dip?.documents?.uri); + const normalizedData = normalizeDocumentRecord( + dip?.documents?.data, + dip?.documents?.uri, + ); return { uri: dip?.documents?.uri, title: normalizedData?.title, @@ -98,7 +102,9 @@ export async function getPostPageData(did: string, rkey: string) { ); // Find current document index - const currentIndex = sortedDocs.findIndex((doc) => doc.uri === document.uri); + const currentIndex = sortedDocs.findIndex( + (doc) => doc.uri === document.uri, + ); if (currentIndex !== -1) { prevNext = { @@ -122,13 +128,18 @@ export async function getPostPageData(did: string, rkey: string) { // Build explicit publication context for consumers const rawPub = document.documents_in_publications[0]?.publications; - const publication = rawPub ? { - uri: rawPub.uri, - name: rawPub.name, - identity_did: rawPub.identity_did, - record: rawPub.record as PubLeafletPublication.Record | SiteStandardPublication.Record | null, - publication_subscriptions: rawPub.publication_subscriptions || [], - } : null; + const publication = rawPub + ? { + uri: rawPub.uri, + name: rawPub.name, + identity_did: rawPub.identity_did, + record: rawPub.record as + | PubLeafletPublication.Record + | SiteStandardPublication.Record + | null, + publication_subscriptions: rawPub.publication_subscriptions || [], + } + : null; return { ...document, diff --git a/components/PostListing.tsx b/components/PostListing.tsx index 324cfcaf..ae6e619b 100644 --- a/components/PostListing.tsx +++ b/components/PostListing.tsx @@ -15,10 +15,10 @@ import { InteractionPreview, TagPopover } from "./InteractionsPreview"; import { useLocalizedDate } from "src/hooks/useLocalizedDate"; import { useSmoker } from "./Toast"; import { Separator } from "./Layout"; -import { SpeedyLink } from "./SpeedyLink"; import { CommentTiny } from "./Icons/CommentTiny"; import { QuoteTiny } from "./Icons/QuoteTiny"; import { ShareTiny } from "./Icons/ShareTiny"; +import { useSelectedPostListing } from "src/useSelectedPostState"; export const PostListing = (props: Post) => { let pubRecord = props.publication?.pubRecord as @@ -149,7 +149,9 @@ export const PostListing = (props: Post) => { tags={tags} showComments={pubRecord?.preferences?.showComments !== false} showMentions={pubRecord?.preferences?.showMentions !== false} - />{" "} + documentUri={props.documents.uri} + document={postRecord} + />
@@ -193,29 +195,42 @@ const Interactions = (props: { postUrl: string; showComments: boolean; showMentions: boolean; + documentUri: string; + document: NormalizedDocument; }) => { + let setSelectedPostListing = useSelectedPostListing( + (s) => s.setSelectedPostListing, + ); + let selectPostListing = (drawer: "quotes" | "comments") => { + setSelectedPostListing({ + document_uri: props.documentUri, + document: props.document, + drawer, + }); + }; + return (
{!props.showMentions || props.quotesCount === 0 ? null : ( - selectPostListing("quotes")} + className="relative flex flex-row gap-1 text-sm items-center hover:text-accent-contrast text-tertiary" > {props.quotesCount} - + )} {!props.showComments || props.commentsCount === 0 ? null : ( - selectPostListing("comments")} + className="relative flex flex-row gap-1 text-sm items-center hover:text-accent-contrast text-tertiary" > {props.commentsCount} - + )}