diff --git a/lib/core/directives/version-compatibility.directive.spec.ts b/lib/core/directives/version-compatibility.directive.spec.ts index 7697e72db93..120c973a1d7 100644 --- a/lib/core/directives/version-compatibility.directive.spec.ts +++ b/lib/core/directives/version-compatibility.directive.spec.ts @@ -21,7 +21,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { TestBed, ComponentFixture } from '@angular/core/testing'; import { setupTestBed } from '../testing/setup-test-bed'; import { CoreTestingModule } from '../testing/core.testing.module'; -import { VersionCompatibilityService } from '@alfresco/adf-core'; +import { VersionCompatibilityService } from '../services/version-compatibility.service'; @Component({ template: ` @@ -63,8 +63,7 @@ describe('VersionCompatibilityDirective', () => { TranslateModule.forRoot(), CoreTestingModule ], - declarations: [TestComponent - ] + declarations: [TestComponent] }); beforeEach(() => { diff --git a/lib/core/directives/version-compatibility.directive.ts b/lib/core/directives/version-compatibility.directive.ts index 3b6e3d4039f..3d7cfd0a77a 100644 --- a/lib/core/directives/version-compatibility.directive.ts +++ b/lib/core/directives/version-compatibility.directive.ts @@ -17,6 +17,7 @@ import { Directive, Input, ViewContainerRef, TemplateRef } from '@angular/core'; import { VersionCompatibilityService } from '../services/version-compatibility.service'; +import { take } from 'rxjs/operators'; @Directive({ selector: '[adf-acs-version]' @@ -37,11 +38,10 @@ export class VersionCompatibilityDirective { } private validateAcsVersion(requiredVersion: string) { - this.versionCompatibilityService.acsVersionInitialized$.subscribe(() => { + this.versionCompatibilityService.acsVersionInitialized$.pipe(take(1)).subscribe(() => { + this.viewContainer.clear(); if (requiredVersion && this.versionCompatibilityService.isVersionSupported(requiredVersion)) { this.viewContainer.createEmbeddedView(this.templateRef); - } else { - this.viewContainer.clear(); } }); }