From 3f47948bdb68630a49d72a016eeaae8100ba7874 Mon Sep 17 00:00:00 2001 From: celine Date: Wed, 10 Dec 2025 07:04:30 -0500 Subject: [PATCH] refactored the footer a bit --- app/(home-pages)/discover/PubListing.tsx | 15 +- app/lish/Subscribe.tsx | 242 +++--------------- .../[rkey]/Interactions/Interactions.tsx | 166 ++++++++---- .../[rkey]/LinearDocumentPage.tsx | 40 +-- .../[publication]/[rkey]/PostContent.tsx | 2 +- .../[did]/[publication]/[rkey]/PostFooter.tsx | 63 ----- .../[did]/[publication]/[rkey]/PostPages.tsx | 1 - 7 files changed, 170 insertions(+), 359 deletions(-) delete mode 100644 app/lish/[did]/[publication]/[rkey]/PostFooter.tsx diff --git a/app/(home-pages)/discover/PubListing.tsx b/app/(home-pages)/discover/PubListing.tsx index 285a36cd..43a22b17 100644 --- a/app/(home-pages)/discover/PubListing.tsx +++ b/app/(home-pages)/discover/PubListing.tsx @@ -1,6 +1,7 @@ "use client"; import { AtUri } from "@atproto/syntax"; import { PublicationSubscription } from "app/(home-pages)/reader/getSubscriptions"; +import { SubscribeWithBluesky } from "app/lish/Subscribe"; import { PubIcon } from "components/ActionBar/Publications"; import { Separator } from "components/Layout"; import { usePubTheme } from "components/ThemeManager/PublicationThemeProvider"; @@ -13,6 +14,7 @@ import { Json } from "supabase/database.types"; export const PubListing = ( props: PublicationSubscription & { resizeHeight?: boolean; + subscribe?: boolean; }, ) => { let record = props.record as PubLeafletPublication.Record; @@ -60,13 +62,12 @@ export const PubListing = (
{props.authorProfile?.handle}
-

- Updated{" "} - {timeAgo( - props.documents_in_publications?.[0]?.documents?.indexed_at || - "", - )} -

+ diff --git a/app/lish/Subscribe.tsx b/app/lish/Subscribe.tsx index 001ff6f8..695bd6da 100644 --- a/app/lish/Subscribe.tsx +++ b/app/lish/Subscribe.tsx @@ -23,165 +23,8 @@ import { addFeed } from "./addFeed"; import { useSearchParams } from "next/navigation"; import LoginForm from "app/login/LoginForm"; import { RSSSmall } from "components/Icons/RSSSmall"; -import { SpeedyLink } from "components/SpeedyLink"; - -type State = - | { state: "email" } - | { state: "code"; token: string } - | { state: "success" }; -export const SubscribeButton = (props: { - compact?: boolean; - publication: string; -}) => { - let { identity, mutate } = useIdentityData(); - let [emailInputValue, setEmailInputValue] = useState(""); - let [codeInputValue, setCodeInputValue] = useState(""); - let [state, setState] = useState({ state: "email" }); - - if (state.state === "email") { - return ( -
-
- { - setEmailInputValue(e.currentTarget.value); - }} - /> - { - if (identity?.email) { - await subscribeToPublicationWithEmail(props.publication); - //optimistically could add! - await mutate(); - return; - } - let tokenID = await requestAuthEmailToken(emailInputValue); - setState({ state: "code", token: tokenID }); - }} - > - {props.compact ? ( - - ) : ( - "Subscribe" - )} - -
- {/* */} -
- ); - } - if (state.state === "code") { - return ( -
-
-
Please enter the code we sent to
-
{emailInputValue}
-
- - - - -
- ); - } - - if (state.state === "success") { - return ( -
-
-
You're subscribed!
- {/* */} -
-
- ); - } -}; - -export const ShareButton = () => { - return ( - - ); -}; - -const ConfirmCodeInput = (props: { - codeInputValue: string; - token: string; - setCodeInputValue: (value: string) => void; - setState: (state: State) => void; - publication: string; -}) => { - let { mutate } = useIdentityData(); - return ( -
- { - props.setCodeInputValue(e.currentTarget.value); - }} - /> - { - console.log( - await confirmEmailAuthToken(props.token, props.codeInputValue), - ); - - await subscribeToPublicationWithEmail(props.publication); - //optimistically could add! - await mutate(); - props.setState({ state: "success" }); - return; - }} - > - Confirm - -
- ); -}; export const SubscribeWithBluesky = (props: { - isPost?: boolean; pubName: string; pub_uri: string; base_url: string; @@ -208,11 +51,6 @@ export const SubscribeWithBluesky = (props: { } return (
- {props.isPost && ( -
- Get updates from {props.pubName}! -
- )}
Manage Subscription
+ } > -
- You're Subscribed{props.isPost ? ` to ` : "!"} - {props.isPost && ( - - {props.pubName} - - )} -
- Manage
} - > -
-

Update Options

- - {!hasFeed && ( - - - View Bluesky Custom Feed - - - )} +
+

Update Options

+ {!hasFeed && ( - - Get RSS + + View Bluesky Custom Feed + )} -
+ + + Get RSS + + -
- -
-
{" "} - -
+
+ +
+ +
+ + ); }; @@ -430,3 +256,7 @@ const SubscribeSuccessModal = ({ ); }; + +export const SubscribeOnPost = () => { + return
; +}; diff --git a/app/lish/[did]/[publication]/[rkey]/Interactions/Interactions.tsx b/app/lish/[did]/[publication]/[rkey]/Interactions/Interactions.tsx index dc4963bf..d78c8170 100644 --- a/app/lish/[did]/[publication]/[rkey]/Interactions/Interactions.tsx +++ b/app/lish/[did]/[publication]/[rkey]/Interactions/Interactions.tsx @@ -13,8 +13,14 @@ import { TagTiny } from "components/Icons/TagTiny"; import { Tag } from "components/Tags"; import { Popover } from "components/Popover"; import { PostPageData } from "../getPostPageData"; -import { PubLeafletComment } from "lexicons/api"; +import { PubLeafletComment, PubLeafletPublication } from "lexicons/api"; import { prefetchQuotesData } from "./Quotes"; +import { useIdentityData } from "components/IdentityProvider"; +import { ManageSubscription, SubscribeWithBluesky } from "app/lish/Subscribe"; +import { EditTiny } from "components/Icons/EditTiny"; +import { getPublicationURL } from "app/lish/createPub/getPublicationURL"; +import { PubListing } from "app/(home-pages)/discover/PubListing"; +import { PubIcon } from "components/ActionBar/Publications"; export type InteractionState = { drawerOpen: undefined | boolean; @@ -108,6 +114,7 @@ export const Interactions = (props: { }) => { const data = useContext(PostPageContext); const document_uri = data?.uri; + let { identity } = useIdentityData(); if (!document_uri) throw new Error("document_uri not available in PostPageContext"); @@ -121,6 +128,7 @@ export const Interactions = (props: { const tags = (data?.data as any)?.tags as string[] | undefined; const tagCount = tags?.length || 0; + return (
{tagCount > 0 && } @@ -165,6 +173,8 @@ export const ExpandedInteractions = (props: { pageId?: string; }) => { const data = useContext(PostPageContext); + let { identity } = useIdentityData(); + const document_uri = data?.uri; if (!document_uri) throw new Error("document_uri not available in PostPageContext"); @@ -176,59 +186,109 @@ export const ExpandedInteractions = (props: { prefetchQuotesData(data.quotesAndMentions); } }; + let publication = data?.documents_in_publications[0]?.publications; const tags = (data?.data as any)?.tags as string[] | undefined; const tagCount = tags?.length || 0; + + let subscribed = + identity?.atp_did && + publication?.publication_subscriptions && + publication?.publication_subscriptions.find( + (s) => s.identity === identity.atp_did, + ); + + let isAuthor = + identity && + identity.atp_did === + data.documents_in_publications[0]?.publications?.identity_did && + data.leaflets_in_publications[0]; + return (
+ {!subscribed && !isAuthor && publication && publication.record && ( +
+
+
+
Subscribe to {publication.name}
{" "} + to get updates in Reader, RSS, or via Bluesky Feed +
+ +
+
+ )} {tagCount > 0 && ( <> -
- -
- - )} +
- {props.quotesCount > 0 && ( - + + )} - {props.showComments === false ? null : ( - )} - - )} + {props.showComments === false ? null : ( + + )} +
+ + {subscribed && publication && ( + + )} +
); }; @@ -298,3 +358,23 @@ export function getCommentCount(document: PostPageData, pageId?: string) { (c) => !(c.record as PubLeafletComment.Record)?.onPage, ).length; } + +const EditButton = (props: { document: PostPageData }) => { + let { identity } = useIdentityData(); + if (!props.document) return; + if ( + identity && + identity.atp_did === + props.document.documents_in_publications[0]?.publications?.identity_did && + props.document.leaflets_in_publications[0] + ) + return ( + + Edit Post + + ); + return; +}; diff --git a/app/lish/[did]/[publication]/[rkey]/LinearDocumentPage.tsx b/app/lish/[did]/[publication]/[rkey]/LinearDocumentPage.tsx index 42b1f0e5..c5fe24c0 100644 --- a/app/lish/[did]/[publication]/[rkey]/LinearDocumentPage.tsx +++ b/app/lish/[did]/[publication]/[rkey]/LinearDocumentPage.tsx @@ -48,7 +48,6 @@ export function LinearDocumentPage({ fullPageScroll, hasPageBackground, } = props; - let { identity } = useIdentityData(); let drawer = useDrawerOpen(document_uri); if (!document) return null; @@ -85,49 +84,14 @@ export function LinearDocumentPage({ did={did} prerenderedCodeBlocks={prerenderedCodeBlocks} /> + - {!isSubpage && ( - <> -
- {identity && - identity.atp_did === - document.documents_in_publications[0]?.publications - ?.identity_did && - document.leaflets_in_publications[0] ? ( - - Edit Post - - ) : ( - document.documents_in_publications[0]?.publications && ( - - ) - )} -
- - )} + {!hasPageBackground &&
} ); diff --git a/app/lish/[did]/[publication]/[rkey]/PostContent.tsx b/app/lish/[did]/[publication]/[rkey]/PostContent.tsx index dc480c6b..8944e53b 100644 --- a/app/lish/[did]/[publication]/[rkey]/PostContent.tsx +++ b/app/lish/[did]/[publication]/[rkey]/PostContent.tsx @@ -59,7 +59,7 @@ export function PostContent({ return (
{blocks.map((b, index) => { return ( diff --git a/app/lish/[did]/[publication]/[rkey]/PostFooter.tsx b/app/lish/[did]/[publication]/[rkey]/PostFooter.tsx deleted file mode 100644 index 91c442d7..00000000 --- a/app/lish/[did]/[publication]/[rkey]/PostFooter.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import { ProfileViewDetailed } from "@atproto/api/dist/client/types/app/bsky/actor/defs"; -import { getPublicationURL } from "app/lish/createPub/getPublicationURL"; -import { SubscribeWithBluesky } from "app/lish/Subscribe"; -import { EditTiny } from "components/Icons/EditTiny"; -import { useIdentityData } from "components/IdentityProvider"; -import { PubLeafletComment } from "lexicons/api"; -import { PostPageData } from "./getPostPageData"; -import { ExpandedInteractions } from "./Interactions/Interactions"; -import { decodeQuotePosition } from "./quotePosition"; - -export const PostFooter = (props: { - data: PostPageData; - profile: ProfileViewDetailed; - preferences: { showComments?: boolean }; -}) => { - let { identity } = useIdentityData(); - if (!props.data || !props.data.documents_in_publications[0].publications) - return; - return ( -
- { - const url = new URL(q.link); - const quoteParam = url.pathname.split("/l-quote/")[1]; - if (!quoteParam) return null; - const quotePosition = decodeQuotePosition(quoteParam); - return !quotePosition?.pageId; - }).length - } - commentsCount={ - props.data.comments_on_documents.filter( - (c) => !(c.record as PubLeafletComment.Record)?.onPage, - ).length - } - /> - {identity && - identity.atp_did === - props.data.documents_in_publications[0]?.publications?.identity_did ? ( - - Edit Post - - ) : ( - - )} -
- ); -}; diff --git a/app/lish/[did]/[publication]/[rkey]/PostPages.tsx b/app/lish/[did]/[publication]/[rkey]/PostPages.tsx index 89cea1a9..05576804 100644 --- a/app/lish/[did]/[publication]/[rkey]/PostPages.tsx +++ b/app/lish/[did]/[publication]/[rkey]/PostPages.tsx @@ -21,7 +21,6 @@ import { flushSync } from "react-dom"; import { scrollIntoView } from "src/utils/scrollIntoView"; import { useParams } from "next/navigation"; import { decodeQuotePosition } from "./quotePosition"; -import { PostFooter } from "./PostFooter"; import { PollData } from "./fetchPollData"; import { LinearDocumentPage } from "./LinearDocumentPage"; import { CanvasPage } from "./CanvasPage"; -- 2.51.2