Skip to content

Commit 333808e

Browse files
committed
fix: turn off image load optimization if DOM tree is customized
1 parent f664cfb commit 333808e

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

projects/stream-chat-angular/src/lib/avatar-placeholder/avatar-placeholder.component.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
AvatarType,
1616
DefaultStreamChatGenerics,
1717
} from '../types';
18+
import { ThemeService } from '../theme.service';
1819

1920
/**
2021
* The `AvatarPlaceholder` component displays the [default avatar](./AvatarComponent.mdx) unless a [custom template](../services/CustomTemplatesService.mdx) is provided. This component is used by the SDK internally, you likely won't need to use it.
@@ -81,22 +82,25 @@ export class AvatarPlaceholderComponent
8182
constructor(
8283
public customTemplatesService: CustomTemplatesService,
8384
private hostElement: ElementRef<HTMLElement>,
84-
private cdRef: ChangeDetectorRef
85+
private cdRef: ChangeDetectorRef,
86+
private themeService: ThemeService
8587
) {}
8688

8789
ngAfterViewInit(): void {
88-
if (this.location !== 'message-sender') {
89-
this.isVisible = true;
90-
this.cdRef.detectChanges();
91-
return;
92-
}
93-
this.checkIfVisible();
9490
const elementToObserve =
9591
this.hostElement.nativeElement.parentElement?.parentElement
9692
?.parentElement;
97-
if (!elementToObserve) {
93+
if (
94+
this.location !== 'message-sender' ||
95+
!elementToObserve ||
96+
!elementToObserve.classList.contains('str-chat__li') ||
97+
this.themeService.themeVersion === '1'
98+
) {
99+
this.isVisible = true;
100+
this.cdRef.detectChanges();
98101
return;
99102
}
103+
this.checkIfVisible();
100104
this.mutationObserver = new MutationObserver(() => {
101105
this.checkIfVisible();
102106
});

0 commit comments

Comments
 (0)