Implement limited replies feature in NostrFeed component

- Introduced a mechanism to track posts that should display limited replies (only the first 2) instead of collapsing them entirely, enhancing user interaction with threaded discussions.
- Updated the ThreadedPost component to support toggling between limited and full replies, improving visibility and engagement with nested replies.
- Enhanced the FeedService to ensure proper filtering and handling of feed types, contributing to a more organized and user-friendly experience within the NostrFeed module.
This commit is contained in:
padreug 2025-09-20 16:31:13 +02:00
parent 872954d5ce
commit f0a6b2bd1d
4 changed files with 85 additions and 40 deletions

View file

@ -163,21 +163,26 @@ export class FeedService extends BaseService {
filters.push(filter)
}
} else {
// Use legacy feed types
// Handle default feed types (all, announcements, general, etc.)
const filter: Filter = {
kinds: [1], // Text notes by default
kinds: [1], // Text notes
limit: config.maxPosts || 50
}
// Handle legacy feed types
if (config.feedType === 'announcements') {
if (config.adminPubkeys && config.adminPubkeys.length > 0) {
filter.authors = config.adminPubkeys
} else {
// No admin pubkeys configured - fall back to all text posts
console.log('No admin pubkeys configured for announcements feed, showing all posts')
// filter.authors remains undefined, so all authors are included
}
// Apply feed-specific filtering
switch (config.feedType) {
case 'announcements':
if (config.adminPubkeys?.length) {
filter.authors = config.adminPubkeys
}
break
case 'general':
// General posts - no specific author filtering
break
case 'all':
default:
// All posts - no specific filtering
break
}
filters.push(filter)
@ -421,6 +426,8 @@ export class FeedService extends BaseService {
* Build threaded reply structure from flat posts
*/
buildThreadedPosts(posts: FeedPost[]): FeedPost[] {
console.log('FeedService.buildThreadedPosts: Input posts count:', posts.length)
// Create a map for quick lookup
const postMap = new Map<string, FeedPost>()
posts.forEach(post => {