mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-06 16:24:17 +00:00
fix(ui): optimize comment polling and remove unused comments endpoint
This commit is contained in:
@@ -40,7 +40,6 @@ describe('file api', () => {
|
|||||||
vi.spyOn(assetService, 'deleteAssets').mockImplementation(vi.fn())
|
vi.spyOn(assetService, 'deleteAssets').mockImplementation(vi.fn())
|
||||||
vi.spyOn(assetService, 'createComment').mockImplementation(vi.fn())
|
vi.spyOn(assetService, 'createComment').mockImplementation(vi.fn())
|
||||||
vi.spyOn(assetService, 'listComments').mockImplementation(vi.fn())
|
vi.spyOn(assetService, 'listComments').mockImplementation(vi.fn())
|
||||||
vi.spyOn(assetService, 'getComment').mockImplementation(vi.fn())
|
|
||||||
vi.spyOn(assetService, 'restoreAssets').mockImplementation(vi.fn())
|
vi.spyOn(assetService, 'restoreAssets').mockImplementation(vi.fn())
|
||||||
vi.spyOn(metadataService, 'updateAssetMetadata').mockImplementation(vi.fn())
|
vi.spyOn(metadataService, 'updateAssetMetadata').mockImplementation(vi.fn())
|
||||||
vi.spyOn(notificationService, 'create').mockImplementation(vi.fn())
|
vi.spyOn(notificationService, 'create').mockImplementation(vi.fn())
|
||||||
|
|||||||
@@ -183,20 +183,6 @@ const route = new Hono<{ Variables: { user: User } }>()
|
|||||||
const comments = await assetService.listComments(fileId, req)
|
const comments = await assetService.listComments(fileId, req)
|
||||||
return c.json(comments)
|
return c.json(comments)
|
||||||
})
|
})
|
||||||
.get('/comments/:commentId', async (c) => {
|
|
||||||
const commentId = c.req.param('commentId')
|
|
||||||
const user = c.get('user')
|
|
||||||
|
|
||||||
await authzService.hasPermission({
|
|
||||||
user,
|
|
||||||
permission: Permission.Read,
|
|
||||||
type: ResourceType.Comment,
|
|
||||||
id: commentId,
|
|
||||||
})
|
|
||||||
|
|
||||||
const comment = await assetService.getComment(commentId)
|
|
||||||
return c.json(comment)
|
|
||||||
})
|
|
||||||
.post('/files/restore', zValidator('json', restoreFilesRequestSchema), async (c) => {
|
.post('/files/restore', zValidator('json', restoreFilesRequestSchema), async (c) => {
|
||||||
const user = c.get('user')
|
const user = c.get('user')
|
||||||
const req = c.req.valid('json')
|
const req = c.req.valid('json')
|
||||||
|
|||||||
@@ -57,31 +57,7 @@ export const MessageCard: React.FC<MessageCardProps> = ({
|
|||||||
onSelect,
|
onSelect,
|
||||||
frameRate,
|
frameRate,
|
||||||
}) => {
|
}) => {
|
||||||
const isRunning =
|
const message = initialMessage
|
||||||
!!initialMessage.sessionId &&
|
|
||||||
!!initialMessage.message &&
|
|
||||||
initialMessage.message in AI_PLACEHOLDERS
|
|
||||||
|
|
||||||
const { data: polledMessage } = useQuery({
|
|
||||||
queryKey: ['comments', initialMessage.id],
|
|
||||||
queryFn: async () => {
|
|
||||||
const res = await client.api.comments[':commentId'].$get({
|
|
||||||
param: { commentId: initialMessage.id! },
|
|
||||||
})
|
|
||||||
if (!res.ok) throw new Error('Failed to fetch comment')
|
|
||||||
return (await res.json()) as CommentInfo
|
|
||||||
},
|
|
||||||
enabled: !!teamId && isRunning,
|
|
||||||
refetchInterval: (query) => {
|
|
||||||
const data = query.state.data as CommentInfo
|
|
||||||
if (data && (!data.message || !(data.message in AI_PLACEHOLDERS))) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return 2000
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const message = polledMessage || initialMessage
|
|
||||||
const hasDrawInfo =
|
const hasDrawInfo =
|
||||||
!!message.annotations && Array.isArray(message.annotations) && message.annotations.length > 0
|
!!message.annotations && Array.isArray(message.annotations) && message.annotations.length > 0
|
||||||
const creator = message.creator
|
const creator = message.creator
|
||||||
|
|||||||
Reference in New Issue
Block a user