feat: bunch of work done here, got comments and edit and delete

This commit is contained in:
2026-02-04 13:00:16 -08:00
parent b6d66d34cb
commit 318f3bc500
19 changed files with 1868 additions and 117 deletions
+58
View File
@@ -166,6 +166,64 @@ interface Music {
5. **Privacy**: Any items you'd want to keep private even from public view?
## Current Sprint: Edit, Filters & Comments
### Feature 1: Edit Existing Library Entries (Admin Only)
**Backend:**
- Add PUT `/api/games/:id`, `/api/books/:id`, `/api/music/:id` endpoints
- Reuse existing admin authentication middleware
- Validate input against existing schemas
**Frontend:**
- Add edit button to entry cards (visible for admins)
- Reuse existing "Add" modal/form components with pre-filled data
- Update state after successful edit
### Feature 2: Fix Filter Tab State Updates
**Investigation needed:**
- Check how tab counts are calculated (likely not re-fetching after add)
- Ensure Angular state updates reactively when items are added/modified
- May need to refresh counts after mutations or use observables properly
### Feature 3: Comments System
**Database Schema:**
```prisma
model Comment {
id String @id @default(auto()) @map("_id") @db.ObjectId
content String // Markdown content - sanitised on render
userId String @db.ObjectId
user User @relation(fields: [userId], references: [id])
// Polymorphic relation - one of these will be set
gameId String? @db.ObjectId
game Game? @relation(fields: [gameId], references: [id])
bookId String? @db.ObjectId
book Book? @relation(fields: [bookId], references: [id])
musicId String? @db.ObjectId
music Music? @relation(fields: [musicId], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
```
**Backend:**
- POST `/api/games/:id/comments` (authenticated users)
- GET `/api/games/:id/comments` (public)
- DELETE `/api/games/:id/comments/:commentId` (admin only)
- Same for books and music
- Use a markdown sanitisation library (e.g., `sanitize-html` or `DOMPurify` on render)
**Frontend:**
- Expandable comments section on each entry card
- Markdown rendering with sanitisation (use `marked` + `DOMPurify`)
- Add comment form for authenticated users
- Delete button for admins
- Show commenter's Discord username/avatar
### Implementation Order
1. Fix filter tab bug (quick win)
2. Add edit functionality (builds on existing patterns)
3. Add comments system (new feature, more complex)
## Next Steps
1. Choose technical stack