From c11359b2d25107f53fd90ea3533323241d215568 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Tue, 17 Feb 2026 15:21:31 +0000 Subject: [PATCH] Autosave: 20260217-152131 --- assets/js/main.js | 5 ++-- assets/js/voice.js | 50 +++++++++++++++++++++++++++++++-------- data/22.log | 3 +++ data/22.participants.json | 2 +- data/3.participants.json | 2 +- index.php | 26 +++++++++++++------- requests.log | 12 ++++++++++ 7 files changed, 76 insertions(+), 24 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index 454c3b1..e26e253 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -681,9 +681,8 @@ document.addEventListener('DOMContentLoaded', () => { const channelId = voiceItem.dataset.channelId; if (voiceHandler) { if (voiceHandler.currentChannelId == channelId) { - console.log('Leaving voice channel:', channelId); - voiceHandler.leave(); - voiceItem.classList.remove('active'); + console.log('Already in this channel:', channelId); + return; } else { console.log('Joining voice channel:', channelId); voiceHandler.join(channelId); diff --git a/assets/js/voice.js b/assets/js/voice.js index 1b86879..9e77e8d 100644 --- a/assets/js/voice.js +++ b/assets/js/voice.js @@ -265,15 +265,31 @@ class VoiceChannel { } setupVOX() { - if (this.audioContext) { - if (this.audioContext.state === 'suspended') { - this.audioContext.resume(); - } + if (!this.localStream) { + console.warn('Cannot setup VOX: no localStream'); return; } - + + console.log('Setting up VOX logic...'); try { - this.audioContext = new (window.AudioContext || window.webkitAudioContext)(); + if (!this.audioContext) { + this.audioContext = new (window.AudioContext || window.webkitAudioContext)(); + } + + // Re-ensure context is running + if (this.audioContext.state === 'suspended') { + this.audioContext.resume().then(() => console.log('AudioContext resumed')); + } + + // Cleanup old nodes + if (this.scriptProcessor) { + this.scriptProcessor.onaudioprocess = null; + try { this.scriptProcessor.disconnect(); } catch(e) {} + } + if (this.microphone) { + try { this.microphone.disconnect(); } catch(e) {} + } + this.analyser = this.audioContext.createAnalyser(); this.analyser.fftSize = 512; this.microphone = this.audioContext.createMediaStreamSource(this.localStream); @@ -282,7 +298,8 @@ class VoiceChannel { this.microphone.connect(this.analyser); this.analyser.connect(this.scriptProcessor); this.scriptProcessor.connect(this.audioContext.destination); - + + this.voxActive = false; this.currentVolume = 0; this.scriptProcessor.onaudioprocess = () => { @@ -311,6 +328,7 @@ class VoiceChannel { } } }; + console.log('VOX logic setup complete'); } catch (e) { console.error('Failed to setup VOX:', e); } @@ -360,9 +378,21 @@ class VoiceChannel { this.localStream.getTracks().forEach(track => track.stop()); this.localStream = null; } - if (this.audioContext) { - this.audioContext.close(); - this.audioContext = null; + + if (this.scriptProcessor) { + try { + this.scriptProcessor.disconnect(); + this.scriptProcessor.onaudioprocess = null; + } catch(e) {} + this.scriptProcessor = null; + } + if (this.microphone) { + try { this.microphone.disconnect(); } catch(e) {} + this.microphone = null; + } + if (this.audioContext && this.audioContext.state !== 'closed') { + // Keep AudioContext alive but suspended to reuse it + this.audioContext.suspend(); } Object.values(this.peers).forEach(pc => pc.close()); diff --git a/data/22.log b/data/22.log index e69de29..ab069b2 100644 --- a/data/22.log +++ b/data/22.log @@ -0,0 +1,3 @@ +{"from":"fc0c84d0eacc14ca","to":"3183519aeadc9f64","data":{"type":"ice_candidate","candidate":{"candidate":"candidate:1 1 UDP 1686052863 78.246.210.10 31075 typ srflx raddr 192.168.26.26 rport 52078","sdpMLineIndex":0,"sdpMid":"0","usernameFragment":"0e646e7c"}},"time":1771341579696} +{"from":"fc0c84d0eacc14ca","to":"3183519aeadc9f64","data":{"type":"ice_candidate","candidate":{"candidate":"candidate:1 2 UDP 1686052862 78.246.210.10 31078 typ srflx raddr 192.168.26.26 rport 52079","sdpMLineIndex":0,"sdpMid":"0","usernameFragment":"0e646e7c"}},"time":1771341579740} +{"from":"fc0c84d0eacc14ca","to":"3183519aeadc9f64","data":{"type":"ice_candidate","candidate":{"candidate":"","sdpMLineIndex":0,"sdpMid":"0","usernameFragment":"0e646e7c"}},"time":1771341579742} diff --git a/data/22.participants.json b/data/22.participants.json index bb2fb68..0637a08 100644 --- a/data/22.participants.json +++ b/data/22.participants.json @@ -1 +1 @@ -{"45a8f0c9dde7c4a2":{"id":"45a8f0c9dde7c4a2","user_id":2,"name":"swefpifh ᵇʰᶠʳ","avatar_url":"","last_seen":1771340822998}} \ No newline at end of file +[] \ No newline at end of file diff --git a/data/3.participants.json b/data/3.participants.json index cbc2de9..e929308 100644 --- a/data/3.participants.json +++ b/data/3.participants.json @@ -1 +1 @@ -{"1e0897d1dcb980dc":{"id":"1e0897d1dcb980dc","user_id":3,"name":"swefheim","avatar_url":"","last_seen":1771340822155}} \ No newline at end of file +{"f9f747081f54c6e3":{"id":"f9f747081f54c6e3","user_id":2,"name":"swefpifh ᵇʰᶠʳ","avatar_url":"","last_seen":1771341691097}} \ No newline at end of file diff --git a/index.php b/index.php index 3f3915a..3576530 100644 --- a/index.php +++ b/index.php @@ -1325,17 +1325,20 @@ document.addEventListener('DOMContentLoaded', () => { const voiceTabBtn = document.querySelector('[data-bs-target="#settings-voice"]'); if (voiceTabBtn) { voiceTabBtn.addEventListener('shown.bs.tab', async () => { - if (window.voiceHandler && !window.voiceHandler.localStream) { - try { - console.log('Voice tab active, requesting mic for preview...'); - const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); - window.voiceHandler.localStream = stream; + if (window.voiceHandler) { + if (!window.voiceHandler.localStream) { + try { + console.log('Voice tab active, requesting mic for preview...'); + const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); + window.voiceHandler.localStream = stream; + window.voiceHandler.setupVOX(); + } catch (e) { + console.error('Failed to get mic for preview:', e); + } + } else { + console.log('Voice tab active, using existing localStream for preview'); window.voiceHandler.setupVOX(); - } catch (e) { - console.error('Failed to get mic for preview:', e); } - } else if (window.voiceHandler && window.voiceHandler.localStream) { - window.voiceHandler.setupVOX(); } }); } @@ -1408,6 +1411,11 @@ async function handleSaveUserSettings(btn) { if (result.success) { btn.innerHTML = ' Saved!'; + // Update current username in window + if (formData.get('display_name')) { + window.currentUsername = formData.get('display_name'); + } + // Update local voiceHandler settings without reload if (window.voiceHandler) { const mode = formData.get('voice_mode'); diff --git a/requests.log b/requests.log index fb2110c..a8de67a 100644 --- a/requests.log +++ b/requests.log @@ -606,3 +606,15 @@ {"date":"2026-02-17 15:05:57","method":"POST","post":{"avatar_url":"","display_name":"swefpifh \u1d47\u02b0\u1da0\u02b3","theme":"dark","voice_mode":"vox","voice_ptt_key":"v","voice_vox_threshold":"0.06","dnd_mode":"1","sound_notifications":"1"},"session":{"user_id":2},"user_id":2,"db_success":true} 2026-02-17 15:06:05 - GET /index.php?server_id=1&channel_id=1 - POST: [] 2026-02-17 15:06:09 - GET /index.php?server_id=1&channel_id=1 - POST: [] +{"date":"2026-02-17 15:07:56","method":"POST","post":{"avatar_url":"","display_name":"swefpifh \u1d47\u02b0\u1da0\u02b3","theme":"dark","voice_mode":"ptt","voice_ptt_key":"v","voice_vox_threshold":"0.06","dnd_mode":"1","sound_notifications":"1"},"session":{"user_id":2},"user_id":2,"db_success":true} +{"date":"2026-02-17 15:08:11","method":"POST","post":{"avatar_url":"","display_name":"swefpifh \u1d47\u02b0\u1da0\u02b3","theme":"dark","voice_mode":"ptt","voice_ptt_key":"0","voice_vox_threshold":"0.06","dnd_mode":"1","sound_notifications":"1"},"session":{"user_id":2},"user_id":2,"db_success":true} +2026-02-17 15:14:44 - GET /?fl_project=38443 - POST: [] +2026-02-17 15:14:44 - GET /?fl_project=38443 - POST: [] +2026-02-17 15:18:05 - GET /?fl_project=38443 - POST: [] +2026-02-17 15:18:05 - GET /?fl_project=38443 - POST: [] +2026-02-17 15:19:12 - GET /index.php?server_id=1&channel_id=1 - POST: [] +{"date":"2026-02-17 15:19:29","method":"POST","post":{"avatar_url":"","display_name":"swefpifh \u1d47\u02b0\u1da0\u02b3","theme":"dark","voice_mode":"ptt","voice_ptt_key":"0","voice_vox_threshold":"0.06","dnd_mode":"1","sound_notifications":"1"},"session":{"user_id":2},"user_id":2,"db_success":true} +{"date":"2026-02-17 15:19:34","method":"POST","post":{"avatar_url":"","display_name":"swefpifh \u1d47\u02b0\u1da0\u02b3","theme":"dark","voice_mode":"vox","voice_ptt_key":"0","voice_vox_threshold":"0.06","dnd_mode":"1","sound_notifications":"1"},"session":{"user_id":2},"user_id":2,"db_success":true} +{"date":"2026-02-17 15:19:53","method":"POST","post":{"avatar_url":"","display_name":"swefpifh \u1d47\u02b0\u1da0\u02b3","theme":"dark","voice_mode":"vox","voice_ptt_key":"0","voice_vox_threshold":"0.06","dnd_mode":"1","sound_notifications":"1"},"session":{"user_id":2},"user_id":2,"db_success":true} +2026-02-17 15:19:56 - GET /index.php?server_id=1&channel_id=1 - POST: [] +2026-02-17 15:20:01 - GET /index.php?server_id=1&channel_id=1 - POST: []