From 378d0b2a29f2076450d5a10b5e06e29436192c7c Mon Sep 17 00:00:00 2001 From: Andrea Barbasso <´andrea.barbasso@4science.com´> Date: Wed, 14 Feb 2024 11:47:03 +0100 Subject: [PATCH] Revert "[DSC-1111] fix deletion - upload - deletion flow" This reverts commit 618151faaf88ea8366c4243dab33a628582cc98c. --- src/app/core/data/comcol-data.service.ts | 2 +- .../comcol-form/comcol-form.component.ts | 26 ++++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/app/core/data/comcol-data.service.ts b/src/app/core/data/comcol-data.service.ts index 6a0cb16c06..abc9046cd0 100644 --- a/src/app/core/data/comcol-data.service.ts +++ b/src/app/core/data/comcol-data.service.ts @@ -1,4 +1,4 @@ -import { distinctUntilChanged, filter, map, switchMap, take, tap } from 'rxjs/operators'; +import { distinctUntilChanged, filter, map, switchMap, take } from 'rxjs/operators'; import { combineLatest as observableCombineLatest, Observable } from 'rxjs'; import { hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util'; import { ObjectCacheService } from '../cache/object-cache.service'; diff --git a/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.ts b/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.ts index 81990e5c0b..bb4ba7cef0 100644 --- a/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.ts +++ b/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.ts @@ -3,7 +3,7 @@ import { UntypedFormGroup } from '@angular/forms'; import { DynamicFormControlModel, DynamicFormService, DynamicInputModel } from '@ng-dynamic-forms/core'; import { TranslateService } from '@ngx-translate/core'; import { FileUploader } from 'ng2-file-upload'; -import { BehaviorSubject, combineLatest as observableCombineLatest, concatMap, Subscription } from 'rxjs'; +import { BehaviorSubject, combineLatest as observableCombineLatest, Subscription } from 'rxjs'; import { AuthService } from '../../../../core/auth/auth.service'; import { ObjectCacheService } from '../../../../core/cache/object-cache.service'; import { ComColDataService } from '../../../../core/data/comcol-data.service'; @@ -24,7 +24,6 @@ import { NoContent } from '../../../../core/shared/NoContent.model'; import { getFirstCompletedRemoteData } from '../../../../core/shared/operators'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { followLink } from '../../../utils/follow-link-config.model'; -import { map } from 'rxjs/operators'; /** * A form for creating and editing Communities or Collections @@ -235,11 +234,11 @@ export class ComColFormComponent implements On * Helper method that confirms the deletion of the logo and handles possible errors */ confirmLogoDelete(removeLogo: any) { + //this.refreshCache() this.modalService.open(removeLogo).result.then((result) => { if (result === 'delete') { if (hasValue(this.dso.id) && hasValue(this.dso._links.logo)) { - this.refreshCache().pipe( - concatMap(() => this.dsoService.deleteLogo(this.dso)), + this.dsoService.deleteLogo(this.dso).pipe( getFirstCompletedRemoteData() ).subscribe((response: RemoteData) => { if (response.hasSucceeded) { @@ -273,16 +272,13 @@ export class ComColFormComponent implements On private refreshCache() { this.requestService.removeByHrefSubstring(this.dso._links.self.href); this.objectCache.remove(this.dso._links.self.href); - return this.dsoService.findById(this.dso.id, false, true, followLink('logo')).pipe( - getFirstCompletedRemoteData(), - map((rd: RemoteData) => { - if (rd.hasSucceeded) { - this.dso = rd.payload; - return true; - } - return false; - }) - ); + this.dsoService.findById(this.dso.id, false, true, followLink('logo')).pipe( + getFirstCompletedRemoteData() + ).subscribe((rd: RemoteData) => { + if (rd.hasSucceeded) { + this.dso = rd.payload; + } + }); } /** @@ -290,7 +286,7 @@ export class ComColFormComponent implements On */ public onCompleteItem() { if (hasValue(this.dso.id)) { - this.subs.push(this.refreshCache().subscribe()); + this.refreshCache(); } this.notificationsService.success(null, this.translate.get(this.type.value + '.edit.logo.notifications.add.success')); // this.finish.emit();