diff --git a/client/src/components/Nav/ClearConvos.jsx b/client/src/components/Nav/ClearConvos.jsx deleted file mode 100644 index e9ad554346..0000000000 --- a/client/src/components/Nav/ClearConvos.jsx +++ /dev/null @@ -1,40 +0,0 @@ -import { useEffect } from 'react'; -import store from '~/store'; -import { Dialog } from '../ui/Dialog.tsx'; -import DialogTemplate from '../ui/DialogTemplate'; -import { useClearConversationsMutation } from '~/data-provider'; - -const ClearConvos = ({ open, onOpenChange}) => { - const { newConversation } = store.useConversation(); - const { refreshConversations } = store.useConversations(); - const clearConvosMutation = useClearConversationsMutation(); - - const clickHandler = () => { - console.log('Clearing conversations...'); - clearConvosMutation.mutate(); - }; - - useEffect(() => { - if (clearConvosMutation.isSuccess) { - newConversation(); - refreshConversations(); - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [clearConvosMutation.isSuccess]); - - return ( - - ); -}; - -export default ClearConvos; diff --git a/client/src/components/Nav/ClearConvos.tsx b/client/src/components/Nav/ClearConvos.tsx new file mode 100644 index 0000000000..da51542d63 --- /dev/null +++ b/client/src/components/Nav/ClearConvos.tsx @@ -0,0 +1,41 @@ +import { useState, useEffect, useCallback } from 'react'; +import { Dialog, DialogTemplate } from '../ui/'; +import { ClearChatsButton } from './SettingsTabs/'; +import { useClearConversationsMutation } from '~/data-provider'; +import store from '~/store'; + +const ClearConvos = ({ open, onOpenChange }) => { + const { newConversation } = store.useConversation(); + const { refreshConversations } = store.useConversations(); + const clearConvosMutation = useClearConversationsMutation(); + const [confirmClear, setConfirmClear] = useState(false); + + const clearConvos = useCallback(() => { + if (confirmClear) { + console.log('Clearing conversations...'); + clearConvosMutation.mutate({}); + setConfirmClear(false); + } else { + setConfirmClear(true); + } + }, [confirmClear, clearConvosMutation]); + + useEffect(() => { + if (clearConvosMutation.isSuccess) { + refreshConversations(); + newConversation(); + } + }, [clearConvosMutation.isSuccess, newConversation, refreshConversations]); + + return ( + + ); +}; + +export default ClearConvos; diff --git a/client/src/components/Nav/ExportConversation/ExportModel.jsx b/client/src/components/Nav/ExportConversation/ExportModel.jsx index 4ad69a6184..90fa687c28 100644 --- a/client/src/components/Nav/ExportConversation/ExportModel.jsx +++ b/client/src/components/Nav/ExportConversation/ExportModel.jsx @@ -3,12 +3,7 @@ import { useRecoilValue, useRecoilCallback } from 'recoil'; import filenamify from 'filenamify'; import exportFromJSON from 'export-from-json'; import download from 'downloadjs'; -import DialogTemplate from '~/components/ui/DialogTemplate.jsx'; -import { Dialog, DialogButton } from '~/components/ui/Dialog.tsx'; -import { Input } from '~/components/ui/Input.tsx'; -import { Label } from '~/components/ui/Label.tsx'; -import { Checkbox } from '~/components/ui/Checkbox.tsx'; -import Dropdown from '~/components/ui/Dropdown'; +import { Dialog, DialogButton, DialogTemplate, Input, Label, Checkbox, Dropdown } from '~/components/ui/'; import { cn } from '~/utils/'; import { useScreenshot } from '~/utils/screenshotContext'; diff --git a/client/src/components/Nav/SettingsTabs/General.tsx b/client/src/components/Nav/SettingsTabs/General.tsx index 456ea1e02e..f412596fd7 100644 --- a/client/src/components/Nav/SettingsTabs/General.tsx +++ b/client/src/components/Nav/SettingsTabs/General.tsx @@ -19,9 +19,9 @@ const ThemeSelector = ({ theme, onChange }: { theme: string, onChange: (value: s ); -const ClearChatsButton = ({ confirmClear, onClick }: { confirmClear: boolean, onClick: () => void }) => ( +export const ClearChatsButton = ({ confirmClear, showText = true, onClick }: { confirmClear: boolean, showText: boolean, onClick: () => void }) => (