fix: improve plugins functionality with server management
This commit is contained in:
@@ -81,6 +81,8 @@ The renderer sends structured command/query objects through the Electron preload
|
||||
|
||||
The Electron schema now normalises reaction rows and room channel/member rosters into separate SQLite tables instead of storing those arrays inline on the parent message or room rows. The renderer-facing API is unchanged: CQRS handlers rehydrate the same `Message` and `Room` payloads before returning them over IPC.
|
||||
|
||||
Electron room membership is user-scoped through `room_owners`, and messages carry `ownerUserId`. Auth setup writes the current user ID to the database before room loading, so `/search`, the server rail, and local history only hydrate rooms/messages owned by the active account. A room row can still hold shared server metadata for the same server ID, but each account has its own ownership edge and message history.
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant Eff as NgRx Effect
|
||||
|
||||
@@ -140,9 +140,11 @@ export class IncomingSignalingMessageHandler {
|
||||
}
|
||||
|
||||
for (const user of users) {
|
||||
if (!user.oderId) continue;
|
||||
if (!user.oderId)
|
||||
continue;
|
||||
|
||||
if (localOderId && user.oderId === localOderId) continue;
|
||||
if (localOderId && user.oderId === localOderId)
|
||||
continue;
|
||||
|
||||
this.clearUserJoinedFallbackOffer(user.oderId);
|
||||
|
||||
@@ -310,9 +312,11 @@ export class IncomingSignalingMessageHandler {
|
||||
const fromUserId = message.fromUserId;
|
||||
const sdp = message.payload?.sdp;
|
||||
|
||||
if (!fromUserId || !sdp) return;
|
||||
if (!fromUserId || !sdp)
|
||||
return;
|
||||
|
||||
if (fromUserId === this.dependencies.getLocalOderId()) return;
|
||||
if (fromUserId === this.dependencies.getLocalOderId())
|
||||
return;
|
||||
|
||||
this.clearUserJoinedFallbackOffer(fromUserId);
|
||||
this.nonInitiatorWaitStart.delete(fromUserId);
|
||||
@@ -332,9 +336,11 @@ export class IncomingSignalingMessageHandler {
|
||||
const fromUserId = message.fromUserId;
|
||||
const sdp = message.payload?.sdp;
|
||||
|
||||
if (!fromUserId || !sdp) return;
|
||||
if (!fromUserId || !sdp)
|
||||
return;
|
||||
|
||||
if (fromUserId === this.dependencies.getLocalOderId()) return;
|
||||
if (fromUserId === this.dependencies.getLocalOderId())
|
||||
return;
|
||||
|
||||
this.clearUserJoinedFallbackOffer(fromUserId);
|
||||
|
||||
@@ -346,9 +352,11 @@ export class IncomingSignalingMessageHandler {
|
||||
const fromUserId = message.fromUserId;
|
||||
const candidate = message.payload?.candidate;
|
||||
|
||||
if (!fromUserId || !candidate) return;
|
||||
if (!fromUserId || !candidate)
|
||||
return;
|
||||
|
||||
if (fromUserId === this.dependencies.getLocalOderId()) return;
|
||||
if (fromUserId === this.dependencies.getLocalOderId())
|
||||
return;
|
||||
|
||||
this.clearUserJoinedFallbackOffer(fromUserId);
|
||||
|
||||
@@ -507,15 +515,18 @@ export class IncomingSignalingMessageHandler {
|
||||
}
|
||||
|
||||
private shouldInitiatePeer(peerId: string, localOderId: string | null = this.dependencies.getLocalOderId()): boolean {
|
||||
if (!localOderId) return false;
|
||||
if (!localOderId)
|
||||
return false;
|
||||
|
||||
if (peerId === localOderId) return false;
|
||||
if (peerId === localOderId)
|
||||
return false;
|
||||
|
||||
return localOderId < peerId;
|
||||
}
|
||||
|
||||
private hasActivePeerConnection(peer: PeerData | undefined): boolean {
|
||||
if (!peer) return false;
|
||||
if (!peer)
|
||||
return false;
|
||||
|
||||
const connectionState = peer.connection?.connectionState;
|
||||
|
||||
@@ -523,11 +534,13 @@ export class IncomingSignalingMessageHandler {
|
||||
}
|
||||
|
||||
private isPeerConnectionNegotiating(peer: PeerData | undefined): boolean {
|
||||
if (!peer || this.hasActivePeerConnection(peer)) return false;
|
||||
if (!peer || this.hasActivePeerConnection(peer))
|
||||
return false;
|
||||
|
||||
const connectionState = peer.connection?.connectionState;
|
||||
|
||||
if (connectionState === 'closed' || connectionState === 'failed') return false;
|
||||
if (connectionState === 'closed' || connectionState === 'failed')
|
||||
return false;
|
||||
|
||||
const signalingState = peer.connection?.signalingState;
|
||||
const ageMs = Date.now() - peer.createdAt;
|
||||
@@ -535,11 +548,13 @@ export class IncomingSignalingMessageHandler {
|
||||
// If a local offer (or pranswer) has already been sent, the peer is actively
|
||||
// negotiating with the remote side. Use a much longer grace period so that
|
||||
// a slow signaling round-trip does not trigger a premature teardown.
|
||||
if (signalingState === 'have-local-offer' || signalingState === 'have-local-pranswer') return ageMs < PEER_NEGOTIATION_OFFER_SENT_GRACE_MS;
|
||||
if (signalingState === 'have-local-offer' || signalingState === 'have-local-pranswer')
|
||||
return ageMs < PEER_NEGOTIATION_OFFER_SENT_GRACE_MS;
|
||||
|
||||
// ICE negotiation in progress (offer/answer exchange already complete, candidates being checked).
|
||||
// TURN relay can take 5-15 s on high-latency networks, so use the same extended grace.
|
||||
if (connectionState === 'connecting') return ageMs < PEER_NEGOTIATION_OFFER_SENT_GRACE_MS;
|
||||
if (connectionState === 'connecting')
|
||||
return ageMs < PEER_NEGOTIATION_OFFER_SENT_GRACE_MS;
|
||||
|
||||
return ageMs < PEER_NEGOTIATION_GRACE_MS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user