|
|
|
|
@ -397,9 +397,79 @@
@@ -397,9 +397,79 @@
|
|
|
|
|
replyingTo = replyEvent; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function handleCommentPublished() { |
|
|
|
|
async function handleCommentPublished() { |
|
|
|
|
replyingTo = null; |
|
|
|
|
loadComments(); |
|
|
|
|
// Wait a short delay to allow the comment to propagate to relays |
|
|
|
|
await new Promise(resolve => setTimeout(resolve, 1500)); |
|
|
|
|
// Reload comments without using cache to ensure we get the new comment |
|
|
|
|
await loadCommentsFresh(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function loadCommentsFresh() { |
|
|
|
|
if (!threadId) { |
|
|
|
|
loading = false; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
loading = true; |
|
|
|
|
try { |
|
|
|
|
// Use all relay sources: profileRelays + defaultRelays + user's inboxes + user's localrelays |
|
|
|
|
const allRelays = relayManager.getProfileReadRelays(); |
|
|
|
|
|
|
|
|
|
const replyFilters: any[] = []; |
|
|
|
|
|
|
|
|
|
// Always fetch kind 1111 comments - check both e and E tags, and a and A tags |
|
|
|
|
replyFilters.push( |
|
|
|
|
{ kinds: [1111], '#e': [threadId] }, // Lowercase e tag |
|
|
|
|
{ kinds: [1111], '#E': [threadId] }, // Uppercase E tag (NIP-22) |
|
|
|
|
{ kinds: [1111], '#a': [threadId] }, // Lowercase a tag (some clients use wrong tags) |
|
|
|
|
{ kinds: [1111], '#A': [threadId] } // Uppercase A tag (NIP-22 for addressable events) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// For kind 1 events, fetch kind 1 replies |
|
|
|
|
// Also fetch kind 1 replies for any event (some apps use kind 1 for everything) |
|
|
|
|
replyFilters.push({ kinds: [1], '#e': [threadId] }); |
|
|
|
|
|
|
|
|
|
// Fetch yak backs (kind 1244) - voice replies |
|
|
|
|
replyFilters.push({ kinds: [1244], '#e': [threadId] }); |
|
|
|
|
|
|
|
|
|
// Fetch zap receipts (kind 9735) |
|
|
|
|
replyFilters.push({ kinds: [9735], '#e': [threadId] }); |
|
|
|
|
|
|
|
|
|
console.log('CommentThread: Reloading comments after publish for threadId:', threadId); |
|
|
|
|
|
|
|
|
|
// Don't use cache when reloading after publishing - we want fresh data |
|
|
|
|
const allReplies = await nostrClient.fetchEvents( |
|
|
|
|
replyFilters, |
|
|
|
|
allRelays, |
|
|
|
|
{ useCache: false, cacheResults: true, timeout: 10000 } |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
console.log('CommentThread: Fetched', allReplies.length, 'replies (fresh)'); |
|
|
|
|
|
|
|
|
|
// Filter to only replies that reference the root |
|
|
|
|
const rootReplies = allReplies.filter(reply => referencesRoot(reply)); |
|
|
|
|
|
|
|
|
|
console.log('CommentThread: Root replies:', rootReplies.length); |
|
|
|
|
|
|
|
|
|
// Separate by type |
|
|
|
|
comments = rootReplies.filter(e => e.kind === 1111); |
|
|
|
|
kind1Replies = rootReplies.filter(e => e.kind === 1); |
|
|
|
|
yakBacks = rootReplies.filter(e => e.kind === 1244); |
|
|
|
|
zapReceipts = rootReplies.filter(e => e.kind === 9735); |
|
|
|
|
|
|
|
|
|
console.log('CommentThread: Separated - comments:', comments.length, 'kind1Replies:', kind1Replies.length, 'yakBacks:', yakBacks.length, 'zapReceipts:', zapReceipts.length); |
|
|
|
|
|
|
|
|
|
// Recursively fetch all nested replies (non-blocking - let it run in background) |
|
|
|
|
fetchNestedReplies().catch((error) => { |
|
|
|
|
console.error('Error fetching nested replies:', error); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
console.error('Error reloading comments:', error); |
|
|
|
|
} finally { |
|
|
|
|
loading = false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -448,7 +518,7 @@
@@ -448,7 +518,7 @@
|
|
|
|
|
comment={item.event} |
|
|
|
|
parentEvent={parent} |
|
|
|
|
onReply={handleReply} |
|
|
|
|
rootEventKind={rootKind} |
|
|
|
|
rootEventKind={rootKind ?? undefined} |
|
|
|
|
/> |
|
|
|
|
{:else if item.type === 'reply'} |
|
|
|
|
<!-- Kind 1 reply - render as FeedPost --> |
|
|
|
|
|