diff --git a/src/components/VersionHint.tsx b/src/components/VersionHint.tsx index 1421ab2..3844e59 100644 --- a/src/components/VersionHint.tsx +++ b/src/components/VersionHint.tsx @@ -1,8 +1,13 @@ import { ChatStore } from "@/types/chatstore"; import { Tr } from "@/translate"; +import { useContext } from "react"; +import { AppContext } from "@/pages/App"; -const VersionHint = (props: { chatStore: ChatStore }) => { - const { chatStore } = props; +const VersionHint = () => { + const ctx = useContext(AppContext); + if (!ctx) return
error
; + + const { chatStore } = ctx; return ( <> {chatStore.chatgpt_api_web_version < "v1.3.0" && ( diff --git a/src/components/WhisperButton.tsx b/src/components/WhisperButton.tsx index e002214..9029907 100644 --- a/src/components/WhisperButton.tsx +++ b/src/components/WhisperButton.tsx @@ -1,4 +1,4 @@ -import { createRef } from "react"; +import { createRef, useContext } from "react"; import { ChatStore } from "@/types/chatstore"; import { useEffect, useState, Dispatch } from "react"; @@ -10,13 +10,17 @@ import { MicIcon, VoicemailIcon, } from "lucide-react"; +import { AppContext } from "@/pages/App"; const WhisperButton = (props: { - chatStore: ChatStore; inputMsg: string; setInputMsg: Dispatch; }) => { - const { chatStore, inputMsg, setInputMsg } = props; + const ctx = useContext(AppContext); + if (!ctx) return
error
; + const { chatStore } = ctx; + + const { inputMsg, setInputMsg } = props; const mediaRef = createRef(); const [isRecording, setIsRecording] = useState("Mic"); return ( diff --git a/src/editMessage.tsx b/src/editMessage.tsx index 170d572..a06fda9 100644 --- a/src/editMessage.tsx +++ b/src/editMessage.tsx @@ -1,4 +1,4 @@ -import { useState, useEffect, Dispatch } from "react"; +import { useState, useEffect, Dispatch, useContext } from "react"; import { Tr, langCodeContext, LANG_OPTIONS, tr } from "@/translate"; import { ChatStore, ChatStoreMessage } from "@/types/chatstore"; import { EditMessageString } from "@/editMessageString"; @@ -13,16 +13,18 @@ import { DialogTrigger, } from "@/components/ui/dialog"; import { Button } from "./components/ui/button"; +import { AppContext } from "./pages/App"; interface EditMessageProps { chat: ChatStoreMessage; - chatStore: ChatStore; showEdit: boolean; setShowEdit: Dispatch; - setChatStore: (cs: ChatStore) => void; } export function EditMessage(props: EditMessageProps) { - const { showEdit, setShowEdit, chat, setChatStore, chatStore } = props; + const ctx = useContext(AppContext); + if (!ctx) return
error
; + + const { showEdit, setShowEdit, chat } = props; return ( @@ -37,21 +39,11 @@ export function EditMessage(props: EditMessageProps) { {typeof chat.content === "string" ? ( - + ) : ( - + )} - {chatStore.develop_mode && ( + {ctx.chatStore.develop_mode && (