feat(frontend): send initiator-online after sender rejoins with cached/long room ID

- Add forceInitiatorOnline flag to webrtcService.joinRoom
  - Trigger initiator-online for sender when joining with >=8-char IDs
This commit is contained in:
david_bai
2025-10-31 12:47:46 +08:00
parent 3d222fd316
commit 2f5ed92188
2 changed files with 19 additions and 3 deletions
+10 -1
View File
@@ -86,8 +86,17 @@ export function useRoomManager({
? shareRoomId
: roomId;
// If sender uses a long ID (e.g., cached UUID), proactively send
// "initiator-online" after join to trigger receivers' re-handshake.
const forceInitiatorOnline =
isSenderSide && typeof actualRoomId === "string" && actualRoomId.length >= 8;
// Directly call the service method without dependency injection
await webrtcService.joinRoom(actualRoomId, isSenderSide);
await webrtcService.joinRoom(
actualRoomId,
isSenderSide,
forceInitiatorOnline
);
putMessageInMs(
messages.text.ClipboardApp.joinRoom.successMsg,
+9 -2
View File
@@ -141,7 +141,11 @@ class WebRTCService {
}
// Business methods
public async joinRoom(roomId: string, isSender: boolean): Promise<void> {
public async joinRoom(
roomId: string,
isSender: boolean,
forceInitiatorOnline: boolean = false
): Promise<void> {
// Ensure clean state before joining
if (!isSender) {
// Force reset FileReceiver state to prevent "already in progress" errors
@@ -149,7 +153,10 @@ class WebRTCService {
}
const peer = isSender ? this.sender : this.receiver;
await peer.joinRoom(roomId, isSender);
// If sender is performing a manual reconnect with a cached/long ID,
// optionally send an "initiator-online" after successful join so receivers
// can reply with "recipient-ready" to re-establish P2P.
await peer.joinRoom(roomId, isSender, isSender && !!forceInitiatorOnline);
const setInRoom = isSender
? useFileTransferStore.getState().setIsSenderInRoom