MCPcopy Create free account
hub / github.com/bytebase/bytebase / updateDatabaseQueryContext

Function updateDatabaseQueryContext

frontend/src/react/stores/sqlEditor/tab.ts:346–369  ·  view source on GitHub ↗
({ database, contextId, context })

Source from the content-addressed store, hash-verified

344 },
345
346 updateDatabaseQueryContext({ database, contextId, context }) {
347 // Resolve the tab that OWNS this context by its globally-unique id
348 // rather than assuming `currentTabId`. A query that completes after
349 // the user switches tabs must still update its own tab's context —
350 // the Vue original mutated the reactive context object directly,
351 // which had the same cross-tab effect; immer freezes store objects
352 // so React must route through this action, hence the lookup.
353 const owner = locateDatabaseQueryContext(
354 get().tabsById,
355 database,
356 contextId
357 );
358 if (!owner) return undefined;
359 set((s) => {
360 const target = s.tabsById
361 .get(owner.tabId)
362 ?.databaseQueryContexts?.get(database)?.[owner.index];
363 if (!target) return;
364 Object.assign(target, context);
365 });
366 return get()
367 .tabsById.get(owner.tabId)
368 ?.databaseQueryContexts?.get(database)?.[owner.index];
369 },
370
371 async initProject(project) {
372 // Dedupe concurrent inits for the same project. During bootstrap

Callers

nothing calls this directly

Calls 4

getFunction · 0.85
setFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected