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 project include list loading flicker

Benjamin Bädorfbdb36ccc39ac
diff --git a/frontend/src/app/shared/components/project-include/project-include.component.html b/frontend/src/app/shared/components/project-include/project-include.component.html
index 1d898d9076e..929e5742560 100644
--- a/frontend/src/app/shared/components/project-include/project-include.component.html
+++ b/frontend/src/app/shared/components/project-include/project-include.component.html
@@ -45,11 +45,7 @@
></span>
</spot-text-field>
- <ng-container *ngIf="(projects$ | async)?.length > 0">
- has projects
- </ng-container>
<ng-container *ngIf="(loading$ | async) === false; else loadingTemplate">
- loading done
<ul
class="op-project-include--list"
op-project-list
diff --git a/frontend/src/app/shared/components/project-include/project-include.component.ts b/frontend/src/app/shared/components/project-include/project-include.component.ts
index 8671baedfe7..a8b82fb0048 100644
--- a/frontend/src/app/shared/components/project-include/project-include.component.ts
+++ b/frontend/src/app/shared/components/project-include/project-include.component.ts
@@ -16,6 +16,7 @@ import {
finalize,
map,
mergeMap,
+ shareReplay,
take,
} from 'rxjs/operators';
@@ -199,9 +200,16 @@ export class OpProjectIncludeComponent extends UntilDestroyedMixin implements On
),
),
map((projects) => recursiveSort(projects)),
+ shareReplay(),
);
- public loading$ = new BehaviorSubject(false);
+ public fetchingProjects$ = new BehaviorSubject(false);
+ public loading$ = combineLatest([
+ this.fetchingProjects$,
+ this.projects$,
+ ]).pipe(
+ map(([isFetching, projects]) => isFetching || projects.length === 0)
+ );
public get params():ApiV3ListParameters {
const filters:ApiV3ListFilter[] = [
@@ -269,7 +277,7 @@ export class OpProjectIncludeComponent extends UntilDestroyedMixin implements On
}
public loadAllProjects():void {
- this.loading$.next(true);
+ this.fetchingProjects$.next(true);
getPaginatedResults<IProject>(
(params) => {
@@ -278,7 +286,7 @@ export class OpProjectIncludeComponent extends UntilDestroyedMixin implements On
},
)
.pipe(
- finalize(() => this.loading$.next(false)),
+ finalize(() => this.fetchingProjects$.next(false)),
)
.subscribe((projects) => {
this.allProjects$.next(projects);