This commit is contained in:
2026-03-25 20:22:28 +01:00
parent f13c04e809
commit 24bf3e38a7
3 changed files with 411 additions and 397 deletions

View File

@@ -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);
});