Skip to content

Commit

Permalink
fix/no-assistant-available-fresh-install (#876)
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-menlo authored Dec 6, 2023
1 parent efdc776 commit 9e6fdf8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions web/containers/Layout/TopBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CommandSearch from '@/containers/Layout/TopBar/CommandSearch'
import { MainViewState } from '@/constants/screens'

import { useCreateNewThread } from '@/hooks/useCreateNewThread'
import useGetAssistants from '@/hooks/useGetAssistants'
import useGetAssistants, { getAssistants } from '@/hooks/useGetAssistants'
import { useMainViewState } from '@/hooks/useMainViewState'

import { showRightSideBarAtom } from '@/screens/Chat/Sidebar'
Expand All @@ -33,10 +33,18 @@ const TopBar = () => {

const onCreateConversationClick = async () => {
if (assistants.length === 0) {
alert('No assistant available')
return
await getAssistants().then((res) => {
if (res) {
if (res.length === 0) {
alert('No assistant available')
return
}
requestCreateNewThread(res[0])
}
})
} else {
requestCreateNewThread(assistants[0])
}
requestCreateNewThread(assistants[0])
}

return (
Expand Down
2 changes: 1 addition & 1 deletion web/hooks/useGetAssistants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Assistant, ExtensionType, AssistantExtension } from '@janhq/core'

import { extensionManager } from '@/extension/ExtensionManager'

const getAssistants = async (): Promise<Assistant[]> => {
export const getAssistants = async (): Promise<Assistant[]> => {
return (
extensionManager
.get<AssistantExtension>(ExtensionType.Assistant)
Expand Down

0 comments on commit 9e6fdf8

Please sign in to comment.