From 8716739b5220d3481fa58e8705c0db905dba0705 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Wed, 13 Jul 2022 21:11:30 +0300 Subject: [PATCH 1/5] RED-3687 - WIP on removing subscriptions --- .../comments/comments.component.html | 63 +++++----- .../components/comments/comments.component.ts | 11 +- .../file-preview-screen.component.html | 20 +-- .../file-preview-screen.component.ts | 119 +++++++++--------- .../services/manual-redaction.service.ts | 2 +- .../red-ui/src/app/utils/context.component.ts | 41 ++++++ 6 files changed, 150 insertions(+), 106 deletions(-) create mode 100644 apps/red-ui/src/app/utils/context.component.ts diff --git a/apps/red-ui/src/app/modules/file-preview/components/comments/comments.component.html b/apps/red-ui/src/app/modules/file-preview/components/comments/comments.component.html index 764e2454f..37411ebe8 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/comments/comments.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/comments/comments.component.html @@ -1,39 +1,34 @@ - - -
-
-
- {{ comment.user | name }} - {{ comment.date | date: 'sophisticatedDate' }} -
- -
- -
+ +
+
+
+ {{ comment.user | name }} + {{ comment.date | date: 'sophisticatedDate' }}
-
{{ comment.text }}
+
+ +
- - +
{{ comment.text }}
+
+ + + +
- -
- - - diff --git a/apps/red-ui/src/app/modules/file-preview/components/comments/comments.component.ts b/apps/red-ui/src/app/modules/file-preview/components/comments/comments.component.ts index 214246329..f0eab09e1 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/comments/comments.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/comments/comments.component.ts @@ -1,14 +1,15 @@ -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, HostBinding, Input, OnChanges, ViewChild } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, HostBinding, Input, OnInit, ViewChild } from '@angular/core'; import { Dossier, File, IComment } from '@red/domain'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { UserService } from '@services/user.service'; import { PermissionsService } from '@services/permissions.service'; -import { AutoUnsubscribe, InputWithActionComponent, LoadingService, trackByFactory } from '@iqser/common-ui'; +import { InputWithActionComponent, LoadingService, trackByFactory } from '@iqser/common-ui'; import { firstValueFrom, Observable } from 'rxjs'; import { CommentingService } from '../../services/commenting.service'; import { tap } from 'rxjs/operators'; import { FilePreviewStateService } from '../../services/file-preview-state.service'; import { ManualRedactionService } from '../../services/manual-redaction.service'; +import { ContextComponent } from '@utils/context.component'; @Component({ selector: 'redaction-comments', @@ -16,7 +17,7 @@ import { ManualRedactionService } from '../../services/manual-redaction.service' styleUrls: ['./comments.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) -export class CommentsComponent extends AutoUnsubscribe implements OnChanges { +export class CommentsComponent extends ContextComponent implements OnInit { @Input() annotation: AnnotationWrapper; readonly trackBy = trackByFactory(); readonly file$: Observable; @@ -39,12 +40,14 @@ export class CommentsComponent extends AutoUnsubscribe implements OnChanges { this.dossier$ = _stateService.dossier$; } - ngOnChanges() { + ngOnInit() { this.hiddenComments$ = this._commentingService.isActive$(this.annotation.id).pipe( tap(active => { this._hidden = !active; }), ); + + super._initContext([{ file: this.file$ }, { dossier: this.dossier$ }, this.hiddenComments$]); } async addComment(value: string): Promise { diff --git a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.html b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.html index 19f0302e7..31f5076ab 100644 --- a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.html +++ b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.html @@ -1,22 +1,22 @@ - -
+ +