mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Improve Comment model to support multiple comment type.
This commit is contained in:
@@ -571,13 +571,13 @@ class Network {
|
||||
return `${this.apiBaseUrl}/files/download/${fileId}?cf_token=${cfToken}`;
|
||||
}
|
||||
|
||||
async createComment(
|
||||
async createResourceComment(
|
||||
resourceID: number,
|
||||
content: string,
|
||||
images: number[],
|
||||
): Promise<Response<any>> {
|
||||
return this._callApi(() =>
|
||||
axios.post(`${this.apiBaseUrl}/comments/${resourceID}`, {
|
||||
axios.post(`${this.apiBaseUrl}/comments/resource/${resourceID}`, {
|
||||
content,
|
||||
images,
|
||||
}),
|
||||
@@ -597,12 +597,12 @@ class Network {
|
||||
);
|
||||
}
|
||||
|
||||
async listComments(
|
||||
async listResourceComments(
|
||||
resourceID: number,
|
||||
page: number = 1,
|
||||
): Promise<PageResponse<Comment>> {
|
||||
return this._callApi(() =>
|
||||
axios.get(`${this.apiBaseUrl}/comments/${resourceID}`, {
|
||||
axios.get(`${this.apiBaseUrl}/comments/resource/${resourceID}`, {
|
||||
params: { page },
|
||||
}),
|
||||
);
|
||||
|
@@ -1221,7 +1221,7 @@ function CommentInput({
|
||||
return;
|
||||
}
|
||||
}
|
||||
const res = await network.createComment(
|
||||
const res = await network.createResourceComment(
|
||||
resourceId,
|
||||
commentContent,
|
||||
imageIds,
|
||||
@@ -1339,7 +1339,7 @@ function CommentsList({
|
||||
const [comments, setComments] = useState<Comment[] | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
network.listComments(resourceId, page).then((res) => {
|
||||
network.listResourceComments(resourceId, page).then((res) => {
|
||||
if (res.success) {
|
||||
setComments(res.data!);
|
||||
maxPageCallback(res.totalPages || 1);
|
||||
|
Reference in New Issue
Block a user