mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 04:17:23 +00:00
fix comments on activities page.
This commit is contained in:
@@ -269,7 +269,7 @@ function DeleteCommentDialog({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function CommentContent({ content }: { content: string }) {
|
export function CommentContent({ content }: { content: string }) {
|
||||||
const lines = content.split("\n");
|
const lines = content.split("\n");
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
let line = lines[i];
|
let line = lines[i];
|
||||||
|
@@ -232,6 +232,7 @@ export const i18nData = {
|
|||||||
"Write down your comment": "Write down your comment",
|
"Write down your comment": "Write down your comment",
|
||||||
"Click to view more": "Click to view more",
|
"Click to view more": "Click to view more",
|
||||||
"Comment Details": "Comment Details",
|
"Comment Details": "Comment Details",
|
||||||
|
"Posted a comment": "Posted a comment",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"zh-CN": {
|
"zh-CN": {
|
||||||
@@ -456,6 +457,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": "发布了一个评论",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"zh-TW": {
|
"zh-TW": {
|
||||||
@@ -680,6 +682,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": "發布了評論",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@@ -171,7 +171,7 @@ export enum ActivityType {
|
|||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
ResourcePublished = 1,
|
ResourcePublished = 1,
|
||||||
ResourceUpdated = 2,
|
ResourceUpdated = 2,
|
||||||
ResourceCommented = 3,
|
NewComment = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Activity {
|
export interface Activity {
|
||||||
@@ -181,5 +181,5 @@ export interface Activity {
|
|||||||
created_at: string;
|
created_at: string;
|
||||||
resource?: Resource;
|
resource?: Resource;
|
||||||
user?: User;
|
user?: User;
|
||||||
comment?: CommentWithResource;
|
comment?: Comment;
|
||||||
}
|
}
|
||||||
|
@@ -7,6 +7,7 @@ import { MdArrowRight } from "react-icons/md";
|
|||||||
import { useNavigate } from "react-router";
|
import { useNavigate } from "react-router";
|
||||||
import Loading from "../components/loading.tsx";
|
import Loading from "../components/loading.tsx";
|
||||||
import { ImageGrid } from "../components/image.tsx";
|
import { ImageGrid } from "../components/image.tsx";
|
||||||
|
import { CommentContent } from "../components/comment_tile.tsx";
|
||||||
|
|
||||||
export default function ActivitiesPage() {
|
export default function ActivitiesPage() {
|
||||||
const [activities, setActivities] = useState<Activity[]>([]);
|
const [activities, setActivities] = useState<Activity[]>([]);
|
||||||
@@ -67,7 +68,7 @@ function ActivityCard({ activity }: { activity: Activity }) {
|
|||||||
"Unknown activity",
|
"Unknown activity",
|
||||||
t("Published a resource"),
|
t("Published a resource"),
|
||||||
t("Updated a resource"),
|
t("Updated a resource"),
|
||||||
t("Commented on a resource"),
|
t("Posted a comment"),
|
||||||
];
|
];
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -92,19 +93,10 @@ function ActivityCard({ activity }: { activity: Activity }) {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else if (activity.type === ActivityType.ResourceCommented) {
|
} else if (activity.type === ActivityType.NewComment) {
|
||||||
content = (
|
content = (
|
||||||
<div className={"mt-2"}>
|
<div className="comment_tile">
|
||||||
<div className={"text-sm mx-1 whitespace-pre-wrap"}>
|
<CommentContent content={activity.comment!.content} />
|
||||||
{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>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -120,8 +112,8 @@ function ActivityCard({ activity }: { activity: Activity }) {
|
|||||||
activity.type === ActivityType.ResourceUpdated
|
activity.type === ActivityType.ResourceUpdated
|
||||||
) {
|
) {
|
||||||
navigate(`/resources/${activity.resource?.id}`);
|
navigate(`/resources/${activity.resource?.id}`);
|
||||||
} else if (activity.type === ActivityType.ResourceCommented) {
|
} else if (activity.type === ActivityType.NewComment) {
|
||||||
navigate(`/resources/${activity.comment?.resource.id}#comments`);
|
navigate(`/comments/${activity.comment?.id}`);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
Reference in New Issue
Block a user