mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 04:16:00 +00:00
26 lines
639 B
TypeScript
26 lines
639 B
TypeScript
import _ from 'lodash';
|
|
import { currentDatabase, openedTabs } from '../stores';
|
|
|
|
let lastCurrentTab = null;
|
|
|
|
openedTabs.subscribe(value => {
|
|
const newCurrentTab = (value || []).find(x => x.selected);
|
|
if (newCurrentTab == lastCurrentTab) return;
|
|
|
|
if (newCurrentTab) {
|
|
const { conid, database } = newCurrentTab.props || {};
|
|
if (
|
|
conid &&
|
|
database &&
|
|
(conid != _.get(lastCurrentTab, 'props.conid') || database != _.get(lastCurrentTab, 'props.database'))
|
|
) {
|
|
currentDatabase.set({
|
|
connection: { _id: conid },
|
|
name: database,
|
|
});
|
|
}
|
|
}
|
|
|
|
lastCurrentTab = newCurrentTab;
|
|
});
|