From 0a67bed141127ba2d399565ca69b1437bc1c84e6 Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Tue, 1 Oct 2024 21:57:13 +0530 Subject: [PATCH] SDA-4675 - Revert delay --- src/common/utils.ts | 48 ----------------------------------------- src/renderer/ssf-api.ts | 43 +++++++++++++++--------------------- 2 files changed, 17 insertions(+), 74 deletions(-) diff --git a/src/common/utils.ts b/src/common/utils.ts index 7cac9f4d0..6cf45ce4f 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -349,51 +349,3 @@ export class DelayedFunctionQueue { } } } -export interface IFunctionQueue { - enqueue: (fn: () => void) => void; -} - -/** - * Creates a function queue that executes functions sequentially with a specified interval. - * - * @param {number} interval - The interval (in milliseconds) between function executions. - * @returns {IFunctionQueue} - An object representing the function queue. - */ -export const createSequentialFunctionQueue = ( - interval: number, -): IFunctionQueue => { - const queue: Array<() => void> = []; - let isProcessing: boolean = false; - - // Enqueue a function call - const enqueue = (fn: () => void): void => { - queue.push(fn); - processQueue(); - }; - - // Process the queue - const processQueue = (): void => { - if (isProcessing) { - return; - } - isProcessing = true; - - const processNext = (): void => { - if (queue.length === 0) { - isProcessing = false; - return; - } - const fn = queue.shift(); - if (fn) { - fn(); - } - // Schedule the next function execution after the interval - setTimeout(() => { - processNext(); - }, interval); - }; - processNext(); - }; - - return { enqueue }; -}; diff --git a/src/renderer/ssf-api.ts b/src/renderer/ssf-api.ts index 370e54395..7b70e095e 100644 --- a/src/renderer/ssf-api.ts +++ b/src/renderer/ssf-api.ts @@ -35,11 +35,7 @@ import { PhoneNumberProtocol, } from '../common/api-interface'; import { i18n, LocaleType } from '../common/i18n-preload'; -import { - createSequentialFunctionQueue, - DelayedFunctionQueue, - throttle, -} from '../common/utils'; +import { DelayedFunctionQueue, throttle } from '../common/utils'; import { getSource } from './desktop-capturer'; import SSFNotificationHandler from './notification-ssf-handler'; import { ScreenSnippetBcHandler } from './screen-snippet-bc-handler'; @@ -90,9 +86,6 @@ const callNotificationActionCallbacks = new Map< >(); const DEFAULT_THROTTLE = 1000; -const NOTIFICATION_DELAY = 500; - -const notificationQueue = createSequentialFunctionQueue(NOTIFICATION_DELAY); // Throttle func const throttledSetBadgeCount = throttle((count) => { @@ -719,24 +712,22 @@ export class SSFApi { notificationOpts: INotificationData, notificationCallback: NotificationActionCallback, ): void { - notificationQueue.enqueue(() => { - // Store callbacks based on notification id so, - // we can use this to trigger on notification action - if (typeof notificationOpts.id === 'number') { - notificationActionCallbacks.set( - notificationOpts.id, - notificationCallback, - ); - } - // ipc does not support sending Functions, Promises, Symbols, WeakMaps, - // or WeakSets will throw an exception - if (notificationOpts.callback) { - delete notificationOpts.callback; - } - ipcRenderer.send(apiName.symphonyApi, { - cmd: apiCmds.showNotification, - notificationOpts, - }); + // Store callbacks based on notification id so, + // we can use this to trigger on notification action + if (typeof notificationOpts.id === 'number') { + notificationActionCallbacks.set( + notificationOpts.id, + notificationCallback, + ); + } + // ipc does not support sending Functions, Promises, Symbols, WeakMaps, + // or WeakSets will throw an exception + if (notificationOpts.callback) { + delete notificationOpts.callback; + } + ipcRenderer.send(apiName.symphonyApi, { + cmd: apiCmds.showNotification, + notificationOpts, }); }