Display plugins from people you follow

This commit is contained in:
Alex Gleason committed 2025-12-04 18:06:13 -06:00
1 parent 4c9e688009
commit 9005a2c38e
8 files changed
+103 -13

No files matched your search

+22 -1
View File
@@ -1,6 +1,8 @@
import { useQuery } from '@tanstack/react-query';
import { useNostr } from '@nostrify/react';
import type { NostrEvent } from '@nostrify/nostrify';
import { useCurrentUser } from './useCurrentUser';
import { useContacts } from './useContacts';
export interface DiscoveredPlugin {
id: string;
@@ -15,20 +17,39 @@ export interface DiscoveredPlugin {
/**
* Hook to discover Shakespeare plugins on Nostr
* Queries NIP-34 git repository announcements with t-tag "shakespeare-plugin"
* Filters to only show plugins by the current user and people they follow
*/
export function useDiscoverPlugins() {
const { nostr } = useNostr();
const { user } = useCurrentUser();
const { data: contacts } = useContacts(user?.pubkey);
return useQuery({
queryKey: ['discover-plugins'],
queryKey: ['discover-plugins', user?.pubkey, contacts],
queryFn: async (c) => {
const signal = AbortSignal.any([c.signal, AbortSignal.timeout(5000)]);
// Build authors list: current user + people they follow
const authors: string[] = [];
if (user?.pubkey) {
authors.push(user.pubkey);
}
if (contacts && contacts.length > 0) {
authors.push(...contacts);
}
// If no authors (user not logged in or no follows), return empty array
if (authors.length === 0) {
return [];
}
// Query NIP-34 repository announcements (kind 30617) with shakespeare-plugin tag
// Filter by authors: current user + people they follow
const events = await nostr.query(
[
{
kinds: [30617],
authors,
'#t': ['shakespeare-plugin'],
limit: 100,
},