| 299 | }, |
| 300 | |
| 301 | removeDatabaseQueryContext({ database, contextId }) { |
| 302 | const id = get().currentTabId; |
| 303 | const tab = get().tabsById.get(id); |
| 304 | if (!tab?.databaseQueryContexts?.has(database)) return undefined; |
| 305 | const contexts = tab.databaseQueryContexts.get(database)!; |
| 306 | const index = contexts.findIndex((c) => c.id === contextId); |
| 307 | if (index < 0) return undefined; |
| 308 | let next: SQLEditorDatabaseQueryContext | undefined; |
| 309 | set((s) => { |
| 310 | const draftTab = s.tabsById.get(id); |
| 311 | if (!draftTab?.databaseQueryContexts?.has(database)) return; |
| 312 | const arr = draftTab.databaseQueryContexts.get(database)!; |
| 313 | arr.splice(index, 1); |
| 314 | next = arr[index] ?? arr[index - 1]; |
| 315 | }); |
| 316 | return next; |
| 317 | }, |
| 318 | |
| 319 | batchRemoveDatabaseQueryContext({ database, contextIds }) { |
| 320 | if (contextIds.length === 0) return; |