fix:Fix the issue of failing to join room with simple IDs

fix:Fix the issue of failing to join room with simple IDs
This commit is contained in:
david_bai
2025-08-31 23:55:52 +08:00
parent 0bcd2c0f97
commit a82ca50ee9
2 changed files with 8 additions and 16 deletions
@@ -106,14 +106,16 @@ export function SendTabPanel({
const { fetchRoom } = await import("@/app/config/api");
const simpleRoomId = await fetchRoom();
if (simpleRoomId) {
// Do not call processRoomIdInput, don't know why the validation will fail
// Instead, directly set the input and room ID
// fetchRoom() already created the room, so set it as initial room ID
// This prevents joinRoom() from trying to create it again
setInputFieldValue(simpleRoomId);
// Also update the store directly since this room was just created
const { useFileTransferStore } = await import(
"@/stores/fileTransferStore"
);
useFileTransferStore.getState().setShareRoomId(simpleRoomId);
const store = useFileTransferStore.getState();
store.setShareRoomId(simpleRoomId);
// IMPORTANT: Set as initial room ID to prevent duplicate creation
store.setInitShareRoomId(simpleRoomId);
} else {
processRoomIdInput(crypto.randomUUID());
}
+2 -12
View File
@@ -215,29 +215,19 @@ export function useRoomManager({
}, [messages, putMessageInMs, resetSenderAppState]);
// Room ID input processing
const processRoomIdInput = useCallback(
const processRoomIdInput = useCallback(
debounce(async (input: string) => {
console.log("🔍 processRoomIdInput called with:", input);
if (!input.trim() || !messages) {
console.log("❌ Input empty or no messages, returning");
return;
}
if (!input.trim() || !messages) return;
try {
console.log("🌐 Calling checkRoom API for:", input);
const isValid = await checkRoom(input);
console.log("📋 checkRoom result:", isValid, "for input:", input);
if (isValid) {
console.log("✅ Room is valid, setting shareRoomId to:", input);
setShareRoomId(input);
putMessageInMs(
messages.text.ClipboardApp.roomCheck.available_msg,
true
);
} else {
console.log("❌ Room is not valid:", input);
putMessageInMs(
messages.text.ClipboardApp.roomCheck.notAvailable_msg,
true