Skip to content

Commit

Permalink
Merge pull request #2007 from stakwork/feature/disable-follow-questions
Browse files Browse the repository at this point in the history
feat: fixed issue with epty answers, disabled follow questions on load
  • Loading branch information
Rassl authored Aug 8, 2024
2 parents e609ce9 + e290bb8 commit ef415bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/components/App/SideBar/AiSummary/AiQuestions/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Slide } from '@mui/material'
import { memo } from 'react'
import { ClipLoader } from 'react-spinners'
import styled from 'styled-components'
import PlusIcon from '~/components/Icons/PlusIcon'
import StackIcon from '~/components/Icons/StackIcon'
import { Flex } from '~/components/common/Flex'
import { useHasAiChatsResponseLoading } from '~/stores/useAiSummaryStore'
import { useDataStore } from '~/stores/useDataStore'
import { useUserStore } from '~/stores/useUserStore'
import { colors } from '~/utils'
Expand All @@ -16,8 +18,13 @@ type Props = {
const _AiQuestions = ({ questions }: Props) => {
const { fetchData, setAbortRequests } = useDataStore((s) => s)
const [setBudget] = useUserStore((s) => [s.setBudget])
const hasLoadingResponse = useHasAiChatsResponseLoading()

const handleSubmitQuestion = (question: string) => {
if (hasLoadingResponse) {
return
}

if (question) {
fetchData(setBudget, setAbortRequests, question)
}
Expand Down Expand Up @@ -45,7 +52,7 @@ const _AiQuestions = ({ questions }: Props) => {
>
<span>{i}</span>
<Flex className="icon">
<PlusIcon />
{hasLoadingResponse ? <ClipLoader color={colors.white} size={13} /> : <PlusIcon />}
</Flex>
</QuestionWrapper>
))}
Expand Down
4 changes: 2 additions & 2 deletions src/stores/useAiSummaryStore/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { isEmpty } from 'lodash'
import { create } from 'zustand'
import { devtools } from 'zustand/middleware'
import { AIEntity } from '~/types'
Expand Down Expand Up @@ -61,7 +60,8 @@ export const useAiSummaryStore = create<AiSummaryStore>()(
})),
)

export const useHasAiChats = () => useAiSummaryStore((s) => !isEmpty(s.aiSummaryAnswers) || !!s.newLoading)
export const useHasAiChats = () =>
useAiSummaryStore((s) => Object.values(s.aiSummaryAnswers).filter((i) => i.shouldRender).length || !!s.newLoading)

export const useHasAiChatsResponseLoading = () =>
useAiSummaryStore((s) => {
Expand Down

0 comments on commit ef415bc

Please sign in to comment.