diff --git a/src/main/webapp/app/shared/link-preview/components/link-preview-container/link-preview-container.component.ts b/src/main/webapp/app/shared/link-preview/components/link-preview-container/link-preview-container.component.ts index 2ad18852a3bd..1349476f4d0c 100644 --- a/src/main/webapp/app/shared/link-preview/components/link-preview-container/link-preview-container.component.ts +++ b/src/main/webapp/app/shared/link-preview/components/link-preview-container/link-preview-container.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, OnChanges, OnInit, computed, inject, input, signal } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnChanges, OnInit, inject, input, signal } from '@angular/core'; import { LinkPreview, LinkPreviewService } from 'app/shared/link-preview/services/link-preview.service'; import { Link, LinkifyService } from 'app/shared/link-preview/services/linkify.service'; import { User } from 'app/core/user/user.model'; @@ -20,7 +20,6 @@ export class LinkPreviewContainerComponent implements OnInit, OnChanges { readonly isEdited = input(); readonly isReply = input(); - readonly dataSafe = computed(() => this.data() ?? ''); readonly linkPreviews = signal([]); readonly hasError = signal(false); readonly loaded = signal(false); @@ -43,7 +42,7 @@ export class LinkPreviewContainerComponent implements OnInit, OnChanges { } private findPreviews() { - const links: Link[] = this.linkifyService.find(this.dataSafe()); + const links: Link[] = this.linkifyService.find(this.data() ?? ''); // TODO: The limit of 5 link previews should be configurable (maybe in course level) links .filter((link) => !link.isLinkPreviewRemoved) diff --git a/src/test/javascript/spec/component/link-preview/link-preview-container.component.spec.ts b/src/test/javascript/spec/component/link-preview/link-preview-container.component.spec.ts index 6491c4e3341d..534aaad61e6f 100644 --- a/src/test/javascript/spec/component/link-preview/link-preview-container.component.spec.ts +++ b/src/test/javascript/spec/component/link-preview/link-preview-container.component.spec.ts @@ -52,7 +52,7 @@ describe('LinkPreviewContainerComponent', () => { component.ngOnInit(); - expect(linkifyServiceSpy).toHaveBeenCalledWith(component.dataSafe()); + expect(linkifyServiceSpy).toHaveBeenCalledWith(component.data()); expect(linkPreviewServiceSpy).toHaveBeenCalledTimes(2); expect(linkPreviewServiceSpy).toHaveBeenCalledWith('https://example.com/link1'); expect(linkPreviewServiceSpy).toHaveBeenCalledWith('https://example.com/link2'); @@ -81,7 +81,7 @@ describe('LinkPreviewContainerComponent', () => { component.ngOnInit(); - expect(linkifyServiceSpy).toHaveBeenCalledWith(component.dataSafe()); + expect(linkifyServiceSpy).toHaveBeenCalledWith(component.data()); expect(linkPreviewServiceSpy).toHaveBeenCalledOnce(); expect(linkPreviewServiceSpy).toHaveBeenCalledWith('https://example.com/link1'); expect(component.linkPreviews()).toHaveLength(1);