mirror of
https://github.com/open-webui/open-webui
synced 2025-01-18 00:30:51 +00:00
refac: only activate wakelock in call mode
This commit is contained in:
parent
70ab7735ba
commit
c268a4e217
@ -28,6 +28,8 @@
|
||||
export let chatId;
|
||||
export let modelId;
|
||||
|
||||
let wakeLock = null;
|
||||
|
||||
let model = null;
|
||||
|
||||
let loading = false;
|
||||
@ -509,6 +511,34 @@
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
const setWakeLock = async () => {
|
||||
try {
|
||||
wakeLock = await navigator.wakeLock.request('screen');
|
||||
} catch (err) {
|
||||
// The Wake Lock request has failed - usually system related, such as battery.
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
if (wakeLock) {
|
||||
// Add a listener to release the wake lock when the page is unloaded
|
||||
wakeLock.addEventListener('release', () => {
|
||||
// the wake lock has been released
|
||||
console.log('Wake Lock released');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if ('wakeLock' in navigator) {
|
||||
await setWakeLock();
|
||||
|
||||
document.addEventListener('visibilitychange', async () => {
|
||||
// Re-request the wake lock if the document becomes visible
|
||||
if (wakeLock !== null && document.visibilityState === 'visible') {
|
||||
await setWakeLock();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
model = $models.find((m) => m.id === modelId);
|
||||
|
||||
startRecording();
|
||||
|
@ -38,8 +38,6 @@
|
||||
let loaded = false;
|
||||
const BREAKPOINT = 768;
|
||||
|
||||
let wakeLock = null;
|
||||
|
||||
onMount(async () => {
|
||||
theme.set(localStorage.theme);
|
||||
|
||||
@ -54,34 +52,6 @@
|
||||
|
||||
window.addEventListener('resize', onResize);
|
||||
|
||||
const setWakeLock = async () => {
|
||||
try {
|
||||
wakeLock = await navigator.wakeLock.request('screen');
|
||||
} catch (err) {
|
||||
// The Wake Lock request has failed - usually system related, such as battery.
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
if (wakeLock) {
|
||||
// Add a listener to release the wake lock when the page is unloaded
|
||||
wakeLock.addEventListener('release', () => {
|
||||
// the wake lock has been released
|
||||
console.log('Wake Lock released');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if ('wakeLock' in navigator) {
|
||||
await setWakeLock();
|
||||
|
||||
document.addEventListener('visibilitychange', async () => {
|
||||
// Re-request the wake lock if the document becomes visible
|
||||
if (wakeLock !== null && document.visibilityState === 'visible') {
|
||||
await setWakeLock();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let backendConfig = null;
|
||||
try {
|
||||
backendConfig = await getBackendConfig();
|
||||
|
Loading…
Reference in New Issue
Block a user