diff --git a/public/locales/da/main.json b/public/locales/da/main.json index 5cf471b..c36c233 100644 --- a/public/locales/da/main.json +++ b/public/locales/da/main.json @@ -33,5 +33,7 @@ "title": "Indlæg på ShareGPT", "warning": "Vær opmærksom på, at ved at poste din samtale på ShareGPT, vil den blive offentligt tilgængelig og synlig for alle. Når den er postet, kan samtalen ikke skjules eller slettes og kan blive arkiveret eller delt af andre. Vi råder dig til at overveje nøje og undgå at dele følsomme eller private oplysninger på denne platform." }, - "newFolder": "Ny mappe" + "newFolder": "Ny mappe", + "cloneChat": "Clone Chat", + "cloned": "Cloned" } diff --git a/public/locales/en/main.json b/public/locales/en/main.json index b115b2a..9109993 100644 --- a/public/locales/en/main.json +++ b/public/locales/en/main.json @@ -33,5 +33,7 @@ "title": "Post on ShareGPT", "warning": "Please be aware that by posting your conversation on ShareGPT, it will become publicly accessible and viewable to anyone. Once posted, the conversation cannot be hidden or deleted, and may be archived or shared by others. We advise you to consider carefully and avoid sharing sensitive or private information on this platform." }, - "newFolder": "New Folder" + "newFolder": "New Folder", + "cloneChat": "Clone Chat", + "cloned": "Cloned" } diff --git a/public/locales/es/main.json b/public/locales/es/main.json index e422732..0032916 100644 --- a/public/locales/es/main.json +++ b/public/locales/es/main.json @@ -33,5 +33,7 @@ "title": "Publicar en ShareGPT", "warning": "Por favor, tenga en cuenta que al publicar su conversación en ShareGPT, esta será accesible y visible para cualquiera. Una vez publicada, la conversación no se podrá ocultar ni eliminar, y puede ser archivada o compartida por otros. Le aconsejamos que lo considere detenidamente y evite compartir información sensible o privada en esta plataforma." }, - "newFolder": "Nueva Carpeta" + "newFolder": "Nueva Carpeta", + "cloneChat": "Clone Chat", + "cloned": "Cloned" } diff --git a/public/locales/fr/main.json b/public/locales/fr/main.json index c372f6c..1b161e0 100644 --- a/public/locales/fr/main.json +++ b/public/locales/fr/main.json @@ -33,5 +33,7 @@ "title": "Publier sur ShareGPT", "warning": "Veuillez noter que si vous publiez votre conversation sur ShareGPT, elle deviendra accessible au public et visible par tous. Une fois publiée, la conversation ne peut pas être cachée ou supprimée, et peut être archivée ou partagée par d'autres. Nous vous conseillons de considérer attentivement et d'éviter de partager des informations sensibles ou privées sur cette plateforme." }, - "newFolder": "Nouveau Dossier" + "newFolder": "Nouveau Dossier", + "cloneChat": "Clone Chat", + "cloned": "Cloned" } diff --git a/public/locales/ja/main.json b/public/locales/ja/main.json index 231c3ea..ad44dc8 100644 --- a/public/locales/ja/main.json +++ b/public/locales/ja/main.json @@ -33,5 +33,7 @@ "title": "ShareGPTに投稿", "warning": "ShareGPTに会話を投稿すると、誰でもアクセスして閲覧できるようになることに注意してください。一度投稿すると、会話は非表示にできず、削除もできません。また、他の人がアーカイブや共有する可能性があります。このプラットフォームで機密性のある情報や個人情報を共有しないように注意してください。" }, - "newFolder": "新しいフォルダー" + "newFolder": "新しいフォルダー", + "cloneChat": "Clone Chat", + "cloned": "Cloned" } diff --git a/public/locales/ms/main.json b/public/locales/ms/main.json index 38fe9a3..3e8ef87 100644 --- a/public/locales/ms/main.json +++ b/public/locales/ms/main.json @@ -33,5 +33,7 @@ "title": "Siarkan di ShareGPT", "warning": "Sila ambil perhatian bahawa dengan menyiarkan perbualan anda di ShareGPT, ia akan menjadi boleh diakses dan dilihat oleh sesiapa sahaja. Setelah disiarkan, perbualan tidak boleh disembunyikan atau dipadam, dan mungkin diarkibkan atau dikongsi oleh orang lain. Kami menasihatkan anda untuk mempertimbangkan dengan teliti dan mengelakkan berkongsi maklumat sensitif atau peribadi di platform ini." }, - "newFolder": "Folder Baru" + "newFolder": "Folder Baru", + "cloneChat": "Clone Chat", + "cloned": "Cloned" } diff --git a/public/locales/nb/main.json b/public/locales/nb/main.json index 01a3716..5b9a501 100644 --- a/public/locales/nb/main.json +++ b/public/locales/nb/main.json @@ -33,5 +33,7 @@ "title": "Innlegg på ShareGPT", "warning": "Vær oppmerksom på at ved å poste samtalen din på ShareGPT, vil den bli offentlig tilgjengelig og synlig for alle. Når den er postet, kan samtalen ikke skjules eller slettes, og den kan bli arkivert eller delt av andre. Vi anbefaler deg å tenke nøye gjennom og unngå å dele sensitiv eller privat informasjon på denne plattformen." }, - "newFolder": "Ny mappe" + "newFolder": "Ny mappe", + "cloneChat": "Clone Chat", + "cloned": "Cloned" } diff --git a/public/locales/sv/main.json b/public/locales/sv/main.json index e779684..071d571 100644 --- a/public/locales/sv/main.json +++ b/public/locales/sv/main.json @@ -33,5 +33,7 @@ "title": "Inlägg på ShareGPT", "warning": "Var medveten om att genom att posta din konversation på ShareGPT kommer den att bli offentligt tillgänglig och synlig för alla. När den väl är postad kan konversationen varken döljas eller raderas och kan arkiveras eller delas av andra. Vi rekommenderar dig att tänka noggrant igenom och undvika att dela känslig eller privat information på denna plattform." }, - "newFolder": "Ny mapp" + "newFolder": "Ny mapp", + "cloneChat": "Clone Chat", + "cloned": "Cloned" } diff --git a/public/locales/zh-CN/main.json b/public/locales/zh-CN/main.json index 686a607..f603917 100644 --- a/public/locales/zh-CN/main.json +++ b/public/locales/zh-CN/main.json @@ -33,5 +33,7 @@ "title": "发布至 ShareGPT", "warning": "请注意,把您的对话发布到 ShareGPT 后,任何人都可以公开访问和查看。发布后,对话不能被隐藏或删除,且可能被其他人存档或分享。建议您慎重考虑,在这个平台上避免分享敏感或私密信息。" }, - "newFolder": "新文件夹" + "newFolder": "新文件夹", + "cloneChat": "Clone Chat", + "cloned": "Cloned" } diff --git a/public/locales/zh-HK/main.json b/public/locales/zh-HK/main.json index 9c4bc10..f2a8ddc 100644 --- a/public/locales/zh-HK/main.json +++ b/public/locales/zh-HK/main.json @@ -33,5 +33,7 @@ "title": "po 上 ShareGPT", "warning": "請注意,你將呢個傾偈 po 上 ShareGPT 之後,佢會係公開嘅,所有人都可以見到你寫嘅嘢。一旦 po 咗,呢個傾偈將冇得被隱藏或刪除,亦都可能畀人存檔同分享。我哋建議你諗清楚,唔好喺嗰度分享敏感或私人資料。" }, - "newFolder": "新資料夾" + "newFolder": "新資料夾", + "cloneChat": "Clone Chat", + "cloned": "Cloned" } diff --git a/public/locales/zh-TW/main.json b/public/locales/zh-TW/main.json index 7bec774..92ee295 100644 --- a/public/locales/zh-TW/main.json +++ b/public/locales/zh-TW/main.json @@ -33,5 +33,7 @@ "title": "發佈至 ShareGPT", "warning": "請注意,將您的對話發佈至 ShareGPT 後,任何人都可以公開訪問和查看。一旦發佈,對話將無法隱藏或刪除,並且可能被他人存檔或分享。我們建議您慎重考慮,並避免在此平台上分享敏感或私人信息。" }, - "newFolder": "新資料夾" + "newFolder": "新資料夾", + "cloneChat": "Clone Chat", + "cloned": "Cloned" } diff --git a/src/assets/icons/CloneIcon.tsx b/src/assets/icons/CloneIcon.tsx new file mode 100644 index 0000000..62c0a17 --- /dev/null +++ b/src/assets/icons/CloneIcon.tsx @@ -0,0 +1,17 @@ +import React from 'react'; + +const CloneIcon = (props: React.SVGProps) => { + return ( + + + + ); +}; + +export default CloneIcon; diff --git a/src/components/Chat/ChatContent/ChatContent.tsx b/src/components/Chat/ChatContent/ChatContent.tsx index 5e194fe..7fad0a9 100644 --- a/src/components/Chat/ChatContent/ChatContent.tsx +++ b/src/components/Chat/ChatContent/ChatContent.tsx @@ -10,6 +10,7 @@ import CrossIcon from '@icon/CrossIcon'; import useSubmit from '@hooks/useSubmit'; import DownloadChat from './DownloadChat'; +import CloneChat from './CloneChat'; import ShareGPT from '@components/ShareGPT'; const ChatContent = () => { @@ -91,11 +92,12 @@ const ChatContent = () => { )} -
+
{useStore.getState().generating || ( <> + )}
diff --git a/src/components/Chat/ChatContent/CloneChat.tsx b/src/components/Chat/ChatContent/CloneChat.tsx new file mode 100644 index 0000000..36c199c --- /dev/null +++ b/src/components/Chat/ChatContent/CloneChat.tsx @@ -0,0 +1,59 @@ +import React, { useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import useStore from '@store/store'; + +import { ChatInterface } from '@type/chat'; + +import TickIcon from '@icon/TickIcon'; + +const CloneChat = React.memo(() => { + const { t } = useTranslation(); + + const setChats = useStore((state) => state.setChats); + const setCurrentChatIndex = useStore((state) => state.setCurrentChatIndex); + + const [cloned, setCloned] = useState(false); + + const cloneChat = () => { + const chats = useStore.getState().chats; + + if (chats) { + const index = useStore.getState().currentChatIndex; + let title = `Copy of ${chats[index].title}`; + let i = 0; + + while (chats.some((chat) => chat.title === title)) { + i += 1; + title = `Copy ${i} of ${chats[index].title}`; + } + + const clonedChat = JSON.parse(JSON.stringify(chats[index])); + clonedChat.title = title; + + const updatedChats: ChatInterface[] = JSON.parse(JSON.stringify(chats)); + updatedChats.unshift(clonedChat); + + setChats(updatedChats); + setCurrentChatIndex(useStore.getState().currentChatIndex + 1); + setCloned(true); + + window.setTimeout(() => { + setCloned(false); + }, 3000); + } + }; + + return ( + + ); +}); + +export default CloneChat;