refactor: use generateId() for id creation (#736)
This commit is contained in:
parent
085f4a8ac4
commit
2d47ffbd77
8 changed files with 20 additions and 75 deletions
|
|
@ -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',
|
||||
}),
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue