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
[#43696] moved error handling and action to subscribe
Eric Schubert4879c47566d1
diff --git a/frontend/src/app/core/state/file-links/file-links.service.ts b/frontend/src/app/core/state/file-links/file-links.service.tsindex 09354a7c146..5d6edbdbea5 100644--- a/frontend/src/app/core/state/file-links/file-links.service.ts+++ b/frontend/src/app/core/state/file-links/file-links.service.ts@@ -31,7 +31,6 @@ import { Injectable } from '@angular/core';import { HttpHeaders } from '@angular/common/http';import { from } from 'rxjs';import {- catchError,groupBy,mergeMap,reduce,@@ -71,17 +70,16 @@ export class FileLinksResourceService extends ResourceCollectionService<IFileLinreturn acc;}, seed));}),- catchError((error) => {- this.toastService.addError(error);- throw error;- }),)- .subscribe((fileLinkCollections) => {- const storageId = idFromLink(fileLinkCollections.storage);- const collectionKey = `${fileLinksSelfLink}?filters=[{"storage":{"operator":"=","values":["${storageId}"]}}]`;- const collection = { _embedded: { elements: fileLinkCollections.fileLinks } } as IHALCollection<IFileLink>;- insertCollectionIntoState(this.store, collection, collectionKey);- });+ .subscribe(+ (fileLinkCollections) => {+ const storageId = idFromLink(fileLinkCollections.storage);+ const collectionKey = `${fileLinksSelfLink}?filters=[{"storage":{"operator":"=","values":["${storageId}"]}}]`;+ const collection = { _embedded: { elements: fileLinkCollections.fileLinks } } as IHALCollection<IFileLink>;+ insertCollectionIntoState(this.store, collection, collectionKey);+ },+ this.toastAndThrow.bind(this),+ );}protected createStore():CollectionStore<IFileLink> {@@ -96,13 +94,10 @@ export class FileLinksResourceService extends ResourceCollectionService<IFileLinconst headers = new HttpHeaders({ 'Content-Type': 'application/json' });this.http.delete<void>(fileLink._links.delete.href, { withCredentials: true, headers })- .pipe(- catchError((error) => {- this.toastService.addError(error);- throw error;- }),- )- .subscribe(() => removeEntityFromCollectionAndState(this.store, fileLink.id, collectionKey));+ .subscribe(+ () => removeEntityFromCollectionAndState(this.store, fileLink.id, collectionKey),+ this.toastAndThrow.bind(this),+ );}addFileLinks(collectionKey:string, addFileLinksHref:string, storage:IHalResourceLink, filesToLink:IStorageFile[]):void {@@ -122,33 +117,37 @@ export class FileLinksResourceService extends ResourceCollectionService<IFileLinthis.http.post<IHALCollection<IFileLink>>(addFileLinksHref, { _type: 'Collection', _embedded: { elements } })- .pipe(- tap((collection) => {+ .subscribe(+ (collection) => {applyTransaction(() => {const newFileLinks = collection._embedded.elements;this.store.add(newFileLinks);- this.store.update(({ collections }) => (- {- collections: {- ...collections,- [collectionKey]: {- ...collections[collectionKey],- ids: (collections[collectionKey]?.ids || []).concat(newFileLinks.map((link) => link.id)),+ this.store.update(+ ({ collections }) => (+ {+ collections: {+ ...collections,+ [collectionKey]: {+ ...collections[collectionKey],+ ids: (collections[collectionKey]?.ids || []).concat(newFileLinks.map((link) => link.id)),+ },},- },- }- ));+ }+ ),+ );});- }),- catchError((error) => {- this.toastService.addError(error);- throw error;- }),- )- .subscribe();+ },+ this.toastAndThrow.bind(this),+ );}protected basePath():string {return this.apiV3Service.file_links.path;}++ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ private toastAndThrow(error:any):void {+ this.toastService.addError(error);+ throw error;+ }}