diff --git a/web/assets/js/websocket.js b/web/assets/js/websocket.js index 5b8a3948..ccafef87 100644 --- a/web/assets/js/websocket.js +++ b/web/assets/js/websocket.js @@ -14,10 +14,12 @@ class WebSocketClient { } connect() { - if (this.ws && this.ws.readyState === WebSocket.OPEN) { + if (this.ws && (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING)) { return; } + this.shouldReconnect = true; + const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; // Ensure basePath ends with '/' for proper URL construction let basePath = this.basePath || ''; @@ -97,7 +99,10 @@ class WebSocketClient { if (!this.listeners.has(event)) { this.listeners.set(event, []); } - this.listeners.get(event).push(callback); + const callbacks = this.listeners.get(event); + if (!callbacks.includes(callback)) { + callbacks.push(callback); + } } off(event, callback) { diff --git a/web/html/inbounds.html b/web/html/inbounds.html index eeffd98d..b945da90 100644 --- a/web/html/inbounds.html +++ b/web/html/inbounds.html @@ -1602,7 +1602,6 @@ if (payload && Array.isArray(payload)) { // Use setInbounds to properly convert to DBInbound objects with methods this.setInbounds(payload); - this.searchInbounds(this.searchKey); } }); @@ -1614,14 +1613,31 @@ // Update online clients list in real-time if (payload && Array.isArray(payload.onlineClients)) { - this.onlineClients = payload.onlineClients; - // Recalculate client counts to update online status - this.dbInbounds.forEach(dbInbound => { - const inbound = this.inbounds.find(ib => ib.id === dbInbound.id); - if (inbound && this.clientCount[dbInbound.id]) { - this.clientCount[dbInbound.id] = this.getClientCounts(dbInbound, inbound); + const nextOnlineClients = payload.onlineClients; + let onlineChanged = this.onlineClients.length !== nextOnlineClients.length; + if (!onlineChanged) { + const prevSet = new Set(this.onlineClients); + for (const email of nextOnlineClients) { + if (!prevSet.has(email)) { + onlineChanged = true; + break; + } } - }); + } + this.onlineClients = nextOnlineClients; + if (onlineChanged) { + // Recalculate client counts to update online status + this.dbInbounds.forEach(dbInbound => { + const inbound = this.inbounds.find(ib => ib.id === dbInbound.id); + if (inbound && this.clientCount[dbInbound.id]) { + this.clientCount[dbInbound.id] = this.getClientCounts(dbInbound, inbound); + } + }); + + if (this.enableFilter) { + this.filterInbounds(); + } + } } // Update last online map in real-time diff --git a/web/html/settings/panel/subscription/subpage.html b/web/html/settings/panel/subscription/subpage.html index 222352ff..c59f68ee 100644 --- a/web/html/settings/panel/subscription/subpage.html +++ b/web/html/settings/panel/subscription/subpage.html @@ -5,6 +5,43 @@ + {{ template "page/head_end" .}} {{ template "page/body_start" .}} @@ -138,27 +175,12 @@ style="margin-bottom: -10px; position: relative; z-index: 2; box-shadow: 0 2px 4px rgba(0,0,0,0.2);"> [[ linkName(link, idx) ]] -