Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-live-chat-loader

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-live-chat-loader - npm Package Compare versions

Comparing version 0.0.19 to 0.0.20

27

dist/hooks/useChat.js

@@ -38,23 +38,16 @@ "use strict";

if (connection && (connection.saveData || /2g/.test(connection.effectiveType))) return;
var idleCountThreshold = parseInt(idlePeriod, 10) / 50;
if (isNaN(idleCountThreshold)) return; // deadline.timeRemaining() has an upper limit of 50 milliseconds
var idleThreshold = parseInt(idlePeriod, 10);
if (isNaN(idleThreshold)) return; // deadline.timeRemaining() has an upper limit of 50 milliseconds
// We want to ensure the page has been idle for a significant period of time
// Therefore we count consecutive maximum timeRemaining counts and load chat when we reach our threshold
var idleCounts = 0;
var elapsedIdlePeriod = 0;
var scheduleLoadChat = function scheduleLoadChat(deadline) {
if (idleCounts > idleCountThreshold) {
loadChat({
open: false
});
} else if (deadline.timeRemaining() > 49) {
// no activity has occurred, increment idle count
idleCounts++;
requestIdleCallback(scheduleLoadChat);
} else {
// some activity has occurred, reset idle count
idleCounts = 0;
requestIdleCallback(scheduleLoadChat);
}
if (elapsedIdlePeriod > idleThreshold) return loadChat({
open: false
});
var timeRemaining = deadline.timeRemaining();
if (timeRemaining > 49) elapsedIdlePeriod += timeRemaining;
requestIdleCallback(scheduleLoadChat);
};

@@ -69,3 +62,3 @@

});
}, idleCountThreshold * 50);
}, idleThreshold * 2);
}

@@ -72,0 +65,0 @@ }, []);

{
"name": "react-live-chat-loader",
"version": "0.0.19",
"version": "0.0.20",
"description": "Implement live chat in your react app without taking a performance hit.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc