Fix mobile voice button initialization
This commit is contained in:
@@ -32,7 +32,11 @@ function getSessionId() {
|
|||||||
const key = "opensquared_assistant_session";
|
const key = "opensquared_assistant_session";
|
||||||
let value = localStorage.getItem(key);
|
let value = localStorage.getItem(key);
|
||||||
if (!value) {
|
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);
|
localStorage.setItem(key, value);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
@@ -94,6 +98,19 @@ async function sendText() {
|
|||||||
|
|
||||||
async function toggleVoice() {
|
async function toggleVoice() {
|
||||||
await unlockAudio();
|
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) {
|
if (isRecording) {
|
||||||
recorder.stop();
|
recorder.stop();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -31,6 +31,12 @@ textarea {
|
|||||||
font: inherit;
|
font: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
cursor: pointer;
|
||||||
|
touch-action: manipulation;
|
||||||
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
.app-shell {
|
.app-shell {
|
||||||
width: min(100%, 520px);
|
width: min(100%, 520px);
|
||||||
min-height: 100svh;
|
min-height: 100svh;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const CACHE_NAME = "opensquared-assistant-v2";
|
const CACHE_NAME = "opensquared-assistant-v3";
|
||||||
const ASSETS = [
|
const ASSETS = [
|
||||||
"/",
|
"/",
|
||||||
"/styles.css",
|
"/styles.css",
|
||||||
|
|||||||
Reference in New Issue
Block a user