-
Notifications
You must be signed in to change notification settings - Fork 9
Refresh file listings on breadcrumb navigation after bitstream upload #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: clarin-v7
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -212,6 +212,27 @@ export class UploadBitstreamComponent implements OnInit, OnDestroy { | |||||||||||||||||||||||||||
| this.requestService.removeByHrefSubstring(href); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Clear cached requests for this item's bundles to ensure bundle resolution uses fresh data | ||||||||||||||||||||||||||||
| this.itemService.getBundlesEndpoint(this.itemId).pipe(take(1)).subscribe((href: string) => { | ||||||||||||||||||||||||||||
| this.requestService.removeByHrefSubstring(href); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Clear cached requests for this item to ensure breadcrumb navigation resolves a fresh item | ||||||||||||||||||||||||||||
| this.itemRD$.pipe( | ||||||||||||||||||||||||||||
| getFirstSucceededRemoteDataPayload(), | ||||||||||||||||||||||||||||
| take(1), | ||||||||||||||||||||||||||||
| ).subscribe((item: Item) => { | ||||||||||||||||||||||||||||
| this.requestService.removeByHrefSubstring(item._links.self.href); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Clear metadatabitstreams search cache used by preview and CLARIN files sections | ||||||||||||||||||||||||||||
| this.requestService.removeByHrefSubstring('/api/core/metadatabitstreams/search/byHandle'); | ||||||||||||||||||||||||||||
| if (item?.handle) { | ||||||||||||||||||||||||||||
| this.requestService.removeByHrefSubstring(`handle=${encodeURIComponent(item.handle)}`); | ||||||||||||||||||||||||||||
| this.requestService.removeByHrefSubstring(`handle=${item.handle}`); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| this.requestService.removeByHrefSubstring('fileGrpType=ORIGINAL'); | ||||||||||||||||||||||||||||
|
Comment on lines
+215
to
+233
|
||||||||||||||||||||||||||||
| this.requestService.removeByHrefSubstring('/api/core/metadatabitstreams/search/byHandle'); | |
| if (item?.handle) { | |
| this.requestService.removeByHrefSubstring(`handle=${encodeURIComponent(item.handle)}`); | |
| this.requestService.removeByHrefSubstring(`handle=${item.handle}`); | |
| } | |
| this.requestService.removeByHrefSubstring('fileGrpType=ORIGINAL'); | |
| if (item?.handle) { | |
| const byHandleBase = '/api/core/metadatabitstreams/search/byHandle'; | |
| const encodedHandle = encodeURIComponent(item.handle); | |
| // Invalidate cached metadatabitstreams byHandle searches for this item and ORIGINAL file group | |
| this.requestService.removeByHrefSubstring(`${byHandleBase}?handle=${encodedHandle}&fileGrpType=ORIGINAL`); | |
| this.requestService.removeByHrefSubstring(`${byHandleBase}?handle=${item.handle}&fileGrpType=ORIGINAL`); | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||
| import { Component, Input, OnInit } from '@angular/core'; | ||||||||||
| import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core'; | ||||||||||
| import { Item } from '../../core/shared/item.model'; | ||||||||||
| import { getAllSucceededRemoteListPayload, getFirstSucceededRemoteDataPayload } from '../../core/shared/operators'; | ||||||||||
| import { getItemPageRoute } from '../item-page-routing-paths'; | ||||||||||
|
|
@@ -7,14 +7,14 @@ import { RegistryService } from '../../core/registry/registry.service'; | |||||||||
| import { Router } from '@angular/router'; | ||||||||||
| import { HALEndpointService } from '../../core/shared/hal-endpoint.service'; | ||||||||||
| import { ConfigurationDataService } from '../../core/data/configuration-data.service'; | ||||||||||
| import { BehaviorSubject } from 'rxjs'; | ||||||||||
| import { BehaviorSubject, Subscription } from 'rxjs'; | ||||||||||
|
|
||||||||||
| @Component({ | ||||||||||
| selector: 'ds-clarin-files-section', | ||||||||||
| templateUrl: './clarin-files-section.component.html', | ||||||||||
| styleUrls: ['./clarin-files-section.component.scss'] | ||||||||||
| }) | ||||||||||
| export class ClarinFilesSectionComponent implements OnInit { | ||||||||||
| export class ClarinFilesSectionComponent implements OnInit, OnChanges, OnDestroy { | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * The item to display files for | ||||||||||
|
|
@@ -71,6 +71,9 @@ export class ClarinFilesSectionComponent implements OnInit { | |||||||||
| */ | ||||||||||
| downloadZipMinFileCount: BehaviorSubject<number> = new BehaviorSubject<number>(-1); | ||||||||||
|
|
||||||||||
| private currentItemHandle: string; | ||||||||||
| private filesSubscription?: Subscription; | ||||||||||
|
|
||||||||||
|
|
||||||||||
| constructor(protected registryService: RegistryService, | ||||||||||
| protected router: Router, | ||||||||||
|
|
@@ -79,15 +82,18 @@ export class ClarinFilesSectionComponent implements OnInit { | |||||||||
| } | ||||||||||
|
|
||||||||||
| ngOnInit(): void { | ||||||||||
| this.registryService | ||||||||||
| .getMetadataBitstream(this.itemHandle, 'ORIGINAL') | ||||||||||
| .pipe(getAllSucceededRemoteListPayload()) | ||||||||||
| .subscribe((data: MetadataBitstream[]) => { | ||||||||||
| this.listOfFiles.next(data); | ||||||||||
| this.generateCurlCommand(); | ||||||||||
| }); | ||||||||||
| this.totalFileSizes.next(Number(this.item.firstMetadataValue('local.files.size'))); | ||||||||||
| this.loadDownloadZipConfigProperties(); | ||||||||||
| this.refreshFromInputs(true); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| ngOnChanges(changes: SimpleChanges): void { | ||||||||||
| if (changes.item || changes.itemHandle) { | ||||||||||
|
||||||||||
| if (changes.item || changes.itemHandle) { | |
| const itemChanged = changes.item && !changes.item.firstChange; | |
| const itemHandleChanged = changes.itemHandle && !changes.itemHandle.firstChange; | |
| if (itemChanged || itemHandleChanged) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new cache invalidation behavior in onCompleteItem (metadatabitstreams byHandle + handle/fileGrpType staling) isn’t asserted in the spec; the current expectations only cover the bundle endpoint, bundles endpoint, and item self link. Add assertions for the additional removeByHrefSubstring/setStaleByHrefSubstring calls so regressions in the refresh behavior are caught.