From 20bff0e23d8018115ec95506a41ffb4aa321d6ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominic=20Br=C3=A4unlein?= Date: Wed, 30 Oct 2024 14:04:03 +0700 Subject: [PATCH] [#58271] Access token refresh results in error message in files tab https://community.openproject.org/work_packages/58271 --- .../work-package-single-view.base.ts | 10 ------ .../storages/storage/storage.component.ts | 36 +++++++++++-------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/work-package-single-view.base.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/work-package-single-view.base.ts index a89498031d98..89851497d456 100644 --- a/frontend/src/app/features/work-packages/routing/wp-view-base/work-package-single-view.base.ts +++ b/frontend/src/app/features/work-packages/routing/wp-view-base/work-package-single-view.base.ts @@ -188,16 +188,6 @@ export class WorkPackageSingleViewBase extends UntilDestroyedMixin { this.attachmentsResourceService.fetchCollection(this.workPackage.$links.attachments.href as string).subscribe(); } - if (this.workPackage.$links.fileLinks) { - this.fileLinkResourceService - .updateCollectionsForWorkPackage(this.workPackage.$links.fileLinks.href as string) - .pipe(take(1)) - .subscribe( - () => { /* Do nothing */ }, - (error:HttpErrorResponse) => { this.toastService.addError(error); }, - ); - } - // Listen to tab changes to update the tab label this.keepTab.observable .pipe(this.untilDestroyed()) diff --git a/frontend/src/app/shared/components/storages/storage/storage.component.ts b/frontend/src/app/shared/components/storages/storage/storage.component.ts index cc7ca74d77c2..dd967426192e 100644 --- a/frontend/src/app/shared/components/storages/storage/storage.component.ts +++ b/frontend/src/app/shared/components/storages/storage/storage.component.ts @@ -77,7 +77,7 @@ import { IHalResourceLink } from 'core-app/core/state/hal-resource'; import { LocationPickerModalComponent, } from 'core-app/shared/components/storages/location-picker-modal/location-picker-modal.component'; -import { ToastService } from 'core-app/shared/components/toaster/toast.service'; +import { IToast, ToastService } from 'core-app/shared/components/toaster/toast.service'; import { StorageFilesResourceService } from 'core-app/core/state/storage-files/storage-files.service'; import { IUploadFile, OpUploadService } from 'core-app/core/upload/upload.service'; import { IUploadLink } from 'core-app/core/state/storage-files/upload-link.model'; @@ -237,21 +237,27 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD ngOnInit():void { this.storage = this.storagesResourceService.requireEntity(this.projectStorage._links.storage.href); - this.fileLinks = this.collectionKey() - .pipe( - switchMap((key) => { - if (isNewResource(this.resource)) { - return this.fileLinkResourceService.collection(key); - } + this.fileLinks = this.storage.pipe( + take(1), + switchMap(() => + this.collectionKey().pipe( + switchMap((key) => { + if (isNewResource(this.resource)) { + return this.fileLinkResourceService.collection(key); + } + return this.fileLinkResourceService.requireCollection(key); + }), + tap((fileLinks) => { + if (isNewResource(this.resource)) { + this.resource.fileLinks = { elements: fileLinks.map((a) => a._links?.self) }; + } + }), + )), + ); - return this.fileLinkResourceService.requireCollection(key); - }), - tap((fileLinks) => { - if (isNewResource(this.resource)) { - this.resource.fileLinks = { elements: fileLinks.map((a) => a._links?.self) }; - } - }), - ); + this.fileLinks.subscribe({ error: (err:string | HttpErrorResponse | IToast) => + this.toastService.addError(err), + }); this.disabled = combineLatest([ this.storage,