[ACA-4202] - caching with version number for the url (#6422)

* [ACA-4202] - caching with version number for the url

* [ACA-4202] - fixed image caching when file with the same name is versioned

Co-authored-by: Vito Albano <vitoalbano@vitoalbano-mbp-0120.local>
This commit is contained in:
Vito
2020-12-04 17:29:16 +00:00
committed by GitHub
parent 786984bfee
commit 5b603ee018
2 changed files with 25 additions and 1 deletions

View File

@@ -376,6 +376,26 @@ describe('ViewerComponent', () => {
expect(component.fileTitle).toBe('file2');
}));
it('should append version of the file to the file content URL', fakeAsync(() => {
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValue(
Promise.resolve(new NodeEntry({ entry: { name: 'file1', content: {}, properties: { 'cm:versionLabel' : '10'} } }))
);
spyOn(alfrescoApiService.versionsApi, 'getVersion').and.returnValue(Promise.resolve(undefined));
component.nodeId = 'id1';
component.urlFile = null;
component.displayName = null;
component.blobFile = null;
component.showViewer = true;
component.versionId = null;
component.ngOnChanges();
tick();
expect(component.fileTitle).toBe('file1');
expect(component.urlFileContent).toContain('/public/alfresco/versions/1/nodes/id1/content?attachment=false&10');
}));
it('should change display name every time node\`s version changes', fakeAsync(() => {
spyOn(alfrescoApiService.nodesApi, 'getNode').and.returnValue(
Promise.resolve(new NodeEntry({ entry: { name: 'node1', content: {} } }))

View File

@@ -391,9 +391,13 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
this.fileTitle = this.getDisplayName(versionData ? versionData.name : nodeData.name);
const currentFileVersion = this.nodeEntry?.entry?.properties && this.nodeEntry.entry.properties['cm:versionLabel'] ?
encodeURI(this.nodeEntry?.entry?.properties['cm:versionLabel']) : encodeURI('1.0');
this.urlFileContent = versionData ? this.apiService.contentApi.getVersionContentUrl(this.nodeId, versionData.id) :
this.apiService.contentApi.getContentUrl(this.nodeId);
this.urlFileContent = this.cacheBusterNumber ? this.urlFileContent + '&' + this.cacheBusterNumber : this.urlFileContent;
this.urlFileContent = this.cacheBusterNumber ? this.urlFileContent + '&' + currentFileVersion + '&' + this.cacheBusterNumber :
this.urlFileContent + '&' + currentFileVersion;
this.extension = this.getFileExtension(versionData ? versionData.name : nodeData.name);