This commit is contained in:
Ren Amamiya
2023-08-12 11:18:10 +07:00
parent 36b2acba6a
commit bb089bb259
27 changed files with 502 additions and 481 deletions

View File

@@ -11,14 +11,14 @@ import { nHoursAgo } from '@utils/date';
import { LumeEvent, Widget } from '@utils/types';
export function HashtagBlock({ params }: { params: Widget }) {
const { relayUrls, fetcher } = useNDK();
const { ndk } = useNDK();
const { status, data } = useQuery(['hashtag', params.content], async () => {
const events = (await fetcher.fetchAllEvents(
relayUrls,
{ kinds: [1], '#t': [params.content] },
{ since: nHoursAgo(24) }
)) as unknown as LumeEvent[];
return events;
const events = await ndk.fetchEvents({
kinds: [1],
'#t': [params.content],
since: nHoursAgo(24),
});
return [...events] as unknown as LumeEvent[];
});
const parentRef = useRef();

View File

@@ -14,15 +14,14 @@ import { LumeEvent, Widget } from '@utils/types';
export function UserBlock({ params }: { params: Widget }) {
const parentRef = useRef<HTMLDivElement>(null);
const { fetcher, relayUrls } = useNDK();
const { ndk } = useNDK();
const { status, data } = useQuery(['user-feed', params.content], async () => {
const events = await fetcher.fetchAllEvents(
relayUrls,
{ kinds: [1], authors: [params.content] },
{ since: nHoursAgo(48) },
{ sort: true }
);
return events as unknown as LumeEvent[];
const events = await ndk.fetchEvents({
kinds: [1],
authors: [params.content],
since: nHoursAgo(48),
});
return [...events] as unknown as LumeEvent[];
});
const rowVirtualizer = useVirtualizer({
@@ -42,9 +41,7 @@ export function UserBlock({ params }: { params: Widget }) {
<UserProfile pubkey={params.content} />
</div>
<div>
<h3 className="mt-4 px-3 text-lg font-semibold text-white">
Latest activities
</h3>
<h3 className="mt-4 px-3 text-lg font-semibold text-white">Latest postrs</h3>
<div className="flex h-full w-full flex-col justify-between gap-1.5 pb-10">
{status === 'loading' ? (
<div className="px-3 py-1.5">
@@ -57,7 +54,7 @@ export function UserBlock({ params }: { params: Widget }) {
<div className="rounded-xl bg-white/10 px-3 py-6">
<div className="flex flex-col items-center gap-4">
<p className="text-center text-sm text-white">
No new posts about this hashtag in 48 hours ago
No new posts from this user in 48 hours ago
</p>
</div>
</div>