Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rschnekenbu committed May 28, 2024
1 parent a75f3ea commit beb0ed6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions packages/plugin-ext/src/main/browser/window-activity-tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@

import { Disposable, Emitter, Event } from '@theia/core';

const CHECK_INACTIVITY_LIMIT = 2;
const CHECK_INACTIVITY_INTERVAL = 10000;
const CHECK_INACTIVITY_LIMIT = 30;
const CHECK_INACTIVITY_INTERVAL = 1000;

const eventListenerOptions: AddEventListenerOptions = {
passive: true,
capture: true
};
export class WindowActivityTracker implements Disposable {

private inactivityTime = 0; // number of times inactivity was checked since last reset
private inactivityCounter = 0; // number of times inactivity was checked since last reset
private readonly inactivityLimit = CHECK_INACTIVITY_LIMIT; // number of inactivity checks done before sending inactive signal
private readonly checkInactivityInterval = CHECK_INACTIVITY_INTERVAL; // check interval in milliseconds
private interval: NodeJS.Timeout | undefined;
Expand Down Expand Up @@ -64,7 +64,7 @@ export class WindowActivityTracker implements Disposable {

// Reset inactivity time
private resetInactivity = (): void => {
this.inactivityTime = 0;
this.inactivityCounter = 0;
if (!this.interval) {
// it was not active. Set as active and restart tracking inactivity
this.activeState = true;
Expand All @@ -74,8 +74,8 @@ export class WindowActivityTracker implements Disposable {

// Check inactivity status
private checkInactivity = (): void => {
this.inactivityTime++;
if (this.inactivityTime >= this.inactivityLimit) {
this.inactivityCounter++;
if (this.inactivityCounter >= this.inactivityLimit) {
this.activeState = false;
this.stopTracking();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/main/browser/window-state-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class WindowStateMain implements WindowMain, Disposable {

const tracker = new WindowActivityTracker(window);
this.toDispose.push(tracker.onDidChangeActiveState(isActive => this.onActiveStateChanged(isActive)));
this.toDispose.push(Disposable.create(() => tracker.dispose()));
this.toDispose.push(tracker);
}

dispose(): void {
Expand Down

0 comments on commit beb0ed6

Please sign in to comment.