+
-
-
- {props.pub}
-
-
-
- {props.title}
+
+
+
+
+
{postRecord.title}
-
{props.description}
-
-
-
- {props.author}
+
{postRecord.description}
+
+
+
+ {pubRecord.name}
+
+
+ NAME HERE
+
+ {postRecord.publishedAt &&
+ new Date(postRecord.publishedAt).toLocaleDateString("en-US", {
+ year: "numeric",
+ month: "short",
+ day: "numeric",
+ })}
-
- {props.date}
-
-
+
+
);
};
-
-let dummyPosts: {
- title: string;
- description: string;
- date: string;
- read: boolean;
- author: string;
- pub: string;
-}[] = [
- {
- title: "First Post",
- description: "this is a description",
- date: "Oct 2",
- read: false,
- author: "jared",
- pub: "a warm space",
- },
- {
- title: "This is a second Tost",
- description: "It has another description, as you can see",
- date: "Oct 2",
- read: false,
- author: "celine",
- pub: "Celine's Super Soliloquy",
- },
- {
- title: "A Third Post, A Burnt Toast",
- description:
- "If the first post is bread, the second is toast, and inevitably the third is a plate of charcoal.",
- date: "Oct 2",
- read: false,
- author: "brendan",
- pub: "Scraps",
- },
-];
diff --git a/app/reader/page.tsx b/app/reader/page.tsx
index f2de1d5e..925153bc 100644
--- a/app/reader/page.tsx
+++ b/app/reader/page.tsx
@@ -18,6 +18,9 @@ import { NotFoundLayout } from "components/PageLayouts/NotFoundLayout";
import { DashboardLayout } from "components/PageLayouts/DashboardLayout";
import { ReaderContent } from "./ReaderContent";
import { SubscriptionsContent } from "./SubscriptionsContent";
+import { Json } from "supabase/database.types";
+import { getPublicationURL } from "app/lish/createPub/getPublicationURL";
+import { PubLeafletDocument } from "lexicons/api";
export default async function Reader(props: {}) {
let cookieStore = await cookies();
@@ -92,14 +95,44 @@ export default async function Reader(props: {}) {
.select(`publications(*, documents_in_publications(documents(*)))`)
.eq("identity", auth_res?.atp_did);
- let subbedPubs = publications?.map((pub) => {
- let subbedPubsArr: string[] = [];
- pub.publications?.name && subbedPubsArr.push(pub.publications?.name);
- return subbedPubsArr;
- });
+ // 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,
+ );
+
+ if (!postsInPub || postsInPub.length === 0) return [];
- console.log(subbedPubs);
+ return postsInPub
+ .filter(
+ (postInPub) =>
+ postInPub.documents?.data &&
+ postInPub.documents?.uri &&
+ postInPub.documents?.indexed_at,
+ )
+ .map((postInPub) => ({
+ publication: {
+ href: getPublicationURL(publication.publications!),
+ pubRecord: publication.publications?.record || null,
+ uri: publication.publications?.uri || "",
+ },
+ documents: {
+ data: postInPub.documents!.data,
+ uri: postInPub.documents!.uri,
+ indexed_at: postInPub.documents!.indexed_at,
+ },
+ }));
+ }) || [];
+ let sortedPosts = posts.sort((a, b) => {
+ let recordA = a.documents.data as PubLeafletDocument.Record;
+ let recordB = b.documents.data as PubLeafletDocument.Record;
+ const dateA = new Date(recordA.publishedAt || 0);
+ const dateB = new Date(recordB.publishedAt || 0);
+ return dateB.getTime() - dateA.getTime();
+ });
return (
,
- content:
,
+ controls: null,
+ content: (
+
+ ),
},
subs: {
controls: null,
@@ -141,7 +179,3 @@ export default async function Reader(props: {}) {
);
}
-
-const FocusToggle = () => {
- return
focus
;
-};
diff --git a/components/ActionBar/Publications.tsx b/components/ActionBar/Publications.tsx
index 696f1a3c..e5fe0502 100644
--- a/components/ActionBar/Publications.tsx
+++ b/components/ActionBar/Publications.tsx
@@ -93,6 +93,8 @@ const PubListEmpty = () => {
export const PubIcon = (props: {
record: PubLeafletPublication.Record;
uri: string;
+ small?: boolean;
+ className?: string;
}) => {
if (!props.record) return;
@@ -104,11 +106,15 @@ 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="w-6 h-6 rounded-full"
+ className={`${props.small ? "w-5 h-5" : "w-6 h-6"} rounded-full ${props.className}`}
/>
) : (
-
-
+
+
{props.record?.name.slice(0, 1)}
diff --git a/components/PageHeader.tsx b/components/PageHeader.tsx
index 0c41ccfe..89eee9ec 100644
--- a/components/PageHeader.tsx
+++ b/components/PageHeader.tsx
@@ -6,7 +6,6 @@ export const Header = (props: {
cardBorderHidden: boolean;
}) => {
let [scrollPos, setScrollPos] = useState(0);
- console.log(props.cardBorderHidden);
useEffect(() => {
const homeContent = document.getElementById("home-content");