Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | 2x 4x 4x 4x 4x 4x 4x 4x 2x 2x 2x 2x 2x 2x 2x 4x 4x 2x 2x 2x 2x 2x 1x 1x 2x 3x 2x 2x | import { apiGet, apiGetAuth, apiPostAuth } from '@/services/api';
import {
EventCommentsResponse,
CommentCollection,
EventComment,
CreateDiscussionCommentRequest,
UpsertReviewCommentRequest,
ListEventCommentsParams,
ListCommentRepliesParams,
} from '@/models/comment';
function buildCommentsPath(eventId: string, params: ListEventCommentsParams): string {
const p = new URLSearchParams();
if (params.discussion_limit != null) p.set('discussion_limit', String(params.discussion_limit));
if (params.discussion_cursor) p.set('discussion_cursor', params.discussion_cursor);
if (params.review_limit != null) p.set('review_limit', String(params.review_limit));
Iif (params.review_cursor) p.set('review_cursor', params.review_cursor);
const query = p.toString();
return query ? `/events/${eventId}/comments?${query}` : `/events/${eventId}/comments`;
}
function buildRepliesPath(eventId: string, commentId: string, params: ListCommentRepliesParams): string {
const p = new URLSearchParams();
if (params.limit != null) p.set('limit', String(params.limit));
if (params.cursor) p.set('cursor', params.cursor);
const query = p.toString();
const base = `/events/${eventId}/comments/${commentId}/replies`;
return query ? `${base}?${query}` : base;
}
export async function listEventComments(
eventId: string,
params: ListEventCommentsParams = {},
token?: string,
): Promise<EventCommentsResponse> {
const path = buildCommentsPath(eventId, params);
if (token) {
return apiGetAuth<EventCommentsResponse>(path, token);
}
return apiGet<EventCommentsResponse>(path);
}
export async function listCommentReplies(
eventId: string,
commentId: string,
params: ListCommentRepliesParams = {},
token?: string,
): Promise<CommentCollection> {
const path = buildRepliesPath(eventId, commentId, params);
if (token) {
return apiGetAuth<CommentCollection>(path, token);
}
return apiGet<CommentCollection>(path);
}
export async function createDiscussionComment(
eventId: string,
body: CreateDiscussionCommentRequest,
token: string,
): Promise<EventComment> {
return apiPostAuth<EventComment>(`/events/${eventId}/comments`, body, token);
}
export async function upsertReviewComment(
eventId: string,
body: UpsertReviewCommentRequest,
token: string,
): Promise<EventComment> {
return apiPostAuth<EventComment>(`/events/${eventId}/review-comments`, body, token);
}
|