fix(comments): address code quality issues in list and pending_item

- Add key prop to CommentList for loop for Dioxus list diffing
- Rename post_id to _post_id in PendingCommentItem signature
- Remove unnecessary let _ = post_id suppression
This commit is contained in:
xfy 2026-06-11 14:42:03 +08:00
parent 8ae3299b3e
commit 792b06a2eb
2 changed files with 7 additions and 4 deletions

View File

@ -46,12 +46,16 @@ pub fn CommentList(
rsx! {
div { class: "space-y-0 divide-y divide-gray-100 dark:divide-[#2a2a2a]",
for item in merged {
let key_id = match &item {
MergedComment::Approved(c) => c.id,
MergedComment::Pending(c) => c.id,
};
match item {
MergedComment::Approved(comment) => rsx! {
CommentItem { comment, post_id }
CommentItem { key: "{key_id}", comment, post_id }
},
MergedComment::Pending(comment) => rsx! {
PendingCommentItem { comment, post_id }
PendingCommentItem { key: "{key_id}", comment, post_id }
},
}
}

View File

@ -3,8 +3,7 @@ use dioxus::prelude::*;
use crate::hooks::comment_storage::{PendingComment, render_pending_content};
#[component]
pub fn PendingCommentItem(comment: PendingComment, post_id: i32) -> Element {
let _ = post_id;
pub fn PendingCommentItem(comment: PendingComment, _post_id: i32) -> Element {
let depth = if comment.parent_id.is_none() && comment.depth > 0 {
0