fixed race conditions when starting app

This commit is contained in:
Jan Prochazka
2021-05-17 17:42:53 +02:00
parent e44a95d723
commit 9d933d669a
4 changed files with 66 additions and 14 deletions

View File

@@ -1,10 +1,11 @@
import _ from 'lodash';
import { currentDatabase, openedTabs } from '../stores';
import { callWhenAppLoaded } from './appLoadManager';
import { getConnectionInfo } from './metadataLoaders';
let lastCurrentTab = null;
openedTabs.subscribe(async value => {
openedTabs.subscribe(value => {
const newCurrentTab = (value || []).find(x => x.selected);
if (newCurrentTab == lastCurrentTab) return;
@@ -15,11 +16,14 @@ openedTabs.subscribe(async value => {
database &&
(conid != _.get(lastCurrentTab, 'props.conid') || database != _.get(lastCurrentTab, 'props.database'))
) {
const connection = await getConnectionInfo({ conid });
currentDatabase.set({
connection,
name: database,
});
const doWork = async () => {
const connection = await getConnectionInfo({ conid });
currentDatabase.set({
connection,
name: database,
});
};
callWhenAppLoaded(doWork);
}
}