"use client";
import { ButtonPrimary } from "components/Buttons";
import {
SelectedPostListing,
useSelectedPostListing,
} from "src/useSelectedPostState";
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";
import { DotLoader } from "components/utils/DotLoader";
import { ReaderMentionsContent } from "./ReaderMentionsContent";
import { callRPC } from "app/api/rpc/client";
import useSWR from "swr";
import { getDocumentURL } from "app/lish/createPub/getPublicationURL";
export const MobileInteractionPreviewDrawer = () => {
let selectedPost = useSelectedPostListing((s) => s.selectedPostListing);
return (
);
};
export const DesktopInteractionPreviewDrawer = () => {
let selectedPost = useSelectedPostListing((s) => s.selectedPostListing);
return (
);
};
const PreviewDrawerContent = (props: {
selectedPost: SelectedPostListing | null;
}) => {
const documentUri = props.selectedPost?.document_uri || null;
const drawer = props.selectedPost?.drawer || null;
const { data, isLoading } = useSWR(
documentUri ? ["get_document_interactions", documentUri] : null,
async () => {
const res = await callRPC("get_document_interactions", {
document_uri: documentUri!,
});
return res;
},
{ keepPreviousData: false },
);
if (!props.selectedPost || !props.selectedPost.document)
return (
Click a post's comments or mentions to preview them here!
);
const postUrl = getDocumentURL(
props.selectedPost.document,
props.selectedPost.document_uri,
props.selectedPost.publication,
);
const drawerTitle =
drawer === "quotes"
? `Mentions of ${props.selectedPost.document.title}`
: `Comments for ${props.selectedPost.document.title}`;
return (
<>
{drawerTitle}
See Full Post
{isLoading ? (
loading
) : drawer === "quotes" ? (
) : (
)}
>
);
};