From 511419989e8b25077f5bcfa85c41672fc7db2a5c Mon Sep 17 00:00:00 2001 From: Ewan Date: Fri, 21 Nov 2025 01:03:28 +0000 Subject: [PATCH] fix: prevent user from subscribing to own publication --- app/lish/Subscribe.tsx | 10 ++++++++++ .../[did]/[publication]/[rkey]/LinearDocumentPage.tsx | 4 ++++ app/lish/[did]/[publication]/page.tsx | 1 + 3 files changed, 15 insertions(+) diff --git a/app/lish/Subscribe.tsx b/app/lish/Subscribe.tsx index 001ff6f..aa2bd1d 100644 --- a/app/lish/Subscribe.tsx +++ b/app/lish/Subscribe.tsx @@ -186,6 +186,7 @@ export const SubscribeWithBluesky = (props: { pub_uri: string; base_url: string; subscribers: { identity: string }[]; + pub_creator?: string; }) => { let { identity } = useIdentityData(); let searchParams = useSearchParams(); @@ -195,6 +196,9 @@ export const SubscribeWithBluesky = (props: { let subscribed = identity?.atp_did && props.subscribers.find((s) => s.identity === identity.atp_did); + + // Check if the logged-in user is the publication owner + let isOwner = identity?.atp_did && props.pub_creator === identity.atp_did; if (successModalOpen) return ( @@ -203,6 +207,12 @@ export const SubscribeWithBluesky = (props: { setOpen={setSuccessModalOpen} /> ); + + // Don't allow users to subscribe to their own publication + if (isOwner) { + return null; + } + if (subscribed) { return ; } diff --git a/app/lish/[did]/[publication]/[rkey]/LinearDocumentPage.tsx b/app/lish/[did]/[publication]/[rkey]/LinearDocumentPage.tsx index ffa27a2..d64d594 100644 --- a/app/lish/[did]/[publication]/[rkey]/LinearDocumentPage.tsx +++ b/app/lish/[did]/[publication]/[rkey]/LinearDocumentPage.tsx @@ -129,6 +129,10 @@ export function LinearDocumentPage({ pubName={ document.documents_in_publications[0].publications.name } + pub_creator={ + document.documents_in_publications[0].publications + .identity_did + } /> )} diff --git a/app/lish/[did]/[publication]/page.tsx b/app/lish/[did]/[publication]/page.tsx index 0d21712..45fef66 100644 --- a/app/lish/[did]/[publication]/page.tsx +++ b/app/lish/[did]/[publication]/page.tsx @@ -107,6 +107,7 @@ export default async function Publication(props: { pubName={publication.name} pub_uri={publication.uri} subscribers={publication.publication_subscriptions} + pub_creator={publication.identity_did} /> -- 2.43.0 From d8c60bc844947e556431334e6db83276bac65366 Mon Sep 17 00:00:00 2001 From: Ewan Date: Fri, 21 Nov 2025 19:31:17 +0000 Subject: [PATCH] feat: add Edit Publication button for owners on publication homepage Replace subscribe section with "Edit Publication" button when viewing own publication. Button links to dashboard and matches styling of existing edit post button. --- app/lish/[did]/[publication]/page.tsx | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/app/lish/[did]/[publication]/page.tsx b/app/lish/[did]/[publication]/page.tsx index 45fef66..ac36223 100644 --- a/app/lish/[did]/[publication]/page.tsx +++ b/app/lish/[did]/[publication]/page.tsx @@ -15,6 +15,8 @@ import { SpeedyLink } from "components/SpeedyLink"; import { QuoteTiny } from "components/Icons/QuoteTiny"; import { CommentTiny } from "components/Icons/CommentTiny"; import { LocalizedDate } from "./LocalizedDate"; +import { EditTiny } from "components/Icons/EditTiny"; +import { getIdentityData } from "actions/getIdentityData"; export default async function Publication(props: { params: Promise<{ publication: string; did: string }>; @@ -22,6 +24,7 @@ export default async function Publication(props: { let params = await props.params; let did = decodeURIComponent(params.did); if (!did) return ; + let identity = await getIdentityData(); let agent = new BskyAgent({ service: "https://public.api.bsky.app" }); let uri; let publication_name = decodeURIComponent(params.publication); @@ -102,13 +105,22 @@ export default async function Publication(props: {

)}
- + {identity?.atp_did === publication.identity_did ? ( + + Edit Publication + + ) : ( + + )}
-- 2.43.0 From f5cdaff3e4a53f1ff37b89aa869f01cf198667a3 Mon Sep 17 00:00:00 2001 From: Ewan Date: Wed, 3 Dec 2025 11:11:16 +0000 Subject: [PATCH] refactor: streamline LinearDocumentPage and enhance Publication layout --- .../[rkey]/LinearDocumentPage.tsx | 90 +++---- app/lish/[did]/[publication]/page.tsx | 244 +++++++++--------- 2 files changed, 162 insertions(+), 172 deletions(-) diff --git a/app/lish/[did]/[publication]/[rkey]/LinearDocumentPage.tsx b/app/lish/[did]/[publication]/[rkey]/LinearDocumentPage.tsx index d64d594..968de98 100644 --- a/app/lish/[did]/[publication]/[rkey]/LinearDocumentPage.tsx +++ b/app/lish/[did]/[publication]/[rkey]/LinearDocumentPage.tsx @@ -23,43 +23,35 @@ import { useDrawerOpen } from "./Interactions/InteractionDrawer"; import { PageWrapper } from "components/Pages/Page"; import { decodeQuotePosition } from "./quotePosition"; import { PollData } from "./fetchPollData"; +import { SharedPageProps } from "./PostPages"; export function LinearDocumentPage({ - document, blocks, - did, - profile, - preferences, - pubRecord, - prerenderedCodeBlocks, - bskyPostData, - document_uri, - pageId, - pageOptions, - pollData, - fullPageScroll, -}: { - document_uri: string; - document: PostPageData; + ...props +}: Omit & { blocks: PubLeafletPagesLinearDocument.Block[]; - profile?: ProfileViewDetailed; - pubRecord: PubLeafletPublication.Record; - did: string; - prerenderedCodeBlocks?: Map; - bskyPostData: AppBskyFeedDefs.PostView[]; - pollData: PollData[]; - preferences: { showComments?: boolean }; - pageId?: string; - pageOptions?: React.ReactNode; - fullPageScroll: boolean; }) { + const { + document, + did, + profile, + preferences, + pubRecord, + theme, + prerenderedCodeBlocks, + bskyPostData, + pollData, + document_uri, + pageId, + pageOptions, + fullPageScroll, + hasPageBackground, + } = props; let { identity } = useIdentityData(); let drawer = useDrawerOpen(document_uri); - if (!document || !document.documents_in_publications[0].publications) - return null; + if (!document) return null; - let hasPageBackground = !!pubRecord.theme?.showPageBackground; let record = document.data as PubLeafletDocument.Record; const isSubpage = !!pageId; @@ -114,26 +106,28 @@ export function LinearDocumentPage({ Edit Post ) : ( - + document.documents_in_publications[0]?.publications && ( + + ) )}
diff --git a/app/lish/[did]/[publication]/page.tsx b/app/lish/[did]/[publication]/page.tsx index ac36223..8fab538 100644 --- a/app/lish/[did]/[publication]/page.tsx +++ b/app/lish/[did]/[publication]/page.tsx @@ -15,6 +15,7 @@ import { SpeedyLink } from "components/SpeedyLink"; import { QuoteTiny } from "components/Icons/QuoteTiny"; import { CommentTiny } from "components/Icons/CommentTiny"; import { LocalizedDate } from "./LocalizedDate"; +import { PublicationHomeLayout } from "./PublicationHomeLayout"; import { EditTiny } from "components/Icons/EditTiny"; import { getIdentityData } from "actions/getIdentityData"; @@ -62,148 +63,143 @@ export default async function Publication(props: { try { return ( -
-
-
- {record?.icon && ( -
- )} -

- {publication.name} -

-

- {record?.description}{" "} +

+ {record?.icon && ( +
+ )} +

+ {publication.name} +

+

+ {record?.description}{" "} +

+ {profile && ( +

+ by {profile.displayName}{" "} + + @{profile.handle} +

- {profile && ( -

- by {profile.displayName}{" "} - - @{profile.handle} - -

+ )} +
+ {identity?.atp_did === publication.identity_did ? ( + + Edit Publication + + ) : ( + )} -
- {identity?.atp_did === publication.identity_did ? ( - - Edit Publication - - ) : ( - - )} -
-
- {publication.documents_in_publications - .filter((d) => !!d?.documents) - .sort((a, b) => { - let aRecord = a.documents - ?.data! as PubLeafletDocument.Record; - let bRecord = b.documents - ?.data! as PubLeafletDocument.Record; - const aDate = aRecord.publishedAt - ? new Date(aRecord.publishedAt) - : new Date(0); - const bDate = bRecord.publishedAt - ? new Date(bRecord.publishedAt) - : new Date(0); - return bDate.getTime() - aDate.getTime(); // Sort by most recent first - }) - .map((doc) => { - if (!doc.documents) return null; - let uri = new AtUri(doc.documents.uri); - let doc_record = doc.documents - .data as PubLeafletDocument.Record; - let quotes = - doc.documents.document_mentions_in_bsky[0].count || 0; - let comments = - record?.preferences?.showComments === false - ? 0 - : doc.documents.comments_on_documents[0].count || 0; +
+
+ {publication.documents_in_publications + .filter((d) => !!d?.documents) + .sort((a, b) => { + let aRecord = a.documents?.data! as PubLeafletDocument.Record; + let bRecord = b.documents?.data! as PubLeafletDocument.Record; + const aDate = aRecord.publishedAt + ? new Date(aRecord.publishedAt) + : new Date(0); + const bDate = bRecord.publishedAt + ? new Date(bRecord.publishedAt) + : new Date(0); + return bDate.getTime() - aDate.getTime(); // Sort by most recent first + }) + .map((doc) => { + if (!doc.documents) return null; + let uri = new AtUri(doc.documents.uri); + let doc_record = doc.documents + .data as PubLeafletDocument.Record; + let quotes = + doc.documents.document_mentions_in_bsky[0].count || 0; + let comments = + record?.preferences?.showComments === false + ? 0 + : doc.documents.comments_on_documents[0].count || 0; - return ( - -
- -

{doc_record.title}

-

- {doc_record.description} -

-
+ return ( + +
+ +

{doc_record.title}

+

+ {doc_record.description} +

+
-
-

- {doc_record.publishedAt && ( - - )}{" "} -

- {comments > 0 || quotes > 0 ? "| " : ""} - {quotes > 0 && ( +
+

+ {doc_record.publishedAt && ( + + )}{" "} +

+ {comments > 0 || quotes > 0 ? "| " : ""} + {quotes > 0 && ( + + {quotes} + + )} + {comments > 0 && + record?.preferences?.showComments !== false && ( - {quotes} + {comments} )} - {comments > 0 && - record?.preferences?.showComments !== false && ( - - {comments} - - )} -
-
- - ); - })} -
+
+
+
+ ); + })}
-
+ ); -- 2.43.0