fixed rooms with passwd
This commit is contained in:
@@ -15,6 +15,7 @@ const RoomsApp = (function() {
|
||||
let modalTotalEpisodes = 0;
|
||||
const MODAL_EPS_PER_PAGE = 50;
|
||||
let currentQueue = [];
|
||||
let shouldReconnect = true;
|
||||
|
||||
let configState = {
|
||||
extension: null,
|
||||
@@ -160,6 +161,7 @@ const RoomsApp = (function() {
|
||||
function handleInitialEntry(roomInfo) {
|
||||
const token = localStorage.getItem('token');
|
||||
const passwordGroup = document.getElementById('password-group');
|
||||
const guestNameInput = document.getElementById('guest-name-input');
|
||||
|
||||
const hostInfoDiv = document.getElementById('join-host-info');
|
||||
const hostAvatar = document.getElementById('join-host-avatar');
|
||||
@@ -176,24 +178,31 @@ const RoomsApp = (function() {
|
||||
passwordGroup.dataset.required = roomInfo.hasPassword ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if (token && guestNameInput) {
|
||||
const parentGroup = guestNameInput.closest('.form-group') || guestNameInput;
|
||||
parentGroup.style.display = 'none';
|
||||
} else if (guestNameInput) {
|
||||
const parentGroup = guestNameInput.closest('.form-group') || guestNameInput;
|
||||
parentGroup.style.display = 'block';
|
||||
}
|
||||
|
||||
window.__roomPublicUrl = roomInfo.publicUrl || null;
|
||||
window.__roomExposed = roomInfo.exposed || false;
|
||||
|
||||
console.log('Room info loaded:', {
|
||||
exposed: window.__roomExposed,
|
||||
publicUrl: window.__roomPublicUrl
|
||||
});
|
||||
|
||||
if (token) {
|
||||
connectToRoom(currentRoomId);
|
||||
} else {
|
||||
console.log('Guest user, showing modal...');
|
||||
if (elements.joinRoomModal) {
|
||||
elements.joinRoomModal.classList.add('show');
|
||||
const nameInput = document.getElementById('guest-name-input');
|
||||
if (nameInput) {
|
||||
nameInput.value = '';
|
||||
setTimeout(() => nameInput.focus(), 100);
|
||||
|
||||
if (roomInfo.hasPassword) {
|
||||
setTimeout(() => {
|
||||
const passInput = document.getElementById('join-password-input');
|
||||
if(passInput) passInput.focus();
|
||||
}, 100);
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
if(guestNameInput) guestNameInput.focus();
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -983,6 +992,7 @@ const RoomsApp = (function() {
|
||||
closeModal();
|
||||
});
|
||||
function connectToRoom(roomId, guestName, password) {
|
||||
shouldReconnect = true;
|
||||
const token = localStorage.getItem('token');
|
||||
|
||||
const isTunnel = window.location.hostname.includes('trycloudflare.com');
|
||||
@@ -1034,7 +1044,7 @@ const RoomsApp = (function() {
|
||||
|
||||
ws.onclose = (event) => {
|
||||
console.log('WebSocket Disconnected:', event.code, event.reason);
|
||||
|
||||
if (!shouldReconnect) return;
|
||||
if (window.AnimePlayer && typeof window.AnimePlayer.setWebSocket === 'function') {
|
||||
window.AnimePlayer.setWebSocket(null);
|
||||
}
|
||||
@@ -1115,6 +1125,7 @@ const RoomsApp = (function() {
|
||||
function handleWebSocketMessage(data) {
|
||||
switch (data.type) {
|
||||
case 'error':
|
||||
shouldReconnect = false;
|
||||
handleConnectionError(data.message);
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user