Skip to content

Commit

Permalink
[TLC-674] Properly test for existence of duplicates section
Browse files Browse the repository at this point in the history
  • Loading branch information
kshepherd committed Mar 3, 2024
1 parent e76b6c9 commit 1e36a10
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ export class PoolSearchResultListElementComponent extends SearchResultListElemen
*/
showThumbnails: boolean;

enableDetectDuplicates$: Observable<any>;

constructor(
protected linkService: LinkService,
protected truncatableService: TruncatableService,
Expand All @@ -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>) => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/submission/objects/submission-objects.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/submission/objects/submission-objects.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit 1e36a10

Please sign in to comment.