mirror of
https://github.com/lumina-rocks/lumina.git
synced 2026-06-04 17:51:16 +02:00
add GlobalQuickViewFeed (#46)
This commit is contained in:
@@ -21,7 +21,6 @@ const GlobalFeed: React.FC = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2 className="text-2xl font-bold mb-4 px-2 md:px-4">Global Feed</h2>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 px-2 md:px-4">
|
||||
{events.map((event) => {
|
||||
const imageUrl = getImageUrl(event.tags);
|
||||
|
||||
72
components/GlobalQuickViewFeed.tsx
Normal file
72
components/GlobalQuickViewFeed.tsx
Normal file
@@ -0,0 +1,72 @@
|
||||
import { useRef, useState } from "react";
|
||||
import { useNostrEvents } from "nostr-react";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import QuickViewKind20NoteCard from "./QuickViewKind20NoteCard";
|
||||
import { getImageUrl } from "@/utils/utils";
|
||||
|
||||
const GlobalQuickViewFeed: React.FC = () => {
|
||||
const now = useRef(new Date());
|
||||
const [limit, setLimit] = useState(25);
|
||||
|
||||
const { events, isLoading } = useNostrEvents({
|
||||
filter: {
|
||||
limit: limit,
|
||||
kinds: [20],
|
||||
since: Math.floor((now.current.getTime() - 24 * 60 * 60 * 1000) / 1000), // Last 24 hours
|
||||
},
|
||||
});
|
||||
|
||||
const loadMore = () => {
|
||||
setLimit(prevLimit => prevLimit + 25);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="grid grid-cols-3 gap-2">
|
||||
{events.length === 0 && isLoading ? (
|
||||
<>
|
||||
<div>
|
||||
<Skeleton className="h-[33vh] rounded-xl" />
|
||||
</div>
|
||||
<div>
|
||||
<Skeleton className="h-[33vh] rounded-xl" />
|
||||
</div>
|
||||
<div>
|
||||
<Skeleton className="h-[33vh] rounded-xl" />
|
||||
</div>
|
||||
<div>
|
||||
<Skeleton className="h-[33vh] rounded-xl" />
|
||||
</div>
|
||||
<div>
|
||||
<Skeleton className="h-[33vh] rounded-xl" />
|
||||
</div>
|
||||
<div>
|
||||
<Skeleton className="h-[33vh] rounded-xl" />
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
events.map((event) => (
|
||||
<QuickViewKind20NoteCard
|
||||
key={event.id}
|
||||
pubkey={event.pubkey}
|
||||
text={event.content}
|
||||
image={getImageUrl(event.tags)}
|
||||
event={event}
|
||||
tags={event.tags}
|
||||
eventId={event.id}
|
||||
linkToNote={true}
|
||||
/>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
{!isLoading && (
|
||||
<div className="flex justify-center p-4">
|
||||
<Button className="w-full md:w-auto" onClick={loadMore}>Load More</Button>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default GlobalQuickViewFeed;
|
||||
Reference in New Issue
Block a user