Add activity tracker

This commit is contained in:
2022-07-18 23:46:55 +00:00
parent 8fe408bcc6
commit f12cc164b6
6 changed files with 119 additions and 9 deletions

View File

@@ -909,6 +909,41 @@ const ServicesMixin = (SuperClass) => {
};
};
const ActivityMixin = (SuperClass) => {
return class ActivityMixinClass extends SuperClass {
constructor() {
super();
this.activityTriggered = false;
this._activityCooldown = 15000;
for (const ev of ["pointerdown", "pointermove", "keydown"]) {
window.addEventListener(ev, () => this.activityTrigger());
}
this.addEventListener("fully-update", () => {
this.activityTrigger();
});
}
activityTrigger() {
if (!this.activityTriggered) {
this.sendUpdate({
activity: true,
});
}
this.activityTriggered = true;
clearTimeout(this._activityTimeout);
this._activityTimeout = setTimeout(() => this.activityReset(), this._activityCooldown);
}
activityReset() {
clearTimeout(this._activityTimeout);
if (this.activityTriggered) {
this.sendUpdate({
activity: false,
});
}
this.activityTriggered = false;
}
};
};
/**
* @license
* Copyright 2017 Google LLC
@@ -1301,7 +1336,7 @@ var pjson = {
- Media_seek
- Screensavers
*/
class BrowserMod extends ServicesMixin(PopupMixin(BrowserStateMixin(CameraMixin(MediaPlayerMixin(ScreenSaverMixin(FullyMixin(RequireInteractMixin(ConnectionMixin(EventTarget))))))))) {
class BrowserMod extends ServicesMixin(PopupMixin(ActivityMixin(BrowserStateMixin(CameraMixin(MediaPlayerMixin(ScreenSaverMixin(FullyMixin(RequireInteractMixin(ConnectionMixin(EventTarget)))))))))) {
constructor() {
super();
this.connect();