Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions webapp/packages/core-connections/src/ConnectionInfoResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class ConnectionInfoResource extends CachedMapResource<IConnectionInfoPar
connectionInfoEventHandler: ConnectionInfoEventHandler,
connectionStateEventHandler: ConnectionStateEventHandler,
userInfoResource: UserInfoResource,
navTreeResource: NavTreeResource,
private readonly navTreeResource: NavTreeResource,
) {
super();

Expand Down Expand Up @@ -214,18 +214,18 @@ export class ConnectionInfoResource extends CachedMapResource<IConnectionInfoPar
connectionInfoEventHandler.onEvent<ResourceKeyList<IConnectionInfoParams>>(
ServerEventId.CbDatasourceUpdated,
key => {
if (this.isConnected(key)) {
if (this.isConnected(key) && !this.isOutdated(key)) {
const connection = this.get(key);

this.dataSynchronizationService
.requestSynchronization('connection', connection.map(connection => connection?.name).join('\n'))
.then(state => {
if (state) {
this.markOutdated(key);
this.updateFromEvent(key);
}
});
} else {
this.markOutdated(key);
this.updateFromEvent(key);
Comment thread
devnaumov marked this conversation as resolved.
}
},
data =>
Expand Down Expand Up @@ -297,6 +297,32 @@ export class ConnectionInfoResource extends CachedMapResource<IConnectionInfoPar
return this.get(key).every(connection => connection?.connected ?? false);
}

private async updateFromEvent(key: ResourceKeyList<IConnectionInfoParams>): Promise<void> {
for (const connectionKey of key) {
const currentConnection = this.get(connectionKey);
const newConnection = await this.refresh(connectionKey);

if (currentConnection?.nodePath !== newConnection?.nodePath) {
if (currentConnection?.nodePath) {
const parent = this.navNodeInfoResource.getParent(currentConnection.nodePath);

if (parent) {
this.navTreeResource.markOutdated(parent);
}
}

if (newConnection?.nodePath) {
await this.navNodeInfoResource.loadNodeParents(newConnection.nodePath);
const parent = this.navNodeInfoResource.getParent(newConnection.nodePath);

if (parent) {
this.navTreeResource.markOutdated(parent);
}
}
}
}
}

getConnectionIdForNodeId(projectId: string, nodeId: string): IConnectionInfoParams | undefined {
if (!NodeManagerUtils.isDatabaseObject(nodeId)) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2025 DBeaver Corp and others
* Copyright (C) 2020-2026 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -63,7 +63,7 @@ export function navigationTreeProjectFilter(
if (isRMProjectNode(node)) {
const project = projectsNavNodeService.getProject(node.uri);

if (!project || !projectsService.activeProjects.includes(project)) {
if (!project || !projectsService.activeProjects.some(({ id }) => id === project.id)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
* Copyright (C) 2020-2026 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
Expand All @@ -25,7 +25,7 @@ export function navigationTreeProjectsExpandStateGetter(
let active = false;
const project = projectsNavNodeService.getByNodeId(nodeId);
if (project) {
active = projectsService.activeProjects.includes(project);
active = projectsService.activeProjects.some(({ id }) => id === project.id);
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function navigationTreeProjectFilter(
if (isProjectNode(node)) {
const project = projectsNavNodeService.getProject(node.uri);

if (!project || !projectsService.activeProjects.includes(project)) {
if (!project || !projectsService.activeProjects.some(({ id }) => id === project.id)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* CloudBeaver - Cloud Database Manager
* Copyright (C) 2020-2024 DBeaver Corp and others
* Copyright (C) 2020-2026 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0.
* you may not use this file except in compliance with the License.
Expand All @@ -25,7 +25,7 @@ export function navigationTreeProjectsExpandStateGetter(
let active = false;
const project = projectsNavNodeService.getByNodeId(nodeId);
if (project) {
active = projectsService.activeProjects.includes(project);
active = projectsService.activeProjects.some(({ id }) => id === project.id);
}

return {
Expand Down
Loading