Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

delete useOptimisticSqlSnippetCreate

Alaister Young0cb6df2d2342
diff --git a/studio/hooks/index.ts b/studio/hooks/index.ts
index 83e5a772641..25a3607e163 100644
--- a/studio/hooks/index.ts
+++ b/studio/hooks/index.ts
@@ -1,6 +1,5 @@
export * from './misc/useStore'
export * from './misc/withAuth'
-export * from './misc/useOptimisticSqlSnippetCreate'
export * from './misc/useImmutableValue'
export * from './misc/useCheckPermissions'
export * from './misc/useLocalStorage'
diff --git a/studio/hooks/misc/useOptimisticSqlSnippetCreate.ts b/studio/hooks/misc/useOptimisticSqlSnippetCreate.ts
deleted file mode 100644
index 2a4e7e9a13c..00000000000
--- a/studio/hooks/misc/useOptimisticSqlSnippetCreate.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import { createSqlSnippetSkeleton } from 'components/interfaces/SQLEditor/SQLEditor.utils'
-import { useProfileQuery } from 'data/profile/profile-query'
-import { useCallback } from 'react'
-import { useStore } from './useStore'
-import { useContentCreateMutation } from 'data/content/content-create-mutation'
-import { useParams } from 'common'
-import { uuidv4 } from 'lib/helpers'
-
-// [Joshen] Currently not using this after the SQL store refactor to valtio/RQ
-
-export function useOptimisticSqlSnippetCreate(canCreateSQLSnippet: boolean) {
- const { ref } = useParams()
- const { data: profile } = useProfileQuery()
- const { ui, content: contentStore } = useStore()
- const { mutateAsync: createContent } = useContentCreateMutation()
-
- return useCallback(
- async (args?: Parameters<typeof createSqlSnippetSkeleton>[0]) => {
- // get currently selected tab id in case we need to roll back to it
- // const previouslySelectedTabId = sqlEditorStore.selectedTabId
-
- if (!ref) return console.error('Project ref is required')
-
- const snippet = createSqlSnippetSkeleton({
- owner_id: profile?.id,
- ...args,
- })
-
- // save the snippet in memory in the content store with a client-generated id
- // const { data } = contentStore.createOptimistically(snippet)
- const data = { ...snippet, id: uuidv4() }
-
- // update the tabs in the sql editor storage to match the content store
- // const tabs = sqlEditorStore.tabsFromContentStore(contentStore, profile?.id)
- // sqlEditorStore.loadTabs(tabs, false)
-
- // select tab with new snippet
- // sqlEditorStore.selectTab(data.id)
-
- // save the new query to the server in the background
- if (canCreateSQLSnippet) {
- try {
- await createContent({ projectRef: ref, payload: data })
- } catch (error: any) {
- ui.setNotification({
- category: 'error',
- message: `Failed to create new query: ${error.message}`,
- })
- }
- } else {
- ui.setNotification({
- category: 'info',
- message: 'Your queries will not be saved as you do not have sufficient permissions',
- })
- }
- },
- [profile, contentStore]
- )
-}