mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
optimalization
This commit is contained in:
parent
cc049368e3
commit
22d37bda5d
@ -95,11 +95,15 @@ export { OpenedTabsProvider, useOpenedTabs, useSetOpenedTabs };
|
||||
export function useUpdateDatabaseForTab(tabVisible, conid, database) {
|
||||
const connection = useConnectionInfo({ conid });
|
||||
const setDb = useSetCurrentDatabase();
|
||||
const currentDb = useCurrentDatabase();
|
||||
const previousTabVisible = usePrevious(!!(tabVisible && connection));
|
||||
|
||||
if (!conid || !database) return;
|
||||
|
||||
if (!previousTabVisible && tabVisible && connection) {
|
||||
if (currentDb && currentDb.connection && currentDb.connection._id == conid && currentDb.name == database) {
|
||||
return;
|
||||
}
|
||||
setDb({
|
||||
name: database,
|
||||
connection,
|
||||
|
@ -6,7 +6,7 @@ import FavoritesWidget from './FavoritesWidget';
|
||||
import FilesWidget from './FilesWidget';
|
||||
import PluginsWidget from './PluginsWidget';
|
||||
|
||||
export default function WidgetContainer() {
|
||||
function WidgetContainerCore() {
|
||||
const currentWidget = useCurrentWidget();
|
||||
if (currentWidget === 'database') return <DatabaseWidget />;
|
||||
if (currentWidget === 'file') return <FilesWidget />;
|
||||
@ -15,3 +15,7 @@ export default function WidgetContainer() {
|
||||
if (currentWidget === 'favorites') return <FavoritesWidget />;
|
||||
return null;
|
||||
}
|
||||
|
||||
const WidgetContainer = React.memo(WidgetContainerCore);
|
||||
|
||||
export default WidgetContainer;
|
||||
|
Loading…
Reference in New Issue
Block a user