From def707048819beb8cfd772e24fef99f88b436035 Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Thu, 10 Oct 2024 13:13:54 -0500 Subject: [PATCH] fix: server-side rendering compatibility --- projects/stream-chat-angular/src/lib/is-safari.ts | 5 ++--- .../src/lib/message-list/message-list.component.ts | 5 +++-- .../src/lib/voice-recorder/audio-recorder.service.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/projects/stream-chat-angular/src/lib/is-safari.ts b/projects/stream-chat-angular/src/lib/is-safari.ts index af3acb78..a1c129d0 100644 --- a/projects/stream-chat-angular/src/lib/is-safari.ts +++ b/projects/stream-chat-angular/src/lib/is-safari.ts @@ -1,3 +1,2 @@ -export const isSafari = /^((?!chrome|android).)*safari/i.test( - navigator.userAgent -); +export const isSafari = () => + /^((?!chrome|android).)*safari/i.test(navigator.userAgent); diff --git a/projects/stream-chat-angular/src/lib/message-list/message-list.component.ts b/projects/stream-chat-angular/src/lib/message-list/message-list.component.ts index 4021db2b..a8e7f409 100644 --- a/projects/stream-chat-angular/src/lib/message-list/message-list.component.ts +++ b/projects/stream-chat-angular/src/lib/message-list/message-list.component.ts @@ -152,6 +152,7 @@ export class MessageListComponent private forceRepaintSubject = new Subject(); private messageIdToAnchorTo?: string; private anchorMessageTopOffset?: number; + private isSafari = isSafari(); @HostBinding('class') private get class() { @@ -468,7 +469,7 @@ export class MessageListComponent scrollToBottom(): void { this.scrollContainer.nativeElement.scrollTop = this.scrollContainer.nativeElement.scrollHeight + 0.1; - if (isSafari) { + if (this.isSafari) { this.forceRepaintSubject.next(); } } @@ -609,7 +610,7 @@ export class MessageListComponent (messageToAlignTo?.getBoundingClientRect()?.top || 0) - (this.anchorMessageTopOffset || 0); this.anchorMessageTopOffset = undefined; - if (isSafari) { + if (this.isSafari) { this.forceRepaintSubject.next(); } } diff --git a/projects/stream-chat-angular/src/lib/voice-recorder/audio-recorder.service.ts b/projects/stream-chat-angular/src/lib/voice-recorder/audio-recorder.service.ts index ee6fa79d..c99538b1 100644 --- a/projects/stream-chat-angular/src/lib/voice-recorder/audio-recorder.service.ts +++ b/projects/stream-chat-angular/src/lib/voice-recorder/audio-recorder.service.ts @@ -22,7 +22,7 @@ export class AudioRecorderService extends MultimediaRecorder< * - For all other browsers we use audio/webm (which is then transcoded to wav) */ config: MediaRecorderConfig = { - mimeType: isSafari ? 'audio/mp4;codecs=mp4a.40.2' : 'audio/webm', + mimeType: isSafari() ? 'audio/mp4;codecs=mp4a.40.2' : 'audio/webm', }; constructor(