Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close #2022

Closed

close #2022

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/App/UniverseQuestion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import { useAppStore } from '~/stores/useAppStore'
import { useDataStore } from '~/stores/useDataStore'
import { useUserStore } from '~/stores/useUserStore'
import { colors } from '~/utils/colors'
import { useUpdateSelectedNode } from '~/stores/useGraphStore'

export const UniverseQuestion = () => {
const [question, setQuestion] = useState('')
const { fetchData, setAbortRequests, seedQuestions } = useDataStore((s) => s)
const [setBudget] = useUserStore((s) => [s.setBudget])
const setSelectedNode = useUpdateSelectedNode()

const { setUniverseQuestionIsOpen, setSidebarOpen, setShowCollapseButton } = useAppStore((s) => ({
setUniverseQuestionIsOpen: s.setUniverseQuestionIsOpen,
Expand All @@ -35,6 +37,7 @@ export const UniverseQuestion = () => {

const handleSubmitQuestion = async (questionToSubmit: string) => {
if (questionToSubmit) {
setSelectedNode(null)
resetAiSummaryAnswer()
setUniverseQuestionIsOpen()
setSidebarOpen(true)
Expand Down
10 changes: 8 additions & 2 deletions src/components/Universe/Graph/Cubes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ import { Cube } from './Cube'
import { RelevanceBadges } from './RelevanceBadges'
import { SelectionDataNodes } from './SelectionDataNodes'
import { TextNode } from './Text'
import { useAiSummaryStore } from '~/stores/useAiSummaryStore'

const POINTER_IN_DELAY = 200

export const Cubes = memo(() => {
const selectedNode = useSelectedNode()
const relativeIds = useSelectedNodeRelativeIds()
const { selectionGraphData, showSelectionGraph, setHoveredNode, setIsHovering } = useGraphStore((s) => s)
const { resetAiSummaryAnswer, setNewLoading } = useAiSummaryStore()

const data = useDataStore((s) => s.dataInitial)
const [data, abortFetchData] = useDataStore((s) => [s.dataInitial, s.abortFetchData])
const setTranscriptOpen = useAppStore((s) => s.setTranscriptOpen)

const ignoreNodeEvent = useCallback(
Expand All @@ -41,14 +43,18 @@ export const Cubes = memo(() => {
// always close transcript when switching nodes
setTranscriptOpen(false)

setNewLoading(null)
abortFetchData()
resetAiSummaryAnswer()

if (node.userData) {
if (!ignoreNodeEvent(node.userData as NodeExtended)) {
useGraphStore.getState().setSelectedNode((node?.userData as NodeExtended) || null)
}
}
}
},
[setTranscriptOpen, ignoreNodeEvent],
[setTranscriptOpen, setNewLoading, abortFetchData, resetAiSummaryAnswer, ignoreNodeEvent],
)

const hoverTimeoutRef = useRef<NodeJS.Timeout | null>(null)
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 @@
nextPage: () => void
setFilters: (filters: Partial<FilterParams>) => void
setSeedQuestions: (questions: string[]) => void
abortFetchData: () => void
}

const defaultData: Omit<
Expand Down Expand Up @@ -237,13 +238,20 @@
sidebarFilterCounts,
})
} catch (error) {
console.log(error)

Check warning on line 241 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / craco-build-run

Unexpected console statement

Check warning on line 241 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / eslint-run

Unexpected console statement

Check warning on line 241 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run

Unexpected console statement

if (error !== 'abort') {
set({ isLoadingNew: false, isFetching: false })
}
}
},

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

setPage: (page: number) => set({ currentPage: page }),
nextPage: () => {
const { currentPage, fetchData } = get()
Expand Down Expand Up @@ -275,7 +283,7 @@
setHideNodeDetails: (hideNodeDetails) => set({ hideNodeDetails }),
setSeedQuestions: (questions) => set({ seedQuestions: questions }),
updateNode: (updatedNode) => {
console.log(updatedNode)

Check warning on line 286 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / craco-build-run

Unexpected console statement

Check warning on line 286 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / eslint-run

Unexpected console statement

Check warning on line 286 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run

Unexpected console statement
},
addNewNode: (data) => {
const { dataInitial: existingData } = get()
Expand Down Expand Up @@ -319,7 +327,7 @@
})
},
removeNode: (id) => {
console.log(id)

Check warning on line 330 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / craco-build-run

Unexpected console statement

Check warning on line 330 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / eslint-run

Unexpected console statement

Check warning on line 330 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run

Unexpected console statement
},
setAbortRequests: (abortRequest) => set({ abortRequest }),
})),
Expand Down
Loading