Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix/39959/duplicate query space initialization (#9888)

ulfertsb9ff3739e1e5
diff --git a/frontend/src/app/features/work-packages/components/wp-list/wp-list.service.ts b/frontend/src/app/features/work-packages/components/wp-list/wp-list.service.ts
index edabe201e1b..5fe121a45e6 100644
--- a/frontend/src/app/features/work-packages/components/wp-list/wp-list.service.ts
+++ b/frontend/src/app/features/work-packages/components/wp-list/wp-list.service.ts
@@ -337,16 +337,6 @@ export class WorkPackagesListService {
}
}
- private updateStatesFromQueryOnPromise(promise:Promise<QueryResource>):Promise<QueryResource> {
- void promise
- .then((query) => {
- this.wpStatesInitialization.initialize(query, query.results);
- return query;
- });
-
- return promise;
- }
-
public get currentQuery() {
return this.querySpace.query.value!;
}
diff --git a/frontend/src/app/features/work-packages/components/wp-relations/wp-relations.service.ts b/frontend/src/app/features/work-packages/components/wp-relations/wp-relations.service.ts
index 90d6cb076c0..9083673aad4 100644
--- a/frontend/src/app/features/work-packages/components/wp-relations/wp-relations.service.ts
+++ b/frontend/src/app/features/work-packages/components/wp-relations/wp-relations.service.ts
@@ -205,7 +205,7 @@ export class WorkPackageRelationsService extends StateCacheService<RelationsStat
}
/**
- * Given a set of complete relations for this work packge,
+ * Given a set of complete relations for this work package,
* returns the RelationsStateValue
*
* @param wpId The wpId the relations belong to
diff --git a/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts b/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts
index ee6bfcf72ef..c8a3c655a4a 100644
--- a/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts
+++ b/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts
@@ -139,9 +139,9 @@ export class PartitionedQuerySpacePageComponent extends WorkPackagesViewBase imp
this.cdRef.detectChanges();
});
- // If the query was loaded, reload invisibly
+ // Load the query. If it hasn't been loaded before, do that visibly.
const isFirstLoad = !this.querySpace.initialized.hasValue();
- this.refresh(isFirstLoad, isFirstLoad);
+ this.loadingIndicator = this.loadQuery(isFirstLoad);
// Mark tableInformationLoaded when initially loading done
this.setupInformationLoadedListener();
@@ -246,28 +246,22 @@ export class PartitionedQuerySpacePageComponent extends WorkPackagesViewBase imp
}
refresh(visibly = false, firstPage = false):Promise<unknown> {
- let promise:Promise<unknown>;
- const query = this.currentQuery;
-
- if (firstPage || !query) {
- promise = this.loadFirstPage();
- } else {
- const pagination = this.wpListService.getPaginationInfo();
- promise = this.wpListService
- .loadQueryFromExisting(query, pagination, this.projectIdentifier)
- .toPromise();
- }
+ let promise = this.loadQuery(firstPage) as Promise<unknown>;
if (visibly) {
- return this.loadingIndicator = promise.then((loadedQuery:QueryResource) => {
+ promise = promise.then((loadedQuery:QueryResource) => {
this.wpStatesInitialization.initialize(loadedQuery, loadedQuery.results);
return this.additionalLoadingTime();
});
+
+ this.loadingIndicator = promise;
+ } else {
+ promise = promise.then((loadedQuery:QueryResource) => {
+ this.wpStatesInitialization.initialize(loadedQuery, loadedQuery.results);
+ });
}
- return promise.then((loadedQuery:QueryResource) => {
- this.wpStatesInitialization.initialize(loadedQuery, loadedQuery.results);
- });
+ return promise;
}
protected inviteModal = InviteUserModalComponent;
@@ -279,6 +273,22 @@ export class PartitionedQuerySpacePageComponent extends WorkPackagesViewBase imp
});
}
+ protected loadQuery(firstPage = false):Promise<QueryResource> {
+ let promise:Promise<QueryResource>;
+ const query = this.currentQuery;
+
+ if (firstPage || !query) {
+ promise = this.loadFirstPage();
+ } else {
+ const pagination = this.wpListService.getPaginationInfo();
+ promise = this.wpListService
+ .loadQueryFromExisting(query, pagination, this.projectIdentifier)
+ .toPromise();
+ }
+
+ return promise;
+ }
+
protected loadFirstPage():Promise<QueryResource> {
if (this.currentQuery) {
return this.wpListService.reloadQuery(this.currentQuery, this.projectIdentifier).toPromise();
diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-additional-elements.service.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-additional-elements.service.ts
index fe3fa5732fa..4261f2d45e3 100644
--- a/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-additional-elements.service.ts
+++ b/frontend/src/app/features/work-packages/routing/wp-view-base/view-services/wp-view-additional-elements.service.ts
@@ -52,7 +52,7 @@ export class WorkPackageViewAdditionalElementsService {
readonly wpRelations:WorkPackageRelationsService) {
}
- public initialize(query:QueryResource, results:WorkPackageCollectionResource) {
+ public initialize(query:QueryResource, results:WorkPackageCollectionResource):void {
const rows = results.elements;
// Add relations to the stack