diff --git a/src/components/SettingsMenu/SettingsMenu.tsx b/src/components/SettingsMenu/SettingsMenu.tsx index b4431dbe2..a287fa70e 100644 --- a/src/components/SettingsMenu/SettingsMenu.tsx +++ b/src/components/SettingsMenu/SettingsMenu.tsx @@ -16,6 +16,7 @@ import ChatConfigMenu from '@components/ChatConfigMenu'; import EnterToSubmitToggle from './EnterToSubmitToggle'; import TotalTokenCost, { TotalTokenCostToggle } from './TotalTokenCost'; import ClearConversation from '@components/Menu/MenuOptions/ClearConversation'; +import ShareGPTToggle from './ShareGPTToggle'; const SettingsMenu = () => { const { t } = useTranslation(); @@ -51,6 +52,7 @@ const SettingsMenu = () => { + diff --git a/src/components/SettingsMenu/ShareGPTToggle.tsx b/src/components/SettingsMenu/ShareGPTToggle.tsx new file mode 100644 index 000000000..cfbd92202 --- /dev/null +++ b/src/components/SettingsMenu/ShareGPTToggle.tsx @@ -0,0 +1,28 @@ +import React, { useEffect, useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import useStore from '@store/store'; +import Toggle from '@components/Toggle'; + +const ShareGPTToggle = () => { + const { t } = useTranslation(); + + const setShareGPT = useStore((state) => state.setShareGPT); + + const [isChecked, setIsChecked] = useState( + useStore.getState().shareGPT + ); + + useEffect(() => { + setShareGPT(isChecked); + }, [isChecked]); + + return ( + + ); +}; + +export default ShareGPTToggle; diff --git a/src/components/ShareGPT/ShareGPT.tsx b/src/components/ShareGPT/ShareGPT.tsx index f9b4cc8ce..f300a95e8 100644 --- a/src/components/ShareGPT/ShareGPT.tsx +++ b/src/components/ShareGPT/ShareGPT.tsx @@ -9,6 +9,7 @@ import { ShareGPTSubmitBodyInterface } from '@type/api'; const ShareGPT = React.memo(() => { const { t } = useTranslation(); const [isModalOpen, setIsModalOpen] = useState(false); + const isAvailable = useStore((state) => state.shareGPT); const handleConfirm = async () => { const chats = useStore.getState().chats; @@ -40,7 +41,7 @@ const ShareGPT = React.memo(() => { return ( <> - + ) } {isModalOpen && ( void; setTheme: (theme: Theme) => void; setAutoTitle: (autoTitle: boolean) => void; + setShareGPT: (autoTitle: boolean) => void; setAdvancedMode: (advancedMode: boolean) => void; setDefaultChatConfig: (defaultChatConfig: ConfigInterface) => void; setDefaultSystemMessage: (defaultSystemMessage: string) => void; @@ -38,6 +40,7 @@ export const createConfigSlice: StoreSlice = (set, get) => ({ hideMenuOptions: false, hideSideMenu: false, autoTitle: false, + shareGPT: false, enterToSubmit: true, advancedMode: true, defaultChatConfig: _defaultChatConfig, @@ -64,6 +67,12 @@ export const createConfigSlice: StoreSlice = (set, get) => ({ autoTitle: autoTitle, })); }, + setShareGPT: (shareGPT: boolean) => { + set((prev: ConfigSlice) => ({ + ...prev, + shareGPT: shareGPT, + })); + }, setAdvancedMode: (advancedMode: boolean) => { set((prev: ConfigSlice) => ({ ...prev, diff --git a/src/store/store.ts b/src/store/store.ts index 69aba7de0..c29c49077 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -46,6 +46,7 @@ export const createPartializedState = (state: StoreState) => ({ apiEndpoint: state.apiEndpoint, theme: state.theme, autoTitle: state.autoTitle, + shareGPT: state.shareGPT, advancedMode: state.advancedMode, prompts: state.prompts, defaultChatConfig: state.defaultChatConfig,