cleanup
This commit is contained in:
@@ -55,7 +55,7 @@ export class ChatPageComponent implements OnDestroy {
|
||||
private resolveDictationCompletion: (() => void) | null = null;
|
||||
private dictationApplyToken = 0;
|
||||
private lastConversationSnapshot: { peerId: string; length: number; lastEntryId: string | null } | null = null;
|
||||
private lastAutoConnectSnapshot: { peerId: string; hasLivePeer: boolean } | null = null;
|
||||
private lastAutoConnectedPeerId: string | null = null;
|
||||
@ViewChild('callAudioElement')
|
||||
set callAudioElementRef(value: ElementRef<HTMLAudioElement> | undefined) {
|
||||
this.callAudioElement = value;
|
||||
@@ -312,24 +312,26 @@ export class ChatPageComponent implements OnDestroy {
|
||||
effect(() => {
|
||||
const peerId = this.peerId();
|
||||
const hasLivePeer = !!this.peer();
|
||||
const previousSnapshot = this.lastAutoConnectSnapshot;
|
||||
|
||||
if (!peerId) {
|
||||
this.lastAutoConnectSnapshot = null;
|
||||
this.lastAutoConnectedPeerId = null;
|
||||
return;
|
||||
}
|
||||
|
||||
this.lastAutoConnectSnapshot = { peerId, hasLivePeer };
|
||||
this.session.selectPeer(peerId);
|
||||
|
||||
if (!hasLivePeer) {
|
||||
if (this.lastAutoConnectedPeerId === peerId) {
|
||||
this.lastAutoConnectedPeerId = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (previousSnapshot?.peerId === peerId && previousSnapshot.hasLivePeer) {
|
||||
if (this.lastAutoConnectedPeerId === peerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.lastAutoConnectedPeerId = peerId;
|
||||
void this.session.connectToPeer(peerId);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user