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 chatId;
|
||||||
export let modelId;
|
export let modelId;
|
||||||
|
|
||||||
|
let wakeLock = null;
|
||||||
|
|
||||||
let model = null;
|
let model = null;
|
||||||
|
|
||||||
let loading = false;
|
let loading = false;
|
||||||
@ -509,6 +511,34 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
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);
|
model = $models.find((m) => m.id === modelId);
|
||||||
|
|
||||||
startRecording();
|
startRecording();
|
||||||
|
@ -38,8 +38,6 @@
|
|||||||
let loaded = false;
|
let loaded = false;
|
||||||
const BREAKPOINT = 768;
|
const BREAKPOINT = 768;
|
||||||
|
|
||||||
let wakeLock = null;
|
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
theme.set(localStorage.theme);
|
theme.set(localStorage.theme);
|
||||||
|
|
||||||
@ -54,34 +52,6 @@
|
|||||||
|
|
||||||
window.addEventListener('resize', onResize);
|
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;
|
let backendConfig = null;
|
||||||
try {
|
try {
|
||||||
backendConfig = await getBackendConfig();
|
backendConfig = await getBackendConfig();
|
||||||
|
Loading…
Reference in New Issue
Block a user