Skip to content
Snippets Groups Projects
Commit a2d4e8b3 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6620 fix observable subscription

parent 41d0df88
No related branches found
No related tags found
No related merge requests found
......@@ -100,7 +100,8 @@ describe('PostfachMailFormservice', () => {
it('should init mail body with signatur', () => {
formService.initMailBody();
const mailBodyValue = formService.form.get(PostfachMailFormservice.FIELD_MAIL_BODY)?.value;
const mailBodyValue = formService.form.get(PostfachMailFormservice.FIELD_MAIL_BODY).value;
expect(mailBodyValue).toBe(postfachSettings.signatur);
});
});
......
......@@ -32,7 +32,7 @@ import {
UntypedFormGroup,
} from '@angular/forms';
import { ReplyOption } from 'libs/postfach-shared/src/lib/postfach.model';
import { Observable, take } from 'rxjs';
import { Observable, Subscription } from 'rxjs';
@Injectable()
export class PostfachMailFormservice extends AbstractFormService {
......@@ -43,6 +43,8 @@ export class PostfachMailFormservice extends AbstractFormService {
static readonly FIELD_REPLY_OPTION = 'replyOption';
static readonly FIELD_ATTACHMENTS = 'attachments';
private loadPostfachSettingsSubscription: Subscription;
constructor(
formBuilder: UntypedFormBuilder,
private postfachService: PostfachService,
......@@ -61,12 +63,12 @@ export class PostfachMailFormservice extends AbstractFormService {
}
public initMailBody(): void {
this.postfachService
this.loadPostfachSettingsSubscription = this.postfachService
.getSettings()
.pipe(take(1))
.subscribe((settings: PostfachSettings) =>
this.form.get(PostfachMailFormservice.FIELD_MAIL_BODY)?.setValue(settings.signatur),
);
.subscribe((settings: PostfachSettings) => {
this.form.get(PostfachMailFormservice.FIELD_MAIL_BODY)?.setValue(settings.signatur);
this.loadPostfachSettingsSubscription.unsubscribe();
});
}
protected getPathPrefix(): string {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment