@newtonschool/react_proctoring_library 0.0.79 → 0.0.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@ var _react = require("react");
9
9
  var _breachUtils = require("../../utils/breachUtils");
10
10
  var _useGenericFullScreenData = _interopRequireDefault(require("../useGenericFullScreenData"));
11
11
  var _ElectronContext = require("../../contexts/ElectronContext");
12
+ var _useIsPageFocussed = _interopRequireDefault(require("./useIsPageFocussed"));
12
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
14
  function useKioskMode(_ref) {
14
15
  let {
@@ -24,15 +25,7 @@ function useKioskMode(_ref) {
24
25
  isFullscreen
25
26
  } = (0, _useGenericFullScreenData.default)(isElectronApp);
26
27
  const shouldShowProctoredComponent = (0, _breachUtils.showProctoredComponent)(proctorParams, permissions);
27
- const [isDocumentFocused, setIsDocumentFocused] = (0, _react.useState)(true);
28
- (0, _react.useEffect)(() => {
29
- window.addEventListener('focus', () => {
30
- setIsDocumentFocused(true);
31
- });
32
- window.addEventListener('blur', () => {
33
- setIsDocumentFocused(false);
34
- });
35
- }, []);
28
+ const isDocumentFocused = (0, _useIsPageFocussed.default)(isElectronApp);
36
29
  (0, _react.useEffect)(() => {
37
30
  const updateOnlineStatus = () => {
38
31
  setConnectedToInternet(window.navigator.onLine);
@@ -40,6 +33,10 @@ function useKioskMode(_ref) {
40
33
  window.addEventListener('online', updateOnlineStatus);
41
34
  window.addEventListener('offline', updateOnlineStatus);
42
35
  updateOnlineStatus();
36
+ return () => {
37
+ window.removeEventListener('online', updateOnlineStatus);
38
+ window.removeEventListener('offline', updateOnlineStatus);
39
+ };
43
40
  }, []);
44
41
  (0, _react.useEffect)(() => {
45
42
  if (shouldShowProctoredComponent && isFullscreen && isElectronApp && connectedToInternet && isDocumentFocused) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newtonschool/react_proctoring_library",
3
- "version": "0.0.79",
3
+ "version": "0.0.80",
4
4
  "description": "Used to proctor online tests",
5
5
  "author": "ayushkagrawal,shreyachandra,weastel",
6
6
  "main": "dist/index.js",