FRE-600: Fix code review blockers

- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-04-25 00:08:01 -04:00
parent 65b552bb08
commit 7c684a42cc
48450 changed files with 5679671 additions and 383 deletions

View File

@@ -130,27 +130,26 @@ export class WebRTCSignalingServer {
// Store the connection
if (!targetConnection.connections.has(sourcePeerId)) {
const conn = targetConnection.peer.connect(sourcePeerId);
const conn = targetConnection.peer.call(sourcePeerId, new MediaStream());
targetConnection.connections.set(sourcePeerId, conn);
// Handle connection events
conn.on('open', () => {
console.log(`Connection opened: ${targetPeerId} <-> ${sourcePeerId}`);
});
conn.on('data', (data: any) => {
// Handle data channel messages
console.log(`Data received: ${targetPeerId} from ${sourcePeerId}`, data);
});
conn.on('stream', (stream: MediaStream) => {
console.log(`Media stream received: ${targetPeerId} from ${sourcePeerId}`);
});
conn.on('close', () => {
console.log(`Connection closed: ${targetPeerId} <-> ${sourcePeerId}`);
});
conn.on('error', (error: Error) => {
console.error(`Connection error: ${targetPeerId} <-> ${sourcePeerId}`, error);
});
// Send accumulated ICE candidates
const accumulatedCandidates = targetConnection.iceCandidates.get(sourcePeerId) || [];
accumulatedCandidates.forEach(candidate => {
conn.send(JSON.stringify({
conn.dataChannel.send(JSON.stringify({
type: 'ice-candidate',
payload: candidate,
targetPeerId,
@@ -159,11 +158,14 @@ export class WebRTCSignalingServer {
}
// Forward offer to target peer
targetConnection.connections.get(sourcePeerId).send(JSON.stringify({
type: 'offer',
payload: offer,
targetPeerId: targetPeerId,
}));
const targetConn = targetConnection.connections.get(sourcePeerId);
if (targetConn) {
(targetConn as any).dataChannel.send(JSON.stringify({
type: 'offer',
payload: offer,
targetPeerId: targetPeerId,
}));
}
}
private handleAnswer(
@@ -191,21 +193,19 @@ export class WebRTCSignalingServer {
const targetConnection = this.peers.get(targetPeerId);
if (!targetConnection) {
// Store candidate for later delivery
if (!targetConnection?.iceCandidates.has(sourcePeerId)) {
targetConnection?.iceCandidates.set(sourcePeerId, []);
}
targetConnection?.iceCandidates.get(sourcePeerId)!.push(candidate);
return;
}
// Forward ICE candidate to target peer
if (targetConnection.connections.has(sourcePeerId)) {
targetConnection.connections.get(sourcePeerId).send(JSON.stringify({
type: 'ice-candidate',
payload: candidate,
targetPeerId: targetPeerId,
}));
const conn = targetConnection.connections.get(sourcePeerId);
if (conn) {
(conn as any).send(JSON.stringify({
type: 'ice-candidate',
payload: candidate,
targetPeerId: targetPeerId,
}));
}
}
}