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:
parent
8ae3299b3e
commit
792b06a2eb
@ -46,12 +46,16 @@ pub fn CommentList(
|
|||||||
rsx! {
|
rsx! {
|
||||||
div { class: "space-y-0 divide-y divide-gray-100 dark:divide-[#2a2a2a]",
|
div { class: "space-y-0 divide-y divide-gray-100 dark:divide-[#2a2a2a]",
|
||||||
for item in merged {
|
for item in merged {
|
||||||
|
let key_id = match &item {
|
||||||
|
MergedComment::Approved(c) => c.id,
|
||||||
|
MergedComment::Pending(c) => c.id,
|
||||||
|
};
|
||||||
match item {
|
match item {
|
||||||
MergedComment::Approved(comment) => rsx! {
|
MergedComment::Approved(comment) => rsx! {
|
||||||
CommentItem { comment, post_id }
|
CommentItem { key: "{key_id}", comment, post_id }
|
||||||
},
|
},
|
||||||
MergedComment::Pending(comment) => rsx! {
|
MergedComment::Pending(comment) => rsx! {
|
||||||
PendingCommentItem { comment, post_id }
|
PendingCommentItem { key: "{key_id}", comment, post_id }
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,8 +3,7 @@ use dioxus::prelude::*;
|
|||||||
use crate::hooks::comment_storage::{PendingComment, render_pending_content};
|
use crate::hooks::comment_storage::{PendingComment, render_pending_content};
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn PendingCommentItem(comment: PendingComment, post_id: i32) -> Element {
|
pub fn PendingCommentItem(comment: PendingComment, _post_id: i32) -> Element {
|
||||||
let _ = post_id;
|
|
||||||
|
|
||||||
let depth = if comment.parent_id.is_none() && comment.depth > 0 {
|
let depth = if comment.parent_id.is_none() && comment.depth > 0 {
|
||||||
0
|
0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user