import { useCallback } from 'react' import { Button } from '@janhq/joi' import { useAtomValue, useSetAtom } from 'jotai' import { showMigrationModalAtom } from '@/containers/Providers/ModalMigrations' import { toaster } from '@/containers/Toast' import useThreads from '@/hooks/useThreads' import { threadsAtom } from '@/helpers/atoms/Thread.atom' const DataMigration: React.FC = () => { const setShowMigrationModal = useSetAtom(showMigrationModalAtom) const threads = useAtomValue(threadsAtom) const { deleteThread } = useThreads() const onStartMigrationClick = useCallback(() => { setShowMigrationModal(true) }, [setShowMigrationModal]) const onCleanUpDataClick = useCallback(async () => { for (const thread of threads) { try { await deleteThread(thread.id) } catch (err) { console.error('Error deleting thread', err) toaster({ title: 'Delete thread failed', description: `Failed to delete thread ${thread.title}`, type: 'error', }) } } toaster({ title: 'Delete thread successfully!', type: 'success', }) }, [threads, deleteThread]) return (
Clear all logs from Jan app.