Skip to content

Commit

Permalink
Merge pull request #2015 from Shoaibdev7/Ensure-Home-Button-is-Always…
Browse files Browse the repository at this point in the history
…-Clickable

[AI Chat]: Ensure `Home Button` and `LOGO` is Always Clickable for Navigation
  • Loading branch information
Rassl authored Aug 12, 2024
2 parents 4fc2b36 + c0eeb62 commit 5eebecb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/components/App/MainToolbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SourcesTableIcon from '~/components/Icons/SourcesTableIcon'
import { Flex } from '~/components/common/Flex'
import { Text } from '~/components/common/Text'
import { useAiSummaryStore } from '~/stores/useAiSummaryStore'
import { useDataStore } from '~/stores/useDataStore'
import { useFeatureFlagStore } from '~/stores/useFeatureFlagStore'
import { useModal } from '~/stores/useModalStore'
import { useUserStore } from '~/stores/useUserStore'
Expand All @@ -24,14 +25,17 @@ export const MainToolbar = () => {
const { open: openFeedbackModal } = useModal('feedback')
const navigate = useNavigate()

const { resetAiSummaryAnswer } = useAiSummaryStore()
const { resetAiSummaryAnswer, setNewLoading } = useAiSummaryStore()
const { abortFetchData } = useDataStore((s) => s)
const customSchemaFeatureFlag = useFeatureFlagStore((s) => s.customSchemaFeatureFlag)
const userFeedbackFeatureFlag = useFeatureFlagStore((s) => s.userFeedbackFeatureFlag)

const [isAdmin] = useUserStore((s) => [s.isAdmin])
const sphinxEnabled = isSphinx()

const handleLogoClick = () => {
setNewLoading(null)
abortFetchData()
resetAiSummaryAnswer()
navigate('/')
}
Expand Down
10 changes: 7 additions & 3 deletions src/components/App/SideBar/AiView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import styled from 'styled-components'
import ArrowBackIcon from '~/components/Icons/ArrowBackIcon'
import { Flex } from '~/components/common/Flex'
import { useAiSummaryStore } from '~/stores/useAiSummaryStore'
import { useDataStore } from '~/stores/useDataStore'
import { colors } from '~/utils/colors'
import { AiSearch } from '../AiSearch'
import { AiSummary } from '../AiSummary'
Expand All @@ -12,15 +13,18 @@ export const MENU_WIDTH = 390

// eslint-disable-next-line react/display-name
export const AiView = () => {
const { aiSummaryAnswers, resetAiSummaryAnswer, newLoading } = useAiSummaryStore((s) => s)
const { aiSummaryAnswers, resetAiSummaryAnswer, newLoading, setNewLoading } = useAiSummaryStore((s) => s)
const { abortFetchData } = useDataStore((s) => s)

const navigate = useNavigate()

const handleCloseAi = () => {
setNewLoading(null)
abortFetchData()
resetAiSummaryAnswer()
navigate('/')
}

const navigate = useNavigate()

return (
<Wrapper>
<Flex align="flex-start">
Expand Down
8 changes: 8 additions & 0 deletions src/stores/useDataStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export type DataStore = {
nextPage: () => void
setFilters: (filters: Partial<FilterParams>) => void
setSeedQuestions: (questions: string[]) => void
abortFetchData: () => void
}

const defaultData: Omit<
Expand Down Expand Up @@ -244,6 +245,13 @@ export const useDataStore = create<DataStore>()(
}
}
},

abortFetchData: () => {
if (abortController) {
abortController.abort('abort')
}
},

setPage: (page: number) => set({ currentPage: page }),
nextPage: () => {
const { currentPage, fetchData } = get()
Expand Down

0 comments on commit 5eebecb

Please sign in to comment.