Fix duplicate notifications

This commit is contained in:
Yura Bondarenko
2021-06-18 13:59:39 +02:00
parent a3ba4e59b3
commit 7670ba8a43
2 changed files with 15 additions and 13 deletions

View File

@@ -2,7 +2,7 @@ import { Component, Input, OnChanges } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Observable, of as observableOf, Subscription } from 'rxjs';
import { first } from 'rxjs/operators';
import { first, take } from 'rxjs/operators';
import { SectionsService } from '../../sections/sections.service';
import { hasValue, isEmpty, isNotEmpty } from '../../../shared/empty.util';
@@ -131,7 +131,9 @@ export class SubmissionUploadFilesComponent implements OnChanges {
.forEach((sectionId) => {
const sectionData = normalizeSectionData(sections[sectionId]);
const sectionErrors = errorsList[sectionId];
this.sectionService.isSectionType(this.submissionId, sectionId, SectionsType.Upload).subscribe((isUpload) => {
this.sectionService.isSectionType(this.submissionId, sectionId, SectionsType.Upload)
.pipe(take(1))
.subscribe((isUpload) => {
if (isUpload) {
// Look for errors on upload
if ((isEmpty(sectionErrors))) {

View File

@@ -338,8 +338,8 @@ export class SectionsService {
return this.store.select(submissionObjectFromIdSelector(submissionId)).pipe(
filter((submissionState: SubmissionObjectEntry) => isNotUndefined(submissionState)),
map((submissionState: SubmissionObjectEntry) => {
return isNotUndefined(submissionState.sections) && isNotUndefined(submissionState.sections[sectionId]
&& submissionState.sections[sectionId].sectionType === sectionType );
return isNotUndefined(submissionState.sections) && isNotUndefined(submissionState.sections[sectionId])
&& submissionState.sections[sectionId].sectionType === sectionType;
}),
distinctUntilChanged());
}