packages/sdk/packages/indexed-results/src/hooks/useTriggerFreshIndexedResult.tsx
import { useCallback } from 'react'
import type { IndexedResultsConfig } from '../interfaces/index.ts'
export const useTriggerFreshIndexedResult = (indexedResultsConfig?: IndexedResultsConfig, trigger?: boolean) => {
const { processIndexedResults, refresh } = indexedResultsConfig ?? {}
const freshResult = useCallback(async () => {
if (refresh && trigger) {
return refresh ? await refresh?.(processIndexedResults ?? {}) : undefined
}
}, [refresh, processIndexedResults, trigger])
return freshResult
}