diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts index 113442f1..a144f052 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts @@ -265,6 +265,20 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { .subscribe(roomInfo => { this.clearView(); this.roomInfoSubject.next(roomInfo); + + if (!!this.roomInfoSubject.value && !!this.interval) { + clearInterval(this.interval); + this.interval = undefined; + } + + if ( + !!this.roomInfoSubject.value && + !!this.roomInfoSubject.value.isTimeRoom + ) { + this.interval = setInterval(() => { + this.store.dispatch(EventStore.infoIntervalClear({})); + }, 1000); + } }); this.userInfoListSubscription = this.store @@ -393,15 +407,6 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { } } }); - - if ( - !!this.roomInfoSubject.value && - !!this.roomInfoSubject.value.isTimeRoom - ) { - this.interval = setInterval(() => { - this.store.dispatch(EventStore.infoIntervalClear({})); - }, 1000); - } } ngOnDestroy(): void {