Fix mobile voice button initialization
This commit is contained in:
@@ -32,7 +32,11 @@ function getSessionId() {
|
||||
const key = "opensquared_assistant_session";
|
||||
let value = localStorage.getItem(key);
|
||||
if (!value) {
|
||||
value = crypto.randomUUID();
|
||||
if (window.crypto && typeof window.crypto.randomUUID === "function") {
|
||||
value = window.crypto.randomUUID();
|
||||
} else {
|
||||
value = `session-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
||||
}
|
||||
localStorage.setItem(key, value);
|
||||
}
|
||||
return value;
|
||||
@@ -94,6 +98,19 @@ async function sendText() {
|
||||
|
||||
async function toggleVoice() {
|
||||
await unlockAudio();
|
||||
|
||||
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
|
||||
addBubble("Le micro n'est pas disponible dans ce navigateur. Ouvre l'app en HTTPS avec Chrome.", "error");
|
||||
setStatus("Micro indisponible", "error");
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof MediaRecorder === "undefined") {
|
||||
addBubble("L'enregistrement audio n'est pas supporte par ce navigateur.", "error");
|
||||
setStatus("Enregistrement indisponible", "error");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isRecording) {
|
||||
recorder.stop();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user