Skip to content

Commit

Permalink
cancel sub on destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Dec 19, 2024
1 parent 955c663 commit 20f2ca4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/reactions/ReactionsReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
EventType,
RoomEvent as MatrixRoomEvent,
} from "matrix-js-sdk/src/matrix";
import { BehaviorSubject, delay } from "rxjs";
import { BehaviorSubject, delay, Subscription } from "rxjs";

Check failure on line 21 in src/reactions/ReactionsReader.ts

View workflow job for this annotation

GitHub Actions / Lint, format & type check

Imports "Subscription" are only used as type

import {
ElementCallReactionEventType,
Expand Down Expand Up @@ -54,9 +54,11 @@ export class ReactionsReader {
*/
public readonly reactions$ = this.reactionsSubject$.asObservable();

private readonly reactionsSub: Subscription;

public constructor(private readonly rtcSession: MatrixRTCSession) {
// Hide reactions after a given time.
this.reactionsSubject$
this.reactionsSub = this.reactionsSubject$
.pipe(delay(REACTION_ACTIVE_TIME_MS))
.subscribe((reactions) => {
const date = new Date();
Expand Down Expand Up @@ -332,5 +334,6 @@ export class ReactionsReader {
MatrixRoomEvent.LocalEchoUpdated,
this.handleReactionEvent,
);
this.reactionsSub.unsubscribe();
}
}

0 comments on commit 20f2ca4

Please sign in to comment.