cancel sub on destroy

This commit is contained in:
Half-Shot
2024-12-19 15:46:07 +00:00
parent 955c663bc5
commit 20f2ca4afe

View File

@@ -18,7 +18,7 @@ import {
EventType, EventType,
RoomEvent as MatrixRoomEvent, RoomEvent as MatrixRoomEvent,
} from "matrix-js-sdk/src/matrix"; } from "matrix-js-sdk/src/matrix";
import { BehaviorSubject, delay } from "rxjs"; import { BehaviorSubject, delay, Subscription } from "rxjs";
import { import {
ElementCallReactionEventType, ElementCallReactionEventType,
@@ -54,9 +54,11 @@ export class ReactionsReader {
*/ */
public readonly reactions$ = this.reactionsSubject$.asObservable(); public readonly reactions$ = this.reactionsSubject$.asObservable();
private readonly reactionsSub: Subscription;
public constructor(private readonly rtcSession: MatrixRTCSession) { public constructor(private readonly rtcSession: MatrixRTCSession) {
// Hide reactions after a given time. // Hide reactions after a given time.
this.reactionsSubject$ this.reactionsSub = this.reactionsSubject$
.pipe(delay(REACTION_ACTIVE_TIME_MS)) .pipe(delay(REACTION_ACTIVE_TIME_MS))
.subscribe((reactions) => { .subscribe((reactions) => {
const date = new Date(); const date = new Date();
@@ -332,5 +334,6 @@ export class ReactionsReader {
MatrixRoomEvent.LocalEchoUpdated, MatrixRoomEvent.LocalEchoUpdated,
this.handleReactionEvent, this.handleReactionEvent,
); );
this.reactionsSub.unsubscribe();
} }
} }