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

Extract the observables and skip the first WP update which is done because of a cache invalidation. Thus we avoid an unneccessary frame reload which also caused tests to flicker

Henriette Darge7a9172b3e919
diff --git a/frontend/src/app/features/work-packages/components/wp-relations/wp-relations.component.ts b/frontend/src/app/features/work-packages/components/wp-relations/wp-relations.component.ts
index 2d8e50640b2..9ee94b59932 100644
--- a/frontend/src/app/features/work-packages/components/wp-relations/wp-relations.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-relations/wp-relations.component.ts
@@ -38,20 +38,17 @@ import {
import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';
import {
debounceTime,
+ skip,
takeUntil,
} from 'rxjs/operators';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
import { componentDestroyed } from '@w11k/ngx-componentdestroyed';
import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
-import {
- RelationsStateValue,
- WorkPackageRelationsService,
-} from './wp-relations.service';
+import { WorkPackageRelationsService } from './wp-relations.service';
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service';
import { renderStreamMessage } from '@hotwired/turbo';
import { HalEventsService } from 'core-app/features/hal/services/hal-events.service';
-import { merge } from 'rxjs';
@Component({
selector: 'wp-relations',
@@ -80,25 +77,29 @@ export class WorkPackageRelationsComponent extends UntilDestroyedMixin implement
}
ngAfterViewInit() {
- // Listen to changes to this WP or relations
- merge(
- this.wpRelations.state(this.workPackage.id!).values$(),
- this.apiV3Service.work_packages.id(this.workPackage).requireAndStream(),
- ).pipe(
+ // Listen to changes on relations (e.g. by inline creating a child)
+ this.wpRelations
+ .state(this.workPackage.id!)
+ .values$()
+ .pipe(
takeUntil(componentDestroyed(this)),
debounceTime(500),
- ).subscribe((res:WorkPackageResource|RelationsStateValue) => {
- if (res.$isHal) {
- this.workPackage = <WorkPackageResource>res;
- }
+ ).subscribe(() => {
+ this.updateRelationsTab();
+ });
- void this.turboRequests.requestStream(this.turboFrameSrc)
- .then((result) => {
- renderStreamMessage(result.html);
- });
+ // Listen to changes to this WP
+ this.apiV3Service.work_packages.id(this.workPackage)
+ .requireAndStream()
+ .pipe(
+ skip(1),
+ takeUntil(componentDestroyed(this)),
+ debounceTime(500),
+ ).subscribe((wp:WorkPackageResource) => {
+ this.workPackage = wp;
- this.updateCounter();
- });
+ this.updateRelationsTab();
+ });
/*
We globally listen for turbo:submit-end events to know when a form submission ends.
@@ -142,4 +143,13 @@ export class WorkPackageRelationsComponent extends UntilDestroyedMixin implement
const url = this.PathHelper.workPackageUpdateCounterPath(this.workPackage.id!, 'relations');
void this.turboRequests.request(url);
}
+
+ private updateRelationsTab() {
+ void this.turboRequests.requestStream(this.turboFrameSrc)
+ .then((result) => {
+ renderStreamMessage(result.html);
+ });
+
+ this.updateCounter();
+ }
}