Merge branch 'main' into fix-kind-0-photo

Conflicts:
	src/hooks/useAuthor.ts
	src/hooks/useLoggedInAccounts.ts
This commit is contained in:
P. Reis 2025-04-23 17:16:11 -03:00
commit 206a9977a3
8 changed files with 60 additions and 32 deletions

View File

@ -106,8 +106,9 @@ function usePosts() {
return useQuery({ return useQuery({
queryKey: ['posts'], queryKey: ['posts'],
queryFn: async () => { queryFn: async (c) => {
const events = await nostr.query([{ kinds: [1], limit: 20 }]); const signal = AbortSignal.any([c.signal, AbortSignal.timeout(1500)]);
const events = await nostr.query([{ kinds: [1], limit: 20 }], { signal });
return events; // these events could be transformed into another format return events; // these events could be transformed into another format
}, },
}); });

24
package-lock.json generated
View File

@ -9,8 +9,8 @@
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"@hookform/resolvers": "^3.9.0", "@hookform/resolvers": "^3.9.0",
"@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.43.0", "@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.44.0",
"@nostrify/react": "npm:@jsr/nostrify__react@^0.2.0", "@nostrify/react": "npm:@jsr/nostrify__react@^0.2.1",
"@radix-ui/react-accordion": "^1.2.0", "@radix-ui/react-accordion": "^1.2.0",
"@radix-ui/react-alert-dialog": "^1.1.1", "@radix-ui/react-alert-dialog": "^1.1.1",
"@radix-ui/react-aspect-ratio": "^1.1.0", "@radix-ui/react-aspect-ratio": "^1.1.0",
@ -414,9 +414,9 @@
} }
}, },
"node_modules/@jsr/nostrify__nostrify": { "node_modules/@jsr/nostrify__nostrify": {
"version": "0.43.0", "version": "0.44.0",
"resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__nostrify/0.43.0.tgz", "resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__nostrify/0.44.0.tgz",
"integrity": "sha512-rl4jDvxadeCjLsp78lpu8TtuQMiR80alTj4TF33puJgNlbJn0xW6pYWpkw6WOgsgjAvUeytMm3FvdFEnibr+iQ==", "integrity": "sha512-xkN00DJadsTZjhV7D3iQfU6NG9FCzZ/8nljzty5+BTeOyy/nNMLJo3vTrs/IG0dbutJrVn+g/fOjQ5WTW9J4kw==",
"dependencies": { "dependencies": {
"@jsr/nostrify__types": "^0.36.0", "@jsr/nostrify__types": "^0.36.0",
"@jsr/scure__base": "^1.2.4", "@jsr/scure__base": "^1.2.4",
@ -552,9 +552,9 @@
}, },
"node_modules/@nostrify/nostrify": { "node_modules/@nostrify/nostrify": {
"name": "@jsr/nostrify__nostrify", "name": "@jsr/nostrify__nostrify",
"version": "0.43.0", "version": "0.44.0",
"resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__nostrify/0.43.0.tgz", "resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__nostrify/0.44.0.tgz",
"integrity": "sha512-rl4jDvxadeCjLsp78lpu8TtuQMiR80alTj4TF33puJgNlbJn0xW6pYWpkw6WOgsgjAvUeytMm3FvdFEnibr+iQ==", "integrity": "sha512-xkN00DJadsTZjhV7D3iQfU6NG9FCzZ/8nljzty5+BTeOyy/nNMLJo3vTrs/IG0dbutJrVn+g/fOjQ5WTW9J4kw==",
"dependencies": { "dependencies": {
"@jsr/nostrify__types": "^0.36.0", "@jsr/nostrify__types": "^0.36.0",
"@jsr/scure__base": "^1.2.4", "@jsr/scure__base": "^1.2.4",
@ -568,11 +568,11 @@
}, },
"node_modules/@nostrify/react": { "node_modules/@nostrify/react": {
"name": "@jsr/nostrify__react", "name": "@jsr/nostrify__react",
"version": "0.2.0", "version": "0.2.1",
"resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__react/0.2.0.tgz", "resolved": "https://npm.jsr.io/~/11/@jsr/nostrify__react/0.2.1.tgz",
"integrity": "sha512-zV3sMK0oKuwhzazr8C8cnyr6oemYVUoJ63Ik77MeANudto9EUPw8Hp/FtnMX4UDBjr8pU/JXxbEqilCz9CxHzA==", "integrity": "sha512-raKZLgyL07Mb+dtg+aPD8i3eWYMqyv/ko9MXliOvbAX1Ki5o4cBorjsGShT0LvOOgP+2l4e+ZMpl2mceVRjILQ==",
"dependencies": { "dependencies": {
"@jsr/nostrify__nostrify": "^0.43.0", "@jsr/nostrify__nostrify": "^0.44.0",
"nostr-tools": "^2.10.4", "nostr-tools": "^2.10.4",
"react": "^18.0.0" "react": "^18.0.0"
} }

View File

@ -13,8 +13,8 @@
}, },
"dependencies": { "dependencies": {
"@hookform/resolvers": "^3.9.0", "@hookform/resolvers": "^3.9.0",
"@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.43.0", "@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.44.0",
"@nostrify/react": "npm:@jsr/nostrify__react@^0.2.0", "@nostrify/react": "npm:@jsr/nostrify__react@^0.2.1",
"@radix-ui/react-accordion": "^1.2.0", "@radix-ui/react-accordion": "^1.2.0",
"@radix-ui/react-alert-dialog": "^1.1.1", "@radix-ui/react-alert-dialog": "^1.1.1",
"@radix-ui/react-aspect-ratio": "^1.1.0", "@radix-ui/react-aspect-ratio": "^1.1.0",

32
recipe.yaml Normal file
View File

@ -0,0 +1,32 @@
version: 1.0.0
title: Nostr Client Development
description: A recipe for building Nostr client applications
instructions: Create a Nostr client application according to the user's request.
extensions:
- type: builtin
name: developer
display_name: Developer Tools
timeout: 300
bundled: true
- type: stdio
name: nostr
cmd: npx
args:
- -y
- xjsr
- "@nostrbook/mcp"
envs: {}
timeout: 20
description: null
bundled: null
- type: stdio
name: fetch
cmd: uvx
args:
- mcp-server-fetch
envs: {}
timeout: 20
description: null
bundled: null
author:
contact: Alex Gleason <alex@alexgleason.me>

View File

@ -18,7 +18,7 @@ export function useAuthor(pubkey: string | undefined) {
); );
if (!event) { if (!event) {
return {}; throw new Error('No event found');
} }
try { try {
@ -28,5 +28,6 @@ export function useAuthor(pubkey: string | undefined) {
return { event }; return { event };
} }
}, },
retry: 3,
}); });
} }

View File

@ -17,17 +17,10 @@ export function useLoggedInAccounts() {
const { data: authors = [] } = useQuery({ const { data: authors = [] } = useQuery({
queryKey: ['logins', logins.map((l) => l.id).join(';')], queryKey: ['logins', logins.map((l) => l.id).join(';')],
queryFn: async ({ signal }) => { queryFn: async ({ signal }) => {
let events: NostrEvent[] = []; const events = await nostr.query(
[{ kinds: [0], authors: logins.map((l) => l.pubkey) }],
try { { signal: AbortSignal.any([signal, AbortSignal.timeout(3000)]) },
events = await nostr.query( );
[{ kinds: [0], authors: logins.map((l) => l.pubkey) }],
{ signal: AbortSignal.any([signal, AbortSignal.timeout(3000)]) },
);
} catch (error) {
console.error('Error fetching accounts:', error);
return [];
}
return logins.map(({ id, pubkey }): Account => { return logins.map(({ id, pubkey }): Account => {
const event = events.find((e) => e.pubkey === pubkey); const event = events.find((e) => e.pubkey === pubkey);
@ -38,7 +31,8 @@ export function useLoggedInAccounts() {
return { id, pubkey, metadata: {}, event }; return { id, pubkey, metadata: {}, event };
} }
}); });
} },
retry: 3,
}); });
// Current user is the first login // Current user is the first login

View File

@ -23,7 +23,7 @@ export function useNostrPublish() {
tags: t.tags ?? [], tags: t.tags ?? [],
created_at: t.created_at ?? Math.floor(Date.now() / 1000), created_at: t.created_at ?? Math.floor(Date.now() / 1000),
}); });
nostr.event(event); await nostr.event(event, { signal: AbortSignal.timeout(5000) });
} else { } else {
throw new Error("User is not logged in"); throw new Error("User is not logged in");
} }

View File

@ -1,9 +1,9 @@
import { defineConfig } from "vite"; import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc"; import react from "@vitejs/plugin-react-swc";
import path from "path"; import path from "node:path";
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({ export default defineConfig(() => ({
server: { server: {
host: "::", host: "::",
port: 8080, port: 8080,