Skip to content

Commit

Permalink
SDA-4300 - Fix timer GitHub action issue
Browse files Browse the repository at this point in the history
  • Loading branch information
KiranNiranjan authored and Kiran Niranjan committed Sep 28, 2023
1 parent b30cd49 commit 3a85f92
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/app/activity-detection.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { app, powerMonitor, WebContents } from 'electron';
import Timer = NodeJS.Timer;
import Timeout = NodeJS.Timeout;

import { logger } from '../common/logger';
import { windowHandler } from './window-handler';

class ActivityDetection {
private idleThreshold: number;
private window: WebContents | null;
private timer: Timer | undefined;
private queryInterval: NodeJS.Timer | undefined;
private timer: Timeout | undefined;
private queryInterval: Timeout | undefined;

constructor() {
this.idleThreshold = 60 * 60 * 1000;
Expand Down
9 changes: 6 additions & 3 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// regex match the semver (semantic version) this checks for the pattern X.Y.Z
// ex-valid v1.2.0, 1.2.0, 2.3.4-r51
const semver = /^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?)?)?$/i;
const semver =
/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?)?)?$/i;
const patch = /-([0-9A-Za-z-.]+)/;

/**
Expand Down Expand Up @@ -205,15 +206,17 @@ export const throttle = (
);
}

let timer: NodeJS.Timer;
let timer: NodeJS.Timeout;
let lastRan = 0;

return (...args) => {
if (!lastRan) {
func.apply(null, args);
lastRan = Date.now();
} else {
clearTimeout(timer);
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(() => {
if (Date.now() - lastRan >= wait) {
func.apply(null, args);
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const CONTAINER_WIDTH = 363;
interface ICustomBrowserWindow extends Electron.BrowserWindow {
winName: string;
notificationData: INotificationData;
displayTimer: NodeJS.Timer;
displayTimer: NodeJS.Timeout;
clientId: number;
}

Expand Down Expand Up @@ -75,7 +75,7 @@ class Notification extends NotificationHandler {
};
private activeNotifications: ICustomBrowserWindow[] = [];
private inactiveWindows: ICustomBrowserWindow[] = [];
private cleanUpTimer: NodeJS.Timer;
private cleanUpTimer: NodeJS.Timeout;
private notificationQueue: INotificationData[] = [];

private readonly notificationCallbacks: any[] = [];
Expand Down

0 comments on commit 3a85f92

Please sign in to comment.