@newtonschool/react_proctoring_library 0.0.89 → 0.0.91

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.
@@ -20,6 +20,7 @@ var _fullscreen = _interopRequireDefault(require("../fullscreen"));
20
20
  var _ElectronContext = require("../../contexts/ElectronContext");
21
21
  var _useGenericWakeUpLock = _interopRequireDefault(require("../../hooks/useGenericWakeUpLock"));
22
22
  var _breachParameters = _interopRequireDefault(require("../breach-parameters"));
23
+ var _permission = require("../../utils/permission");
23
24
  var _jsxRuntime = require("react/jsx-runtime");
24
25
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
25
26
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -75,6 +76,12 @@ const ProctorApp = _ref => {
75
76
  });
76
77
  await Promise.all(allPromises);
77
78
  }, [permissions, askPermissionAction]);
79
+ (0, _react.useEffect)(() => {
80
+ const allPermissionGranted = (0, _permission.hasAllPermissions)((0, _breachUtils.getRequiredPermissionsFromProctorParams)(proctorParams), permissions);
81
+ if (allPermissionGranted && allPermissionGrantedOnce) {
82
+ allPermissionGrantedOnce.current = true;
83
+ }
84
+ }, [allPermissionGrantedOnce, permissions, proctorParams]);
78
85
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
79
86
  className: "".concat(proctorParams.copyPasteProctoring ? 'disable-copy-paste fullwidth fullheight' : 'fullwidth fullheight'),
80
87
  children: [shouldShowProctoredComponent && children, !shouldShowProctoredComponent && customPermissionView && /*#__PURE__*/(0, _jsxRuntime.jsx)(CustomPermissionView, _objectSpread({
@@ -62,11 +62,6 @@ const ProctoredContextApp = _ref => {
62
62
  const forceUpdate = () => {
63
63
  setUpdateId(oldId => oldId + 1);
64
64
  };
65
- (0, _react.useEffect)(() => {
66
- if (videoPermission && screensharePermission && isFullscreen) {
67
- allPermissionGrantedOnce.current = true;
68
- }
69
- }, [videoPermission, isFullscreen, screensharePermission]);
70
65
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Context.Provider, {
71
66
  value: _objectSpread(_objectSpread({}, customContext), {}, {
72
67
  permissions,
@@ -79,19 +79,16 @@ function ElectronScreenShare(_ref) {
79
79
  streamId: newStreamId
80
80
  });
81
81
  };
82
- const isRecurring = config === null || config === void 0 ? void 0 : config.recurring;
83
82
  const screenShareConfig = config === null || config === void 0 ? void 0 : (_config$fileUploadCon = config.fileUploadConfig) === null || _config$fileUploadCon === void 0 ? void 0 : _config$fileUploadCon.screenShare;
84
83
  (0, _react.useEffect)(() => {
85
- console.log('streamDeviceId, isRecurring, screenShareConfig', streamDeviceId, isRecurring, screenShareConfig);
86
- if (streamDeviceId && screenShareConfig && isRecurring) {
84
+ if (streamDeviceId && screenShareConfig) {
87
85
  const snapshotIntervalID = startScreenShareSnapshot(streamDeviceId);
88
86
  return () => {
89
87
  endScreenShareSnapshot(snapshotIntervalID);
90
88
  };
91
89
  }
92
- }, [streamDeviceId, isRecurring, screenShareConfig]);
90
+ }, [streamDeviceId, screenShareConfig]);
93
91
  (0, _react.useEffect)(() => {
94
- console.log('streamDeviceId', streamDeviceId);
95
92
  const permissionSetter = permission => {
96
93
  setScreensharePermission(permission);
97
94
  };
@@ -103,6 +100,5 @@ function ElectronScreenShare(_ref) {
103
100
  window.electron.listener.removeListener(id, permissionSetter);
104
101
  };
105
102
  }, [streamDeviceId]);
106
- console.log('streamDeviceId', isRecurring, screenShareConfig, streamDeviceId);
107
103
  return null;
108
104
  }
@@ -36,7 +36,7 @@ function WebScreenShare(_ref) {
36
36
  streamSetter,
37
37
  permissions
38
38
  } = (0, _react.useContext)(proctoredContext);
39
- const recurringFetchIntervalRef = (0, _react.useRef)();
39
+ const recurringFetchIntervalRef = (0, _react.useRef)(null);
40
40
  const {
41
41
  recurring = false,
42
42
  recurringFetchInterval = 0
@@ -74,7 +74,9 @@ function WebScreenShare(_ref) {
74
74
  }, randomStartDelay);
75
75
  }
76
76
  return () => {
77
- clearInterval(recurringFetchIntervalRef.current);
77
+ if (recurringFetchIntervalRef.current) {
78
+ clearInterval(recurringFetchIntervalRef.current);
79
+ }
78
80
  clearTimeout(timeoutId);
79
81
  };
80
82
  }, [recurring, recurringFetchInterval, sendScreengrab]);
@@ -7,10 +7,7 @@ exports.default = useKioskMode;
7
7
  require("core-js/modules/web.dom-collections.iterator.js");
8
8
  var _react = require("react");
9
9
  var _breachUtils = require("../../utils/breachUtils");
10
- var _useGenericFullScreenData = _interopRequireDefault(require("../useGenericFullScreenData"));
11
10
  var _ElectronContext = require("../../contexts/ElectronContext");
12
- var _useIsPageFocussed = _interopRequireDefault(require("./useIsPageFocussed"));
13
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
11
  function useKioskMode(_ref) {
15
12
  let {
16
13
  proctoredContext,
@@ -21,11 +18,7 @@ function useKioskMode(_ref) {
21
18
  } = (0, _react.useContext)(proctoredContext);
22
19
  const [connectedToInternet, setConnectedToInternet] = (0, _react.useState)(true);
23
20
  const isElectronApp = (0, _react.useContext)(_ElectronContext.ElectronContext);
24
- const {
25
- isFullscreen
26
- } = (0, _useGenericFullScreenData.default)(isElectronApp);
27
21
  const shouldShowProctoredComponent = (0, _breachUtils.showProctoredComponent)(proctorParams, permissions);
28
- const isDocumentFocused = (0, _useIsPageFocussed.default)(isElectronApp);
29
22
  (0, _react.useEffect)(() => {
30
23
  const updateOnlineStatus = () => {
31
24
  setConnectedToInternet(window.navigator.onLine);
@@ -39,11 +32,11 @@ function useKioskMode(_ref) {
39
32
  };
40
33
  }, []);
41
34
  (0, _react.useEffect)(() => {
42
- if (shouldShowProctoredComponent && isFullscreen && isElectronApp && connectedToInternet && isDocumentFocused) {
35
+ if (shouldShowProctoredComponent && isElectronApp && connectedToInternet) {
43
36
  window.electron.actions.enableKioskMode();
44
37
  } else {
45
38
  var _window$electron, _window$electron$acti;
46
39
  (_window$electron = window.electron) === null || _window$electron === void 0 ? void 0 : (_window$electron$acti = _window$electron.actions) === null || _window$electron$acti === void 0 ? void 0 : _window$electron$acti.disableKioskMode();
47
40
  }
48
- }, [isFullscreen, shouldShowProctoredComponent, isElectronApp, connectedToInternet, isDocumentFocused]);
41
+ }, [shouldShowProctoredComponent, isElectronApp, connectedToInternet]);
49
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newtonschool/react_proctoring_library",
3
- "version": "0.0.89",
3
+ "version": "0.0.91",
4
4
  "description": "Used to proctor online tests",
5
5
  "author": "ayushkagrawal,shreyachandra,weastel",
6
6
  "main": "dist/index.js",