Skip to content

Commit

Permalink
SDA-4675 - Debounce hide notification
Browse files Browse the repository at this point in the history
  • Loading branch information
KiranNiranjan committed Sep 25, 2024
1 parent c8508aa commit b40a96a
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
64 changes: 64 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/renderer/notification.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { app, BrowserWindow, ipcMain } from 'electron';
import * as debounce from 'lodash.debounce';

import { analytics } from '../app/bi/analytics-handler';
import {
Expand Down Expand Up @@ -29,6 +30,7 @@ const animationQueue = new AnimationQueue();
const CONTAINER_HEIGHT = 104; // Notification container height
const CONTAINER_HEIGHT_WITH_INPUT = 146; // Notification container height including input field
const CONTAINER_WIDTH = 363;
const DEBOUNCE_DELAY = 50;
interface ICustomBrowserWindow extends Electron.BrowserWindow {
winName: string;
notificationData: INotificationData;
Expand Down Expand Up @@ -83,6 +85,10 @@ class Notification extends NotificationHandler {

constructor(opts) {
super(opts);
this.hideNotification = debounce(
this.hideNotification.bind(this),
DEBOUNCE_DELAY,
);
ipcMain.on('close-notification', (_event, windowId) => {
const browserWindow = this.getNotificationWindow(windowId);
if (
Expand Down

0 comments on commit b40a96a

Please sign in to comment.