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
[WiP] Reduce number of redraws for the WP timeline
Henriette Dinger70384a8d6c18
diff --git a/frontend/src/app/components/wp-table/timeline/cells/wp-timeline-cell-mouse-handler.ts b/frontend/src/app/components/wp-table/timeline/cells/wp-timeline-cell-mouse-handler.tsindex 24cb0d38cb7..95032048b3d 100644--- a/frontend/src/app/components/wp-table/timeline/cells/wp-timeline-cell-mouse-handler.ts+++ b/frontend/src/app/components/wp-table/timeline/cells/wp-timeline-cell-mouse-handler.ts@@ -231,7 +231,6 @@ export function registerWorkPackageMouseHandler(this:void,const stopAndRefresh = () => {renderInfo.change.clear();renderer.onMouseDownEnd(labels, renderInfo.change);- workPackageTimeline.refreshView();};// Persist the changesdiff --git a/frontend/src/app/components/wp-table/timeline/container/wp-timeline-container.directive.ts b/frontend/src/app/components/wp-table/timeline/container/wp-timeline-container.directive.tsindex 82e8a82fbd6..a6b509b0f11 100644--- a/frontend/src/app/components/wp-table/timeline/container/wp-timeline-container.directive.ts+++ b/frontend/src/app/components/wp-table/timeline/container/wp-timeline-container.directive.ts@@ -34,7 +34,7 @@ import {IsolatedQuerySpace} from "core-app/modules/work_packages/query-space/isoimport * as moment from 'moment';import {Moment} from 'moment';import {componentDestroyed, untilComponentDestroyed} from 'ng2-rx-componentdestroyed';-import {debounceTime, filter, map, takeUntil, withLatestFrom} from 'rxjs/operators';+import {debounceTime, distinctUntilChanged, filter, map, skip, take, takeUntil, withLatestFrom} from 'rxjs/operators';import {calculateDaySpan,getPixelPerDayForZoomLevel,@@ -59,6 +59,11 @@ import {debugLog, timeOutput} from "core-app/helpers/debug_output";import {RenderedWorkPackage} from "core-app/modules/work_packages/render-info/rendered-work-package.type";import {HalEventsService} from "core-app/modules/hal/services/hal-events.service";import {WorkPackageNotificationService} from "core-app/modules/work_packages/notifications/work-package-notification.service";+import {+ LoadingIndicatorService,+ withLoadingIndicator+} from "core-app/modules/common/loading-indicator/loading-indicator.service";+import {combineLatest} from "rxjs";@Component({selector: 'wp-timeline-container',@@ -104,6 +109,7 @@ export class WorkPackageTimelineTableController implements AfterViewInit, OnDestprivate wpRelations:WorkPackageRelationsService,private wpTableHierarchies:WorkPackageViewHierarchiesService,private halEvents:HalEventsService,+ private loadingIndicator:LoadingIndicatorService,readonly I18n:I18nService) {}@@ -121,57 +127,29 @@ export class WorkPackageTimelineTableController implements AfterViewInit, OnDest// Register this instance to the tablethis.wpTableDirective.registerTimeline(this, this.timelineBody[0]);- // Refresh on changes to work packages- this.updateOnWorkPackageChangesets();-- // Refresh timeline rendering callback- this.setupRefreshListener();-// Refresh on window resize eventswindow.addEventListener('wp-resize.timeline', () => this.refreshRequest.putValue(undefined));- // Refresh timeline view after table rendered- this.querySpace.rendered.values$()- .pipe(- takeUntil(this.querySpace.stopAllSubscriptions),- filter(() => this.initialized)- )- .subscribe((orderedRows) => {+ combineLatest([+ this.querySpace.rendered.values$(),+ this.refreshRequest.changes$(),+ this.wpTableTimeline.live$()+ ]).pipe(+ untilComponentDestroyed(this),+ takeUntil(this.querySpace.stopAllSubscriptions),+ filter(() => this.initialized && this.wpTableTimeline.isVisible)+ )+ .subscribe(([orderedRows, changes, timelineState]) => {// Remember all visible rows in their order of appearance.this.workPackageIdOrder = orderedRows.filter(row => !row.hidden);this.refreshView();});-- // Refresh timeline view when becoming visible- this.wpTableTimeline- .live$()- .pipe(- untilComponentDestroyed(this),- filter((timelineState:WorkPackageTimelineState) => timelineState.visible),- )- .subscribe((timelineState:WorkPackageTimelineState) => {- this.refreshRequest.putValue(undefined);- });- }-- private setupRefreshListener() {- this.refreshRequest- .changes$()- .pipe(- untilComponentDestroyed(this),- debounceTime(250)- )- .subscribe(() => this.refreshView());}ngOnDestroy():void {// empty}- workPackageInView(wpId:string):boolean {- return this.cellsRenderer.hasCell(wpId);- }-workPackageCells(wpId:string):WorkPackageTimelineCell[] {return this.cellsRenderer.getCellsFor(wpId);}@@ -208,6 +186,7 @@ export class WorkPackageTimelineTableController implements AfterViewInit, OnDest}refreshView() {+ console.log('START REFRESH VIEW');if (!this.wpTableTimeline.isVisible) {debugLog('refreshView() requested, but TL is invisible.');return;@@ -240,25 +219,9 @@ export class WorkPackageTimelineTableController implements AfterViewInit, OnDest// The header is the only one reliable, as it already has the final width.const currentWidth = this.$element.find(timelineHeaderSelector)[0].scrollWidth;this.outerContainer.width(currentWidth);- });- }- updateOnWorkPackageChangesets() {- this.states.workPackages.observeChange()- .pipe(- takeUntil(componentDestroyed(this)),- filter(() => this.initialized && this.wpTableTimeline.isVisible),- filter(([wpId, ]) => this.cellsRenderer.hasCell(wpId))- )- .subscribe(([wpId, ]) => {- const viewParamsChanged = this.calculateViewParams(this._viewParameters);- if (viewParamsChanged) {- this.refreshRequest.putValue(undefined);- } else {- // Refresh the single cell- this.cellsRenderer.refreshCellsFor(wpId);- }- });+ console.log('END REFRESH VIEW');+ });}startAddRelationPredecessor(start:WorkPackageResource) {