fix comments on activities page.

This commit is contained in:
2025-07-04 16:16:39 +08:00
parent 549c2d48d6
commit 793d78e1b1
4 changed files with 13 additions and 18 deletions

View File

@@ -269,7 +269,7 @@ function DeleteCommentDialog({
);
}
function CommentContent({ content }: { content: string }) {
export function CommentContent({ content }: { content: string }) {
const lines = content.split("\n");
for (let i = 0; i < lines.length; i++) {
let line = lines[i];

View File

@@ -232,6 +232,7 @@ export const i18nData = {
"Write down your comment": "Write down your comment",
"Click to view more": "Click to view more",
"Comment Details": "Comment Details",
"Posted a comment": "Posted a comment",
},
},
"zh-CN": {
@@ -456,6 +457,7 @@ export const i18nData = {
"Write down your comment": "写下您的评论",
"Click to view more": "点击查看更多",
"Comment Details": "评论详情",
"Posted a comment": "发布了一个评论",
},
},
"zh-TW": {
@@ -680,6 +682,7 @@ export const i18nData = {
"Write down your comment": "寫下您的評論",
"Click to view more": "點擊查看更多",
"Comment Details": "評論詳情",
"Posted a comment": "發布了評論",
},
},
};

View File

@@ -171,7 +171,7 @@ export enum ActivityType {
Unknown = 0,
ResourcePublished = 1,
ResourceUpdated = 2,
ResourceCommented = 3,
NewComment = 3,
}
export interface Activity {
@@ -181,5 +181,5 @@ export interface Activity {
created_at: string;
resource?: Resource;
user?: User;
comment?: CommentWithResource;
comment?: Comment;
}

View File

@@ -7,6 +7,7 @@ import { MdArrowRight } from "react-icons/md";
import { useNavigate } from "react-router";
import Loading from "../components/loading.tsx";
import { ImageGrid } from "../components/image.tsx";
import { CommentContent } from "../components/comment_tile.tsx";
export default function ActivitiesPage() {
const [activities, setActivities] = useState<Activity[]>([]);
@@ -67,7 +68,7 @@ function ActivityCard({ activity }: { activity: Activity }) {
"Unknown activity",
t("Published a resource"),
t("Updated a resource"),
t("Commented on a resource"),
t("Posted a comment"),
];
const navigate = useNavigate();
@@ -92,19 +93,10 @@ function ActivityCard({ activity }: { activity: Activity }) {
)}
</div>
);
} else if (activity.type === ActivityType.ResourceCommented) {
} else if (activity.type === ActivityType.NewComment) {
content = (
<div className={"mt-2"}>
<div className={"text-sm mx-1 whitespace-pre-wrap"}>
{activity.comment?.content}
</div>
<ImageGrid images={activity.comment?.images ?? []} />
<div className={"flex items-center mt-1"}>
<MdArrowRight />
<span className={"text-sm text-base-content/80"}>
{activity.comment?.resource?.title}
</span>
</div>
<div className="comment_tile">
<CommentContent content={activity.comment!.content} />
</div>
);
}
@@ -120,8 +112,8 @@ function ActivityCard({ activity }: { activity: Activity }) {
activity.type === ActivityType.ResourceUpdated
) {
navigate(`/resources/${activity.resource?.id}`);
} else if (activity.type === ActivityType.ResourceCommented) {
navigate(`/resources/${activity.comment?.resource.id}#comments`);
} else if (activity.type === ActivityType.NewComment) {
navigate(`/comments/${activity.comment?.id}`);
}
}}
>