fix: add toaster warning when blocked create new thread (#3433)

This commit is contained in:
Faisal Amir 2024-08-22 11:17:35 +07:00 committed by GitHub
parent 90e4d85f9d
commit 77fd1728b9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,11 +10,13 @@ import {
Model,
AssistantTool,
} from '@janhq/core'
import { atom, useAtom, useAtomValue, useSetAtom } from 'jotai'
import { atom, useAtomValue, useSetAtom } from 'jotai'
import { copyOverInstructionEnabledAtom } from '@/containers/CopyInstruction'
import { fileUploadAtom } from '@/containers/Providers/Jotai'
import { toaster } from '@/containers/Toast'
import { generateThreadId } from '@/utils/thread'
import { useActiveModel } from './useActiveModel'
@ -93,7 +95,11 @@ export const useCreateNewThread = () => {
const lastMessage = threads[0]?.metadata?.lastMessage
if (!lastMessage && threads.length) {
return null
return toaster({
title: 'No new thread created.',
description: `To avoid piling up empty threads, please reuse previous one before creating new.`,
type: 'warning',
})
}
}