refactor(auth): unify current user state usage across UI
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import { Heart } from "lucide-react"
|
||||
import { useState } from "react"
|
||||
import { currentUser } from "@/lib/mock"
|
||||
import { generateId } from "@/lib/id"
|
||||
import type { Comment } from "@/lib/types"
|
||||
import { useRequireAuth } from "@/lib/use-require-auth"
|
||||
import { useAuthStore } from "@/store/auth"
|
||||
@@ -32,14 +32,14 @@ export function PostComments({ initialComments, postId }: PostCommentsProps) {
|
||||
requireAuth(() => {
|
||||
const nextContent = content.trim()
|
||||
if (!nextContent) return
|
||||
const author = user ?? currentUser
|
||||
if (!user) return
|
||||
const createdAt = new Date().toISOString()
|
||||
setComments((prev) => [
|
||||
...prev,
|
||||
{
|
||||
id: `comment-${postId}-${createdAt}`,
|
||||
id: generateId(`comment-${postId}`),
|
||||
postId,
|
||||
author,
|
||||
author: user,
|
||||
content: nextContent,
|
||||
likeCount: 0,
|
||||
liked: false,
|
||||
|
||||
Reference in New Issue
Block a user