feat: implement real-time updates for showcase ratings and comments

- Add automatic cache invalidation in useNostrPublish hook
- Implement optimistic updates for comments with error recovery
- Add instant visual feedback for ratings with rollback on error
- Enhance moderation actions with immediate UI updates
- Reduce stale times and refetch intervals for faster updates
- Add loading states and visual indicators during submissions
- Create comprehensive error handling with graceful degradation
- Add RealTimeDemo component for testing real-time features
- Update background polling for better real-time synchronization

Users no longer need to refresh pages to see their updates.
All actions (comments, ratings, moderation) now feel instant
while maintaining data consistency and error recovery.
This commit is contained in:
Mary Kate Fain committed 2025-11-14 10:50:04 -06:00
1 parent 6f2ccb0b5a
commit e709dca735
9 files changed
+552 -24

No files matched your search

+9 -6
View File
@@ -19,9 +19,9 @@ interface CommentFormProps {
export function CommentForm({
root,
reply,
onSuccess,
onSuccess,
placeholder = "Write a comment...",
compact = false
compact = false
}: CommentFormProps) {
const [content, setContent] = useState('');
const { user } = useCurrentUser();
@@ -29,7 +29,7 @@ export function CommentForm({
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
if (!content.trim() || !user) return;
postComment(
@@ -72,10 +72,13 @@ export function CommentForm({
/>
<div className="flex justify-between items-center">
<span className="text-sm text-muted-foreground">
{reply ? 'Replying to comment' : 'Adding to the discussion'}
{isPending
? (reply ? 'Posting reply...' : 'Posting comment...')
: (reply ? 'Replying to comment' : 'Adding to the discussion')
}
</span>
<Button
type="submit"
<Button
type="submit"
disabled={!content.trim() || isPending}
size={compact ? "sm" : "default"}
>