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;
|
||||
|
||||
@@ -31,6 +31,12 @@ textarea {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
button {
|
||||
cursor: pointer;
|
||||
touch-action: manipulation;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
.app-shell {
|
||||
width: min(100%, 520px);
|
||||
min-height: 100svh;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const CACHE_NAME = "opensquared-assistant-v2";
|
||||
const CACHE_NAME = "opensquared-assistant-v3";
|
||||
const ASSETS = [
|
||||
"/",
|
||||
"/styles.css",
|
||||
|
||||
Reference in New Issue
Block a user