-
Notifications
You must be signed in to change notification settings - Fork 552
dbeaver/pro#7548 fixes "load more" button for main nodes #4408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,7 +87,7 @@ | |
| private readonly sessionDataResource: SessionDataResource, | ||
| private readonly userInfoResource: UserInfoResource, | ||
| private readonly projectInfoResource: ProjectInfoResource, | ||
| appAuthService: AppAuthService, | ||
| private readonly appAuthService: AppAuthService, | ||
| ) { | ||
| super(); | ||
|
|
||
|
|
@@ -119,7 +119,13 @@ | |
| () => CachedMapAllKey, | ||
| () => CachedMapAllKey, | ||
| ); | ||
| this.projectInfoResource.onDataOutdated.addHandler(() => this.markTreeOutdated(resourceKeyList(this.keys))); | ||
| this.projectInfoResource.onDataOutdated.addHandler(data => { | ||
| if (isResourceAlias(data)) { | ||
| return; | ||
| } else { | ||
| this.markTreeOutdated(data); | ||
| } | ||
| }); | ||
| this.sessionDataResource.onDataOutdated.addHandler(() => this.markTreeOutdated(resourceKeyList(this.keys))); | ||
| this.userInfoResource.onUserChange.addHandler( | ||
| action(() => { | ||
|
|
@@ -279,7 +285,7 @@ | |
| await this.onNodeMove.execute({ key, target }); | ||
| } | ||
|
|
||
| async setFilter(nodePath: string, include?: string[], exclude?: string[]) { | ||
| await this.graphQLService.sdk.navSetFolderFilter({ | ||
| nodePath, | ||
| exclude, | ||
|
|
@@ -551,7 +557,7 @@ | |
| return nestedChildren; | ||
| } | ||
|
|
||
| private setNavObject(data: NavNodeChildrenQuery | NavNodeChildrenQuery[], offset: number, limit: number): void { | ||
| private setNavObject(data: NavNodeChildrenQuery | NavNodeChildrenQuery[], offset: number, limit: number | undefined): void { | ||
| if (Array.isArray(data)) { | ||
| if (data.length === 0) { | ||
| return; | ||
|
|
@@ -589,12 +595,12 @@ | |
| } | ||
| } | ||
|
|
||
| private insertSlice(data: NavNodeChildrenQuery, offset: number, limit: number): string[] { | ||
| private insertSlice(data: NavNodeChildrenQuery, offset: number, limit: number | undefined): string[] { | ||
| let children = [...(this.get(data.parentPath) || [])]; | ||
|
|
||
| children.splice(offset, limit, ...data.navNodeChildren.map(node => node.uri)); | ||
| children.splice(offset, limit ?? children.length, ...data.navNodeChildren.map(node => node.uri)); | ||
|
|
||
| if (data.navNodeChildren.length < limit) { | ||
| if (limit !== undefined && data.navNodeChildren.length < limit) { | ||
| children.splice(offset + data.navNodeChildren.length, children.length - offset - data.navNodeChildren.length); | ||
| } | ||
|
|
||
|
|
@@ -603,7 +609,36 @@ | |
| return children; | ||
| } | ||
|
|
||
| private async loadNodeChildren(parentPath: string, offset: number, limit: number): Promise<NavNodeChildrenQuery> { | ||
| async loadAllChildren(nodeId: string): Promise<void> { | ||
| if (!this.appAuthService.authenticated || this.isLoading(nodeId)) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since resource is requires user to be authenticated I also added this logic here. otherwise we get erors on login screen |
||
| return; | ||
| } | ||
|
|
||
| const pageKey = CachedResourceOffsetPageKey(0, 0).setParent(CachedResourceOffsetPageTargetKey(nodeId)); | ||
| const hasPage = this.offsetPagination.getPageInfo(pageKey) !== undefined; | ||
|
|
||
| if (hasPage && !this.isOutdated(nodeId)) { | ||
| return; | ||
| } | ||
|
|
||
| this.markLoading(nodeId, true); | ||
| try { | ||
| const navNodeChildren = await this.loadNodeChildren(nodeId, 0, undefined); | ||
| const uris = navNodeChildren.navNodeChildren.map(node => node.uri); | ||
|
|
||
| runInAction(() => { | ||
| this.setNavObject(navNodeChildren, 0, undefined); | ||
| this.offsetPagination.setPage(CachedResourceOffsetPageKey(0, uris.length).setParent(CachedResourceOffsetPageTargetKey(nodeId)), uris, false); | ||
| this.markLoaded(nodeId); | ||
| this.markUpdated(nodeId); | ||
| this.markUpdated(resourceKeyList(uris)); | ||
| }); | ||
| } finally { | ||
| this.markLoading(nodeId, false); | ||
| } | ||
| } | ||
|
|
||
| private async loadNodeChildren(parentPath: string, offset: number, limit: number | undefined): Promise<NavNodeChildrenQuery> { | ||
| const metadata = this.metadata.get(parentPath); | ||
| const { navNodeChildren, navNodeInfo } = await this.graphQLService.sdk.navNodeChildren({ | ||
| parentPath, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -233,8 +233,9 @@ export function useElementsTree(options: IOptions): IElementsTree { | |
| const pageInfo = navTreeResource.offsetPagination.getPageInfo( | ||
| CachedResourceOffsetPageKey(0, 0).setParent(CachedResourceOffsetPageTargetKey(nodeId)), | ||
| ); | ||
| const hasMorePages = pageInfo && pageInfo.end === undefined; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this also reduces the amount of requests and also it is more correct for the logic below cause it actually tries to get next page |
||
|
|
||
| if (pageInfo) { | ||
| if (hasMorePages) { | ||
| const lastOffset = getNextPageOffset(pageInfo); | ||
| for (let offset = 0; offset < lastOffset; offset += navTreeResource.childrenLimit) { | ||
| await navTreeResource.load( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we preloaded all projects. If we change project we don't really want to update all project tree nodes info. We just want project we switched to, or projects we have changed.
datais an array of projectsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise there are abused network with requests about all projects info