Files
supabase/apps/studio/data/utils/deployment-commit-query.ts
Ivan Vasilov 1bc28c7f85 feat: Add a toast to refresh the page if there's a new version of Studio available (#36323)
* Initial work.

* Add missing import.

* Minor fixes.

* Minor fixes.

* Add a feature flag for the refresh toast.

* Add a commit for testing. Revert before merging.

* Remove header caching for testing.

* Tiny lint

* Fix

* One more

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-07-28 17:51:00 +08:00

24 lines
845 B
TypeScript

import { useQuery, UseQueryOptions } from '@tanstack/react-query'
import { fetchHandler } from 'data/fetchers'
import { BASE_PATH } from 'lib/constants'
import { ResponseError } from 'types'
export async function getDeploymentCommit(signal?: AbortSignal) {
const response = await fetchHandler(`${BASE_PATH}/api/get-deployment-commit`)
return (await response.json()) as { commitSha: string; commitTime: string }
}
export type DeploymentCommitData = Awaited<ReturnType<typeof getDeploymentCommit>>
export const useDeploymentCommitQuery = <TData = DeploymentCommitData>({
enabled = true,
...options
}: UseQueryOptions<DeploymentCommitData, ResponseError, TData> = {}) =>
useQuery<DeploymentCommitData, ResponseError, TData>(
['deployment-commit'],
({ signal }) => getDeploymentCommit(signal),
{
...options,
}
)