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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
update count after each update
Behrokh Satarnejad166fa9ef85fe
diff --git a/frontend/src/app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-relations-count.function.ts b/frontend/src/app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-relations-count.function.tsindex 7977fbafd24..ef5764f7364 100644--- a/frontend/src/app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-relations-count.function.ts+++ b/frontend/src/app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-relations-count.function.ts@@ -1,24 +1,29 @@import { Injector } from '@angular/core';-import { Observable, from } from 'rxjs';-import { map } from 'rxjs/operators';+import { Observable, combineLatest, from, Subject } from 'rxjs';+import { map, switchMap, startWith } from 'rxjs/operators';import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service';import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';+import { WorkPackageRelationsService } from 'core-app/features/work-packages/components/wp-relations/wp-relations.service';export function workPackageRelationsCount(workPackage:WorkPackageResource,injector:Injector,):Observable<number> {- const PathHelper = injector.get(PathHelperService);- const turboRequests= injector.get(TurboRequestsService);+ const pathHelper = injector.get(PathHelperService);+ const turboRequests = injector.get(TurboRequestsService);+ const wpRelations = injector.get(WorkPackageRelationsService);const wpId = workPackage.id!.toString();- const url = PathHelper.workPackageGetCounterPath(wpId.toString());- const turbo= turboRequests.request(url);- const observable = from(turbo);- return observable.pipe(- map((response) => {- return parseInt(response.html, 10);- }),+ const url = pathHelper.workPackageGetCounterPath(wpId.toString());+ const updateTrigger$ = new Subject<void>();++ // Listen for relation state changes+ const relationsState$ = wpRelations.state(wpId).values$().pipe(startWith(null));++ // Trigger Turbo request whenever the state changes or manually triggered+ return combineLatest([relationsState$, updateTrigger$.pipe(startWith(null))]).pipe(+ switchMap(() => from(turboRequests.request(url))),+ map((response) => parseInt(response.html, 10)),);}