fix: update last active only on touch #71

This commit is contained in:
leukipp
2025-09-08 09:56:27 +02:00
parent 19348b4b60
commit d35cf27de9
+14 -5
View File
@@ -11,6 +11,7 @@ global.WEBVIEW = global.WEBVIEW || {
status: null, status: null,
locked: false, locked: false,
pointer: { pointer: {
position: {},
time: new Date(), time: new Date(),
}, },
}; };
@@ -742,13 +743,21 @@ const viewEvents = async () => {
const now = new Date(); const now = new Date();
const then = WEBVIEW.pointer.time; const then = WEBVIEW.pointer.time;
const delta = Math.abs(now - then) / 1000; const delta = Math.abs(now - then) / 1000;
WEBVIEW.pointer.time = now;
switch (mouse.type) { switch (mouse.type) {
case "mouseMove": case "mouseMove":
const posNew = { x: mouse.globalX, y: mouse.globalY };
if (posNew.x < 0 || posNew.y < 0) {
break;
}
const posOld = WEBVIEW.pointer.position;
if (posOld.x !== posNew.x || posOld.y !== posNew.y) {
WEBVIEW.pointer.time = now;
WEBVIEW.pointer.position = posNew;
if (delta > 30) { if (delta > 30) {
console.log("Update Last Active"); console.log("Update Last Active");
integration.update(); integration.update();
} }
}
break; break;
case "mouseDown": case "mouseDown":
switch (mouse.button) { switch (mouse.button) {
@@ -784,14 +793,14 @@ const appEvents = async () => {
WEBVIEW.window.focus(); WEBVIEW.window.focus();
}); });
// Webview initialized
WEBVIEW.initialized = true;
// Check for latest release infos (2h) // Check for latest release infos (2h)
setInterval(() => { setInterval(() => {
latestRelease(); latestRelease();
}, 7200 * 1000); }, 7200 * 1000);
await latestRelease(); await latestRelease();
// Webview initialized
WEBVIEW.initialized = true;
}; };
/** /**
@@ -799,7 +808,7 @@ const appEvents = async () => {
*/ */
const latestRelease = async () => { const latestRelease = async () => {
try { try {
const response = await axios.get(`${APP.releases.url}/latest`); const response = await axios.get(`${APP.releases.url}/latest`, { timeout: 10000 });
const data = response ? response.data : null; const data = response ? response.data : null;
if (!data || data.draft || data.prerelease) { if (!data || data.draft || data.prerelease) {
return; return;