chat
Gitea Actions Demo / Deploy (push) Successful in 36s

This commit is contained in:
vadim committed 2026-10-02 21:43:19 +03:00
1 parent cdd7147d8e
commit b80e88b121
9 files changed
+660 -12

No files matched your search

+72
View File
@@ -0,0 +1,72 @@
import { apiClient, toQuery } from '@/lib/api-client.ts'
import type { User } from '@/api/user.api.ts'
export interface CommentFile {
id: string
fileName: string
mimeType: string
size: number
uploaderId: string | null
createdAt: string
}
export interface Comment {
id: string
issueId: number
authorId: string | null
/** null — the author deleted their account */
author: User | null
/** null for a deleted comment */
content: string | null
attachments: CommentFile[]
editedAt: string | null
deletedAt: string | null
createdAt: string
updatedAt: string
}
export interface CommentsPage {
list: Comment[]
nextCursor: string | null
}
export interface CreateCommentInput {
content: string
fileIds?: string[]
}
export type UpdateCommentInput = CreateCommentInput
/** forward — newer than the cursor, backward — older than the cursor (no cursor: the latest page) */
export type CommentListDirection = 'forward' | 'backward'
export const COMMENT_EVENT_TYPES = ['comment.created', 'comment.updated', 'comment.deleted'] as const
export type CommentEventType = (typeof COMMENT_EVENT_TYPES)[number]
// CLIENT REQUEST
export async function itemsList(
issueId: number,
params: { limit?: number; cursor?: string | null; direction?: CommentListDirection } = {},
) {
const query = toQuery({ limit: params.limit, cursor: params.cursor, direction: params.direction })
return apiClient.get<CommentsPage>(`/api/issues/${issueId}/comments${query}`)
}
export async function itemCreate(issueId: number, input: CreateCommentInput) {
return apiClient.post<Comment>(`/api/issues/${issueId}/comments`, input)
}
export async function itemUpdate(id: string, input: UpdateCommentInput) {
return apiClient.patch<Comment>(`/api/comments/${id}`, input)
}
export async function itemDelete(id: string) {
await apiClient.delete(`/api/comments/${id}`)
return true
}
export function eventsUrl(issueId: number) {
return `${window.location.origin}/api/issues/${issueId}/comments/events`
}