Refactor Feed comment handling and pass trending tags to composer
cgen-06d108a1ce4a44ef9003101114454363
This commit is contained in:
parent
add0e3aee0
commit
54a50701a2
1 changed files with 9 additions and 28 deletions
|
|
@ -243,33 +243,11 @@ export default function Feed() {
|
|||
[toast, user?.id],
|
||||
);
|
||||
|
||||
const handleComment = useCallback(
|
||||
async (postId: string) => {
|
||||
if (!user?.id) {
|
||||
toast({ description: "Please sign in to comment." });
|
||||
return;
|
||||
}
|
||||
const content = prompt("Add a comment:")?.trim();
|
||||
if (!content) return;
|
||||
try {
|
||||
const created = await communityService.addComment(
|
||||
postId,
|
||||
user.id,
|
||||
content,
|
||||
);
|
||||
if (created) {
|
||||
setItems((prev) =>
|
||||
prev.map((it) =>
|
||||
it.id === postId ? { ...it, comments: it.comments + 1 } : it,
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("Comment failed", e);
|
||||
}
|
||||
},
|
||||
[toast, user?.id],
|
||||
);
|
||||
const handleComment = useCallback((postId: string) => {
|
||||
setItems((prev) =>
|
||||
prev.map((it) => (it.id === postId ? { ...it, comments: it.comments + 1 } : it)),
|
||||
);
|
||||
}, []);
|
||||
|
||||
const filteredItems = useMemo(() => {
|
||||
if (activeFilter === "following") {
|
||||
|
|
@ -472,7 +450,10 @@ export default function Feed() {
|
|||
Compose
|
||||
</Button>
|
||||
</div>
|
||||
<PostComposer onPosted={() => fetchFeed()} />
|
||||
<PostComposer
|
||||
onPosted={() => fetchFeed()}
|
||||
suggestedTags={trendingTopics.map((t) => t.topic.replace(/^#/, "")).slice(0, 8)}
|
||||
/>
|
||||
<div className="flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-border/30 bg-background/60 p-4 text-sm text-muted-foreground">
|
||||
<div className="flex items-center gap-2">
|
||||
<Sparkles className="h-4 w-4 text-aethex-300" />
|
||||
|
|
|
|||
Loading…
Reference in a new issue