Skip to content

Commit

Permalink
Merge branch 'Connect-Search-Filter' of https://github.com/MirzaHanan…
Browse files Browse the repository at this point in the history
…/sphinx-nav-fiber into Connect-Search-Filter
  • Loading branch information
MirzaHanan committed Oct 2, 2024
2 parents e8d3d40 + ccf1a53 commit cbdd26b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
6 changes: 1 addition & 5 deletions src/components/App/SideBar/FilterSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import PlusIcon from '~/components/Icons/PlusIcon'
import { SchemaExtended } from '~/components/ModalsContainer/BlueprintModal/types'
import { Flex } from '~/components/common/Flex'
import { useDataStore } from '~/stores/useDataStore'
import { useUserStore } from '~/stores/useUserStore'
import { colors } from '~/utils/colors'
import { Hops } from './Hops'
import { MaxResults } from './MaxResults'
Expand Down Expand Up @@ -42,8 +41,7 @@ export const FilterSearch = ({
)
}

const { setFilters, fetchData, setAbortRequests } = useDataStore((s) => s)
const { setBudget } = useUserStore((s) => s)
const { setFilters } = useDataStore((s) => s)
const [selectedTypes, setSelectedTypes] = useState<string[]>(defaultValues.selectedTypes)
const [hops, setHops] = useState(defaultValues.hops)
const [sourceNodes, setSourceNodes] = useState<number>(defaultValues.sourceNodes)
Expand Down Expand Up @@ -74,8 +72,6 @@ export const FilterSearch = ({

setAnchorEl(null)
onClose()

await fetchData(setBudget, setAbortRequests)
}

const uniqueSchemas = (showAllSchemas ? schemaAll : schemaAll.slice(0, 4)).filter(
Expand Down
12 changes: 5 additions & 7 deletions src/stores/useDataStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ export type FetchNodeParams = {
skip_cache?: string
free?: string
media_type?: string
node_type?: string
limit?: string
depth?: string
top_node_count?: string
}

export type SidebarFilterWithCount = {
Expand Down Expand Up @@ -160,7 +156,7 @@ export const useDataStore = create<DataStore>()(
devtools((set, get) => ({
...defaultData,

fetchData: async (setBudget, setAbortRequests, AISearchQuery = '', params: FetchNodeParams = {}) => {
fetchData: async (setBudget, setAbortRequests, AISearchQuery = '') => {
const { dataInitial: existingData, filters } = get()
const currentPage = filters.skip
const itemsPerPage = filters.limit
Expand Down Expand Up @@ -198,7 +194,6 @@ export const useDataStore = create<DataStore>()(

const updatedParams = {
...withoutNodeType,
...params,
...ai,
skip: currentPage === 0 ? String(currentPage * itemsPerPage) : String(currentPage * itemsPerPage + 1),
limit: word ? '25' : String(itemsPerPage),
Expand Down Expand Up @@ -306,7 +301,10 @@ export const useDataStore = create<DataStore>()(
fetchData()
},
resetDataNew: () => null,
setFilters: (filters: FilterParams) => set((state) => ({ filters: { ...state.filters, ...filters, page: 0 } })),
setFilters: (filters: Partial<FilterParams>) => {
set((state) => ({ filters: { ...state.filters, ...filters, skip: 0 } }))
get().fetchData(get().setBudget, get().setAbortRequests)
},
setSidebarFilterCounts: (sidebarFilterCounts) => set({ sidebarFilterCounts }),
setTrendingTopics: (trendingTopics) => set({ trendingTopics }),
setStats: (stats) => set({ stats }),
Expand Down

0 comments on commit cbdd26b

Please sign in to comment.