@newtonschool/react_proctoring_library 0.0.6 → 0.0.7

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.
@@ -45,13 +45,14 @@ const ProctorApp = _ref => {
45
45
  const statistics = (0, _react.useRef)(_defaults.INITIAL_STATISTICS);
46
46
  const [audioPermission, setAudioPermission] = (0, _react.useState)(false);
47
47
  const [videoPermission, setVideoPermission] = (0, _react.useState)(false);
48
+ const firstFullScreenDone = (0, _react.useRef)(false);
48
49
  const {
49
50
  isFullscreen,
50
51
  setFullscreen,
51
52
  fullScreenExitCount
52
- } = (0, _hooks.useFullscreenData)();
53
+ } = (0, _hooks.useFullscreenData)(firstFullScreenDone);
53
54
  const [userCount, lookedAwayCount] = (0, _useWebcamData.default)(webcamReference, canvasReference);
54
- const tabSwitchCount = (0, _hooks.useTabSwitchCount)();
55
+ const tabSwitchCount = (0, _hooks.useTabSwitchCount)(firstFullScreenDone);
55
56
  (0, _react.useEffect)(() => {
56
57
  (0, _utils.removeStatsFromLocalStorage)(proctoringIdentifier);
57
58
  }, [proctoringIdentifier]);
@@ -15,9 +15,8 @@ var _utils = require("../utils");
15
15
 
16
16
  const browserFullscreenElementProp = (0, _utils.getBrowserFullscreenElementProp)();
17
17
 
18
- function useFullscreenData() {
18
+ function useFullscreenData(firstFullScreenDone) {
19
19
  const fullScreenElement = (0, _react.useRef)(document.documentElement);
20
- const firstFullScreenDone = (0, _react.useRef)(false);
21
20
  const [isFullscreen, setIsFullscreen] = (0, _react.useState)(document[browserFullscreenElementProp] != null);
22
21
  const [fullScreenExitCount, setFullScreenExitCount] = (0, _react.useState)(_defaults.initialValues.fullScreenExitCount);
23
22
  (0, _react.useEffect)(() => {
@@ -28,7 +27,7 @@ function useFullscreenData() {
28
27
  if (!firstFullScreenDone.current) {
29
28
  firstFullScreenDone.current = true;
30
29
  }
31
- }, [isFullscreen]);
30
+ }, [isFullscreen, firstFullScreenDone]);
32
31
 
33
32
  const setFullscreen = () => {
34
33
  if (!fullScreenElement || !fullScreenElement.current) {
@@ -13,13 +13,13 @@ var _defaults = require("../constants/defaults");
13
13
 
14
14
  var _ = require(".");
15
15
 
16
- function useTabSwitchCount() {
16
+ function useTabSwitchCount(firstFullScreenDone) {
17
17
  const isTabVisible = (0, _.usePageVisibility)();
18
18
  const [tabSwitchCount, setTabSwitchCount] = (0, _react.useState)(_defaults.initialValues.tabSwitchCount);
19
19
  (0, _react.useEffect)(() => {
20
- if (!isTabVisible) {
20
+ if (!isTabVisible && firstFullScreenDone.current) {
21
21
  setTabSwitchCount(tabSwitchCount => tabSwitchCount + 1);
22
22
  }
23
- }, [isTabVisible]);
23
+ }, [isTabVisible, firstFullScreenDone]);
24
24
  return tabSwitchCount;
25
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newtonschool/react_proctoring_library",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Used to proctor online tests",
5
5
  "author": "ayushkagrawal,shreyachandra",
6
6
  "main": "dist/index.js",