@@ -8,7 +8,7 @@ import { Button } from 'primeng/button';
88import { filter , finalize , switchMap , take } from 'rxjs' ;
99
1010import { HttpEventType } from '@angular/common/http' ;
11- import { ChangeDetectionStrategy , Component , DestroyRef , effect , inject , input , output , signal } from '@angular/core' ;
11+ import { ChangeDetectionStrategy , Component , DestroyRef , inject , input , output , signal } from '@angular/core' ;
1212import { takeUntilDestroyed , toObservable } from '@angular/core/rxjs-interop' ;
1313
1414import { CreateFolderDialogComponent } from '@osf/features/files/components' ;
@@ -54,9 +54,8 @@ export class FilesControlComponent {
5454 projectId = input . required < string > ( ) ;
5555 provider = input . required < string > ( ) ;
5656 filesViewOnly = input < boolean > ( false ) ;
57- isDraftResource = input < boolean > ( false ) ;
5857 attachFile = output < FileModel > ( ) ;
59- removeFromAttachedFiles = output < FileModel > ( ) ;
58+ removeFromAttachedFiles = output < string > ( ) ;
6059 openFile = output < FileModel > ( ) ;
6160
6261 private readonly filesService = inject ( FilesService ) ;
@@ -72,7 +71,6 @@ export class FilesControlComponent {
7271 readonly progress = signal ( 0 ) ;
7372 readonly fileName = signal ( '' ) ;
7473 readonly dataLoaded = signal ( false ) ;
75- pageNumber = signal ( 1 ) ;
7674
7775 fileIsUploading = signal ( false ) ;
7876 filesSelection : FileModel [ ] = [ ] ;
@@ -89,31 +87,13 @@ export class FilesControlComponent {
8987 constructor ( ) {
9088 this . setupRootFoldersLoader ( ) ;
9189 this . setupCurrentFolderWatcher ( ) ;
92-
93- effect ( ( ) => {
94- const currentFolder = this . currentFolder ( ) ;
95- if ( currentFolder ) {
96- this . pageNumber . set ( 1 ) ;
97- this . updateFilesList ( ) ;
98- }
99- } ) ;
10090 }
10191
102- updateFilesList = ( ) : void => {
103- const currentFolder = this . currentFolder ( ) ;
104- const filesLink = currentFolder ?. links . filesLink ;
105- if ( filesLink ) {
106- this . actions . getFiles ( filesLink , this . pageNumber ( ) ) ;
107- }
108- } ;
109-
11092 deleteEntry ( file : FileModel ) : void {
11193 this . actions . deleteEntry ( file ?. links . delete ) . subscribe ( ( ) => {
11294 this . toastService . showSuccess ( 'files.dialogs.deleteFile.success' ) ;
113- this . updateFilesList ( ) ;
114- if ( this . isDraftResource ( ) ) {
115- this . removeFromAttachedFiles . emit ( file ) ;
116- }
95+ this . refreshFilesList ( ) ;
96+ this . removeFromAttachedFiles . emit ( file . id ) ;
11797 } ) ;
11898 }
11999
@@ -200,10 +180,6 @@ export class FilesControlComponent {
200180 this . filesSelection = [ ...new Set ( this . filesSelection ) ] ;
201181 }
202182
203- onRemoveFromAttachedFiles ( file : FileModel ) {
204- this . removeFromAttachedFiles . emit ( file ) ;
205- }
206-
207183 onLoadFiles ( event : { link : string ; page : number } ) {
208184 this . actions . getFiles ( event . link , event . page ) ;
209185 }
0 commit comments