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:
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user