mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix(core-app): CB-1260 navigation tree refresh behaviour
This commit is contained in:
@@ -79,6 +79,7 @@ export class NavTreeResource extends CachedMapResource<string, string[]> {
|
||||
|
||||
this.onNodeRefresh = new Executor<string>(null, (a, b) => a === b);
|
||||
this.onDataOutdated.addHandler(navNodeInfoResource.markOutdated.bind(navNodeInfoResource));
|
||||
this.onDataUpdate.addHandler(navNodeInfoResource.markUpdated.bind(navNodeInfoResource));
|
||||
this.sessionDataResource.onDataUpdate.addPostHandler(() => this.markOutdated());
|
||||
this.connectionInfo.onItemAdd.addHandler(this.connectionUpdateHandler.bind(this));
|
||||
this.connectionInfo.onItemDelete.addHandler(this.connectionRemoveHandler);
|
||||
@@ -106,7 +107,7 @@ export class NavTreeResource extends CachedMapResource<string, string[]> {
|
||||
ResourceKeyUtils.forEach(children, key => {
|
||||
const metadata = this.metadata.get(key);
|
||||
|
||||
if (!metadata.withDetails) {
|
||||
if (!metadata.withDetails && state) {
|
||||
metadata.outdated = true;
|
||||
}
|
||||
metadata.withDetails = state;
|
||||
@@ -273,7 +274,7 @@ export class NavTreeResource extends CachedMapResource<string, string[]> {
|
||||
}
|
||||
|
||||
private async connectionUpdateHandler(key: ResourceKey<string>) {
|
||||
const closedConnectionsTree: string[] = [];
|
||||
const closedConnections: string[] = [];
|
||||
|
||||
await ResourceKeyUtils.forEachAsync(key, async key => {
|
||||
const nodeId = NodeManagerUtils.connectionIdToConnectionNodeId(key);
|
||||
@@ -282,15 +283,17 @@ export class NavTreeResource extends CachedMapResource<string, string[]> {
|
||||
const connectionInfo = this.connectionInfo.get(key);
|
||||
|
||||
if (!connectionInfo?.connected) {
|
||||
closedConnectionsTree.push(...this.get(nodeId) || []);
|
||||
closedConnections.push(nodeId);
|
||||
} else {
|
||||
await this.markOutdated(nodeId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (closedConnectionsTree.length > 0) {
|
||||
this.delete(resourceKeyList(closedConnectionsTree));
|
||||
if (closedConnections.length > 0) {
|
||||
const key = resourceKeyList(closedConnections);
|
||||
this.set(key, closedConnections.map(() => []));
|
||||
await this.markOutdated(ROOT_NODE_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export function useTable(): ITableState {
|
||||
return Array.from(this.selected.values()).some(v => v);
|
||||
},
|
||||
unselect(key?: string | string[]) {
|
||||
if (!key) {
|
||||
if (key === undefined) {
|
||||
this.selected.clear();
|
||||
} else {
|
||||
if (typeof key === 'string') {
|
||||
@@ -51,7 +51,7 @@ export function useTable(): ITableState {
|
||||
return this.selected;
|
||||
},
|
||||
unexpand(key?: string | string[]) {
|
||||
if (!key) {
|
||||
if (key === undefined) {
|
||||
this.expanded.clear();
|
||||
} else {
|
||||
if (typeof key === 'string') {
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ export const DriverProperties: TabContainerPanelComponent<IConnectionFormProps>
|
||||
key: key ?? '',
|
||||
defaultValue: value ?? '',
|
||||
keyPlaceholder: 'property',
|
||||
new: !key,
|
||||
new: key === undefined,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ export abstract class CachedMapResource<
|
||||
makeObservable(this, {
|
||||
set: action,
|
||||
delete: action,
|
||||
clear: action,
|
||||
values: computed,
|
||||
keys: computed,
|
||||
});
|
||||
@@ -159,7 +160,7 @@ export abstract class CachedMapResource<
|
||||
markOutdated(): Promise<void>
|
||||
markOutdated(key: ResourceKey<TKey>): Promise<void>
|
||||
async markOutdated(key?: ResourceKey<TKey>): Promise<void> {
|
||||
if (!key) {
|
||||
if (key === undefined) {
|
||||
key = resourceKeyList(this.keys);
|
||||
} else {
|
||||
key = this.transformParam(key);
|
||||
@@ -176,7 +177,7 @@ export abstract class CachedMapResource<
|
||||
markUpdated(): void
|
||||
markUpdated(key: ResourceKey<TKey>): void
|
||||
markUpdated(key?: ResourceKey<TKey>): void {
|
||||
if (!key) {
|
||||
if (key === undefined) {
|
||||
key = resourceKeyList(this.keys);
|
||||
} else {
|
||||
key = this.transformParam(key);
|
||||
@@ -241,6 +242,11 @@ export abstract class CachedMapResource<
|
||||
this.onItemDelete.execute(key);
|
||||
}
|
||||
|
||||
clear(): void {
|
||||
this.data.clear();
|
||||
this.metadata.clear();
|
||||
}
|
||||
|
||||
async refresh<T extends CachedResourceIncludeArgs<TValue, TArguments> = []>(
|
||||
key: TKey,
|
||||
includes?: T
|
||||
@@ -291,7 +297,7 @@ export abstract class CachedMapResource<
|
||||
}
|
||||
|
||||
getIncludes(key?: ResourceKey<TKey>): string[] {
|
||||
if (!key) {
|
||||
if (key === undefined) {
|
||||
return this.defaultIncludes;
|
||||
}
|
||||
key = this.transformParam(key);
|
||||
|
||||
Reference in New Issue
Block a user