The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
load sql query from previous session
Joshen Lim6307cf9333aa
diff --git a/studio/localStores/sqlEditor/SqlEditorStore.js b/studio/localStores/sqlEditor/SqlEditorStore.jsindex 7f0314fe2e6..47adbd3cfd2 100644--- a/studio/localStores/sqlEditor/SqlEditorStore.js+++ b/studio/localStores/sqlEditor/SqlEditorStore.js@@ -7,6 +7,7 @@ import QueryTab from './QueryTab'import Favorite from './Favorite'// import { useStore } from 'hooks'import { SchemasQuery, TableColumnsQuery, AllFunctionsQuery } from './queries'+import { isUndefined } from 'lodash'let store = nulllet projectRef = null@@ -36,6 +37,7 @@ export const useSqlStore = () => {class SqlEditorStore {metaprojectRef+ localStorageKeytabs = []favorites = []selectedTabId@@ -55,6 +57,7 @@ class SqlEditorStore {this.meta = metathis.projectRef = projectRef+ this.localStorageKey = `supabase-sql-${projectRef}`this.loadKeywords()this.loadSchemas()@@ -165,6 +168,8 @@ class SqlEditorStore {}this.loadFavorites(json.favorites || [])++ this.loadPreviousSession()}loadInitialData() {@@ -215,6 +220,16 @@ class SqlEditorStore {this.favorites = values.map((x) => new Favorite(x.key, x.query, x.name, x.desc))}+ loadPreviousSession() {+ const tabId = localStorage.getItem(this.localStorageKey)+ const allSnippets = this.tabs.concat(this.favorites)+ const selectedTab = allSnippets.find((tab) => tab.id === tabId)++ if (!isUndefined(selectedTab)) {+ this.selectTab(selectedTab.id)+ }+ }+async loadKeywords() {const query = 'select * from pg_get_keywords();'const response = await this.meta.query(query)@@ -251,6 +266,9 @@ class SqlEditorStore {}selectTab(id) {+ // Save selected tab in local storage+ localStorage.setItem(this.localStorageKey, id)+// reset new selected query tabconst found = this.tabs.find((x) => x.id === this.selectedTabId)if (found && found.type == TAB_TYPES.SQL_QUERY) {diff --git a/studio/pages/project/[ref]/sql/index.tsx b/studio/pages/project/[ref]/sql/index.tsxindex 0e5a3493d98..5e238339c92 100644--- a/studio/pages/project/[ref]/sql/index.tsx+++ b/studio/pages/project/[ref]/sql/index.tsx@@ -41,7 +41,7 @@ const PageConfig = () => {*/async function loadPersistantData() {if (sqlEditorStore === undefined) return- sqlEditorStore.loadRemotePersistentData(contentStore, (user as any)?.id)+ await sqlEditorStore.loadRemotePersistentData(contentStore, (user as any)?.id)}return (