소스 검색

fix: add fallback for when crypto.randomUUID is unavailable

Closes #11452

Co-authored-by: Yo'av Moshe <[email protected]>
Adam 2 달 전
부모
커밋
dd2d232a9d
2개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      packages/app/src/components/prompt-input/attachments.ts
  2. 1 1
      packages/app/src/context/comments.tsx

+ 1 - 1
packages/app/src/components/prompt-input/attachments.ts

@@ -31,7 +31,7 @@ export function createPromptAttachments(input: PromptAttachmentsInput) {
       const dataUrl = reader.result as string
       const attachment: ImageAttachmentPart = {
         type: "image",
-        id: crypto.randomUUID(),
+        id: crypto.randomUUID?.() ?? Math.random().toString(16).slice(2),
         filename: file.name,
         mime: file.type,
         dataUrl,

+ 1 - 1
packages/app/src/context/comments.tsx

@@ -53,7 +53,7 @@ function createCommentSessionState(store: Store<CommentStore>, setStore: SetStor
 
   const add = (input: Omit<LineComment, "id" | "time">) => {
     const next: LineComment = {
-      id: crypto.randomUUID(),
+      id: crypto.randomUUID?.() ?? Math.random().toString(16).slice(2),
       time: Date.now(),
       ...input,
     }