mirror of
https://github.com/supabase/supabase.git
synced 2026-10-13 13:19:09 +03:00
* Bump the deps, refactor deprecated code.
* Migrate keepPreviousData usage.
* Migrate all uses of InfiniteQuery.
* Fix refetchInterval in queries.
* Migrate all use of isLoading to isPending in mutations.
* Fix accessing location in claim-project.
* Fix a bug in duplicate query keys.
* Migrate all queries to use isPending.
* Revert "Fix accessing location in claim-project."
This reverts commit 2a07df64b5.
* Revert the rss.xml file to master.
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { useMemo } from 'react'
|
|
|
|
import { WRAPPER_HANDLERS } from 'components/interfaces/Integrations/Wrappers/Wrappers.constants'
|
|
import {
|
|
getWrapperMetaForWrapper,
|
|
wrapperMetaComparator,
|
|
} from 'components/interfaces/Integrations/Wrappers/Wrappers.utils'
|
|
import { useFDWsQuery } from 'data/fdw/fdws-query'
|
|
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
|
|
import { getAnalyticsBucketFDWName } from './AnalyticsBucketDetails.utils'
|
|
|
|
export const useAnalyticsBucketWrapperInstance = (
|
|
{ bucketId }: { bucketId?: string },
|
|
options?: { enabled?: boolean }
|
|
) => {
|
|
const { data: project, isPending: isLoadingProject } = useSelectedProjectQuery()
|
|
|
|
const defaultEnabled = options?.enabled ?? true
|
|
const { data, isPending: isLoadingFDWs } = useFDWsQuery(
|
|
{
|
|
projectRef: project?.ref,
|
|
connectionString: project?.connectionString,
|
|
},
|
|
{ enabled: defaultEnabled && !!bucketId }
|
|
)
|
|
|
|
const icebergWrapper = useMemo(() => {
|
|
return data
|
|
?.filter((wrapper) =>
|
|
wrapperMetaComparator(
|
|
{ handlerName: WRAPPER_HANDLERS.ICEBERG, server: { options: [] } },
|
|
wrapper
|
|
)
|
|
)
|
|
.find((w) => w.name === getAnalyticsBucketFDWName(bucketId ?? ''))
|
|
}, [data, bucketId])
|
|
|
|
const icebergWrapperMeta = getWrapperMetaForWrapper(icebergWrapper)
|
|
|
|
return {
|
|
data: icebergWrapper,
|
|
meta: icebergWrapperMeta,
|
|
isLoading: isLoadingProject || isLoadingFDWs || !bucketId,
|
|
}
|
|
}
|