The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fixes rename query
Alaister Youngdc7813983ccf
diff --git a/studio/components/interfaces/SQLEditor/RenameQueryModal.tsx b/studio/components/interfaces/SQLEditor/RenameQueryModal.tsxindex 239a026363e..ff43f2b67f9 100644--- a/studio/components/interfaces/SQLEditor/RenameQueryModal.tsx+++ b/studio/components/interfaces/SQLEditor/RenameQueryModal.tsx@@ -1,6 +1,7 @@import { useParams } from 'common'import { useContentUpdateMutation } from 'data/content/content-update-mutation'import { useStore } from 'hooks'+import { sqlEditorState } from 'state/sql-editor'import { Button, Form, Input, Modal } from 'ui'export interface RenameQueryModalProps {@@ -13,7 +14,13 @@ export interface RenameQueryModalProps {const RenameQueryModal = ({ snippet, visible, onCancel, onComplete }: RenameQueryModalProps) => {const { ui } = useStore()const { ref } = useParams()- const { mutateAsync: updateContent } = useContentUpdateMutation()+ const { mutateAsync: updateContent } = useContentUpdateMutation({+ onSuccess(data) {+ if (data.content.id) {+ sqlEditorState.snippets[data.content.id].snippet.name = data.content.name+ }+ },+ })const { id, name, description } = snippetdiff --git a/studio/components/layouts/SQLEditorLayout/QueryItem.tsx b/studio/components/layouts/SQLEditorLayout/QueryItem.tsxindex 03124469a1a..7472e6ab7eb 100644--- a/studio/components/layouts/SQLEditorLayout/QueryItem.tsx+++ b/studio/components/layouts/SQLEditorLayout/QueryItem.tsx@@ -52,7 +52,13 @@ const QueryItemActions = observer(({ tabInfo }: { tabInfo: SqlSnippet }) => {const { ref } = useParams()const router = useRouter()const snap = useSqlEditorStateSnapshot()- const { mutateAsync: deleteContent } = useContentDeleteMutation()+ const { mutateAsync: deleteContent } = useContentDeleteMutation({+ onSuccess(data) {+ if (data.id) {+ snap.removeSnippet(data.id)+ }+ },+ })const { id, name } = tabInfo || {}const [renameModalOpen, setRenameModalOpen] = useState(false)@@ -78,7 +84,6 @@ const QueryItemActions = observer(({ tabInfo }: { tabInfo: SqlSnippet }) => {try {await deleteContent({ projectRef: ref, id })- snap.removeSnippet(id)const existingSnippetIds = Object.keys(snap.snippets)if (existingSnippetIds.length === 0) {diff --git a/studio/data/content/content-update-mutation.ts b/studio/data/content/content-update-mutation.tsindex 111915077ba..a6c4deb843f 100644--- a/studio/data/content/content-update-mutation.ts+++ b/studio/data/content/content-update-mutation.ts@@ -14,7 +14,7 @@ export async function updateContent({ projectRef, id, content }: UpdateContentVariables,signal?: AbortSignal) {- const created = await patch<UserContent>(+ const created = await patch<UserContent[]>(`${API_URL}/projects/${projectRef}/content?id=${id}`,content,{ signal }@@ -23,7 +23,7 @@ export async function updateContent(throw created.error}- return { content: created }+ return { content: created[0] }}type UpdateContentData = Awaited<ReturnType<typeof updateContent>>