diff --git a/app/discover/PubListing.tsx b/app/discover/PubListing.tsx index f12095ed..1aefbe06 100644 --- a/app/discover/PubListing.tsx +++ b/app/discover/PubListing.tsx @@ -1,6 +1,7 @@ "use client"; import { AtUri } from "@atproto/syntax"; import { PubIcon } from "components/ActionBar/Publications"; +import { Separator } from "components/Layout"; import { usePubTheme } from "components/ThemeManager/PublicationThemeProvider"; import { BaseThemeProvider } from "components/ThemeManager/ThemeProvider"; import { PubLeafletPublication, PubLeafletThemeColor } from "lexicons/api"; @@ -9,11 +10,11 @@ import { timeAgo } from "src/utils/timeAgo"; import { Json } from "supabase/database.types"; export const PubListing = (props: { + resizeHeight?: boolean; record: Json; uri: string; documents_in_publications: { - indexed_at: string; - documents: { data: Json } | null; + documents: { data: Json; indexed_at: string } | null; }[]; }) => { let record = props.record as PubLeafletPublication.Record; @@ -43,16 +44,33 @@ export const PubListing = (props: { px-3 py-3 selected-outline hover:outline-accent-contrast hover:border-accent-contrast`} > - -
-

{record.name}

-

{record.description}

-
+
+ +
+ +

{record.name}

+ {record.description && ( +

+ {record.description} +

+ )} +
+
+
+

Name Here

{" "} +

- Updated {timeAgo(props.documents_in_publications[0].indexed_at)} + Updated{" "} + {timeAgo( + props.documents_in_publications.sort((a, b) => { + let dateA = new Date(a.documents?.indexed_at || 0); + let dateB = new Date(b.documents?.indexed_at || 0); + return dateB.getTime() - dateA.getTime(); + })[0].documents?.indexed_at || "", + )}

diff --git a/app/discover/SortedPublicationList.tsx b/app/discover/SortedPublicationList.tsx index 71aaa6b5..9641f29f 100644 --- a/app/discover/SortedPublicationList.tsx +++ b/app/discover/SortedPublicationList.tsx @@ -39,7 +39,7 @@ export function SortedPublicationList(props: { ); return bDate.getTime() - aDate.getTime(); }) - .map((pub) => )} + .map((pub) => )}
); diff --git a/app/reader/SubscriptionsContent.tsx b/app/reader/SubscriptionsContent.tsx index b4537f52..7c77807d 100644 --- a/app/reader/SubscriptionsContent.tsx +++ b/app/reader/SubscriptionsContent.tsx @@ -1,3 +1,31 @@ -export const SubscriptionsContent = () => { - return
subs here
; +import { PubListing } from "app/discover/PubListing"; +import { PublicationsList } from "app/discover/page"; +import { ButtonPrimary } from "components/Buttons"; +import { DiscoverSmall } from "components/Icons/DiscoverSmall"; +import { Json } from "supabase/database.types"; + +export const SubscriptionsContent = (props: { + publications: { + record: Json; + uri: string; + documents_in_publications: { + documents: { data: Json; indexed_at: string } | null; + }[]; + }[]; +}) => { + if (props.publications.length === 0) + return ( +
+ Looks like you don't have any publication subscriptions yet! + + Discover Publications! + +
+ ); + + return ( +
+ {props.publications?.map((p) => )} +
+ ); }; diff --git a/app/reader/page.tsx b/app/reader/page.tsx index 925153bc..dc233693 100644 --- a/app/reader/page.tsx +++ b/app/reader/page.tsx @@ -95,13 +95,18 @@ export default async function Reader(props: {}) { .select(`publications(*, documents_in_publications(documents(*)))`) .eq("identity", auth_res?.atp_did); + // get publications to fit PublicationList type + let subbedPublications = + publications + ?.map((subscription) => subscription.publications) + .filter((pub) => pub !== null) || []; + // Flatten all posts from all publications into a single array let posts = - publications?.flatMap((publication) => { - const postsInPub = - publication.publications?.documents_in_publications.filter( - (d) => !!d?.documents, - ); + subbedPublications?.flatMap((pub) => { + const postsInPub = pub.documents_in_publications.filter( + (d) => !!d?.documents, + ); if (!postsInPub || postsInPub.length === 0) return []; @@ -114,9 +119,9 @@ export default async function Reader(props: {}) { ) .map((postInPub) => ({ publication: { - href: getPublicationURL(publication.publications!), - pubRecord: publication.publications?.record || null, - uri: publication.publications?.uri || "", + href: getPublicationURL(pub!), + pubRecord: pub?.record || null, + uri: pub?.uri || "", }, documents: { data: postInPub.documents!.data, @@ -162,9 +167,11 @@ export default async function Reader(props: {}) { /> ), }, - subs: { + subscriptions: { controls: null, - content: , + content: ( + + ), }, discover: { controls: null, diff --git a/components/ActionBar/Publications.tsx b/components/ActionBar/Publications.tsx index e5fe0502..d436717d 100644 --- a/components/ActionBar/Publications.tsx +++ b/components/ActionBar/Publications.tsx @@ -94,6 +94,7 @@ export const PubIcon = (props: { record: PubLeafletPublication.Record; uri: string; small?: boolean; + large?: boolean; className?: string; }) => { if (!props.record) return; @@ -106,14 +107,14 @@ export const PubIcon = (props: { backgroundSize: "cover", backgroundImage: `url(/api/atproto_images?did=${new AtUri(props.uri).host}&cid=${(props.record.icon?.ref as unknown as { $link: string })["$link"]})`, }} - className={`${props.small ? "w-5 h-5" : "w-6 h-6"} rounded-full ${props.className}`} + className={`${props.small ? "w-5 h-5" : props.large ? "w-12 h-12" : "w-6 h-6"} rounded-full ${props.className}`} /> ) : (
{props.record?.name.slice(0, 1)}