refactor: use generateId() for id creation (#736)

This commit is contained in:
Jeremy 2025-01-28 18:51:04 +05:30 committed by GitHub
parent 085f4a8ac4
commit 2d47ffbd77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 20 additions and 75 deletions

View file

@ -4,7 +4,6 @@ import { useSWRConfig } from 'swr';
import { useCopyToClipboard } from 'usehooks-ts';
import type { Vote } from '@/lib/db/schema';
import { getMessageIdFromAnnotations } from '@/lib/utils';
import { CopyIcon, ThumbDownIcon, ThumbUpIcon } from './icons';
import { Button } from './ui/button';
@ -62,13 +61,11 @@ export function PureMessageActions({
disabled={vote?.isUpvoted}
variant="outline"
onClick={async () => {
const messageId = getMessageIdFromAnnotations(message);
const upvote = fetch('/api/vote', {
method: 'PATCH',
body: JSON.stringify({
chatId,
messageId,
messageId: message.id,
type: 'up',
}),
});
@ -116,13 +113,11 @@ export function PureMessageActions({
variant="outline"
disabled={vote && !vote.isUpvoted}
onClick={async () => {
const messageId = getMessageIdFromAnnotations(message);
const downvote = fetch('/api/vote', {
method: 'PATCH',
body: JSON.stringify({
chatId,
messageId,
messageId: message.id,
type: 'down',
}),
});