[TLC-674] Properly test for existence of duplicates section

This commit is contained in:
Kim Shepherd
2024-02-29 11:06:03 +13:00
parent e76b6c962c
commit 1e36a10dd5
3 changed files with 2 additions and 12 deletions

View File

@@ -76,8 +76,6 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen
*/
showThumbnails: boolean;
enableDetectDuplicates$: Observable<any>;
constructor(
protected linkService: LinkService,
protected truncatableService: TruncatableService,
@@ -101,14 +99,6 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen
followLink('submitter')
), followLink('action'));
// Get configuration for duplicate detection feature
this.enableDetectDuplicates$ = this.configService.findByPropertyName('duplicate.enable').pipe(
getFirstCompletedRemoteData(),
map((rd: RemoteData<ConfigurationProperty>) => {
return (rd.hasSucceeded && rd.payload && rd.payload.values[0] === 'true');
})
);
(this.dso.workflowitem as Observable<RemoteData<WorkflowItem>>).pipe(
getFirstCompletedRemoteData(),
mergeMap((wfiRD: RemoteData<WorkflowItem>) => {

View File

@@ -449,7 +449,7 @@ export class SubmissionObjectEffects {
// or if configuration overrides this behaviour
if (!alwaysDisplayDuplicates()) {
const duplicatesSectionId = findKey(currentState.sections, (section) => section.sectionType === SectionsType.Duplicates);
if (isNotUndefined(duplicatesSectionId) && isEmpty((sections[duplicatesSectionId] as WorkspaceitemSectionDuplicatesObject).potentialDuplicates)) {
if (isNotUndefined(duplicatesSectionId) && sections.hasOwnProperty(duplicatesSectionId) && isEmpty((sections[duplicatesSectionId] as WorkspaceitemSectionDuplicatesObject).potentialDuplicates)) {
mappedActions.push(new CleanDuplicateDetectionAction(submissionId));
}
}

View File

@@ -862,7 +862,7 @@ function deleteFile(state: SubmissionObjectState, action: DeleteUploadedFileActi
}
function cleanDuplicateDetectionSection(state: SubmissionObjectState, action: CleanDuplicateDetectionAction): SubmissionObjectState {
if (isNotEmpty(state[ action.payload.submissionId ])) {
if (isNotEmpty(state[ action.payload.submissionId ]) && state[action.payload.submissionId].sections.hasOwnProperty('duplicates')) {
return Object.assign({}, state, {
[ action.payload.submissionId ]: Object.assign({}, state[ action.payload.submissionId ], {
sections: Object.assign({}, state[ action.payload.submissionId ].sections, {