Skip to content

Commit

Permalink
Replace instanceof LocalParticipant checks (#1051)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasIO authored Dec 14, 2024
1 parent ebe78fb commit 2073a8a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/observables/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ export function encryptionStatusObservable(room: Room, participant: Participant
),
map(([encrypted]) => encrypted),
startWith(
participant instanceof LocalParticipant
? participant.isE2EEEnabled
participant?.isLocal
? (participant as LocalParticipant).isE2EEEnabled
: !!participant?.isEncrypted,
),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/sorting/sort-participants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function sortParticipants(participants: Participant[]): Participant[] {
// joinedAt
return sortParticipantsByJoinedAt(a, b);
});
const localParticipant = sortedParticipants.find((p) => p instanceof LocalParticipant);
const localParticipant = sortedParticipants.find((p) => p.isLocal) as LocalParticipant;
if (localParticipant) {
const localIdx = sortedParticipants.indexOf(localParticipant);
if (localIdx >= 0) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/hooks/useIsEncrypted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function useIsEncrypted(participant?: Participant, options: UseIsEncrypte
const observer = React.useMemo(() => encryptionStatusObservable(room, p), [room, p]);
const isEncrypted = useObservableState(
observer,
p instanceof LocalParticipant ? p.isE2EEEnabled : !!p?.isEncrypted,
p.isLocal ? (p as LocalParticipant).isE2EEEnabled : !!p?.isEncrypted,
);
return isEncrypted;
}

0 comments on commit 2073a8a

Please sign in to comment.