diff --git a/app/(home-pages)/reader/InboxContent.tsx b/app/(home-pages)/reader/InboxContent.tsx index a2ea6e07..0770dbc4 100644 --- a/app/(home-pages)/reader/InboxContent.tsx +++ b/app/(home-pages)/reader/InboxContent.tsx @@ -4,9 +4,13 @@ import { DiscoverSmall } from "components/Icons/DiscoverSmall"; import type { Cursor, Post } from "./getReaderFeed"; import useSWRInfinite from "swr/infinite"; import { getReaderFeed } from "./getReaderFeed"; -import { useEffect, useRef } from "react"; +import { useEffect, useRef, useState } from "react"; import Link from "next/link"; import { PostListing } from "components/PostListing"; +import { SortSmall } from "components/Icons/SortSmall"; +import { Input } from "components/Input"; +import { useHasBackgroundImage } from "components/Pages/useHasBackgroundImage"; +import { InteractionDrawer } from "app/lish/[did]/[publication]/[rkey]/Interactions/InteractionDrawer"; export const InboxContent = (props: { posts: Post[]; @@ -60,27 +64,71 @@ export const InboxContent = (props: { return () => observer.disconnect(); }, [data, size, setSize, isValidating]); + let [searchValue, setSearchValue] = useState(""); + let [sort, setSort] = useState<"recent" | "popular">("popular"); const allPosts = data ? data.flatMap((page) => page.posts) : []; + const postTitles = allPosts.map((p) => { + p.documents.data?.title; + }); + const filteredPosts = allPosts + .filter((p) => + p.documents.data?.title.toLowerCase().includes(searchValue.toLowerCase()), + ) + .sort( + (a, b) => + new Date(b.documents.data?.publishedAt || 0).getTime() - + new Date(a.documents.data?.publishedAt || 0).getTime(), + ); if (allPosts.length === 0 && !isValidating) return ; + let hasBackgroundImage = useHasBackgroundImage(); + return ( -
- {allPosts.map((p) => ( - - ))} - {/* Trigger element for loading more posts */} -