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(