1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-04-18 08:08:28 +02:00

Send only necessary notifications to main process

For #238
This commit is contained in:
kkapsner 2018-09-16 12:15:04 +02:00
parent db79c0129b
commit e4c2196131

View File

@ -69,13 +69,17 @@
}); });
var notifications = []; var notifications = [];
var notificationCounter = {}; var notificationCounter = {};
var sentAPIs = {};
function notify(data){ function notify(data){
if (!settings.ignoredAPIs[data.api]){ if (!settings.ignoredAPIs[data.api]){
if (settings.storeNotificationData){ if (settings.storeNotificationData){
notifications.push(data); notifications.push(data);
} }
notificationCounter[data.messageId] = (notificationCounter[data.messageId] || 0) + 1; notificationCounter[data.messageId] = (notificationCounter[data.messageId] || 0) + 1;
port.postMessage({"canvasBlocker-notify": data}); if (!sentAPIs[data.api]){
sentAPIs[data.api] = true;
port.postMessage({"canvasBlocker-notify": data});
}
} }
} }