mirror of
https://github.com/lumina-rocks/lumina.git
synced 2026-04-14 17:36:52 +02:00
Update hashtag routing in NoteContent and enhance hashtag search logic in useHashtagFeed
This commit is contained in:
@@ -98,8 +98,8 @@ describe('NoteContent', () => {
|
||||
|
||||
expect(nostrHashtag).toBeInTheDocument();
|
||||
expect(bitcoinHashtag).toBeInTheDocument();
|
||||
expect(nostrHashtag).toHaveAttribute('href', '/t/nostr');
|
||||
expect(bitcoinHashtag).toHaveAttribute('href', '/t/bitcoin');
|
||||
expect(nostrHashtag).toHaveAttribute('href', '/tag/nostr');
|
||||
expect(bitcoinHashtag).toHaveAttribute('href', '/tag/bitcoin');
|
||||
});
|
||||
|
||||
it('generates deterministic names for users without metadata and styles them differently', () => {
|
||||
|
||||
@@ -83,7 +83,7 @@ export function NoteContent({
|
||||
parts.push(
|
||||
<Link
|
||||
key={`hashtag-${keyCounter++}`}
|
||||
to={`/t/${tag}`}
|
||||
to={`/tag/${tag}`}
|
||||
className="text-blue-500 hover:underline"
|
||||
>
|
||||
{hashtag}
|
||||
|
||||
@@ -8,13 +8,18 @@ import type { NostrEvent } from '@nostrify/nostrify';
|
||||
export function useHashtagFeed(hashtag: string) {
|
||||
const { nostr } = useNostr();
|
||||
const normalizedTag = hashtag.toLowerCase();
|
||||
|
||||
// Search for both normalized and original tag if they differ
|
||||
const tagsToSearch = normalizedTag === hashtag
|
||||
? [normalizedTag]
|
||||
: [normalizedTag, hashtag];
|
||||
|
||||
return useInfiniteQuery({
|
||||
queryKey: ['hashtag-feed', normalizedTag],
|
||||
queryFn: async ({ pageParam, signal }) => {
|
||||
const filter = pageParam
|
||||
? { kinds: [20], '#t': [normalizedTag], limit: 20, until: pageParam as number }
|
||||
: { kinds: [20], '#t': [normalizedTag], limit: 20 };
|
||||
? { kinds: [20], '#t': tagsToSearch, limit: 20, until: pageParam as number }
|
||||
: { kinds: [20], '#t': tagsToSearch, limit: 20 };
|
||||
|
||||
const events = await nostr.query([filter], {
|
||||
signal: AbortSignal.any([signal, AbortSignal.timeout(1500)])
|
||||
|
||||
Reference in New Issue
Block a user