@capytale/meta-player 0.5.6 → 0.5.8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capytale/meta-player",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite",
package/src/App.tsx CHANGED
@@ -11,6 +11,7 @@ import { classNames } from "primereact/utils";
11
11
  import {
12
12
  selectIsPedagoVisible,
13
13
  selectOrientation,
14
+ selectShowSaveForStudents,
14
15
  toggleIsPedagoVisible,
15
16
  } from "./features/layout/layoutSlice";
16
17
  import { FC, KeyboardEvent, PropsWithChildren, useCallback } from "react";
@@ -20,6 +21,7 @@ import {
20
21
  selectHasInstructions,
21
22
  selectIsDirty,
22
23
  selectMode,
24
+ selectShowSaveButton,
23
25
  } from "./features/activityData/activityDataSlice";
24
26
  import settings from "./settings";
25
27
  import ReviewNavbar from "./features/navbar/review-navbar";
@@ -41,14 +43,19 @@ const App: FC<AppProps> = (props) => {
41
43
  const isDirty = useAppSelector(selectIsDirty);
42
44
  const save = useSave();
43
45
 
46
+ const showSaveButton = useAppSelector(selectShowSaveButton);
47
+ const showSaveForStudents = useAppSelector(selectShowSaveForStudents);
48
+ const hasSaveButton =
49
+ showSaveButton && !(mode === "assignment" && !showSaveForStudents);
50
+
44
51
  const handleCtrlS = useCallback(
45
52
  (e: KeyboardEvent<HTMLDivElement>) => {
46
53
  if ((e.ctrlKey || e.metaKey) && e.key === "s") {
47
54
  e.preventDefault();
48
- save(); // Checks if can save inside of save()
55
+ if (hasSaveButton && isDirty) save(); // Checks if can save inside of save()
49
56
  }
50
57
  },
51
- [isDirty, save],
58
+ [hasSaveButton, isDirty, save],
52
59
  );
53
60
 
54
61
  const pedagoOpenLabel = hasPedago
@@ -1,7 +1,6 @@
1
1
  import { useCallback } from "react";
2
2
  import { useAppDispatch, useAppSelector } from "../../app/hooks";
3
- import { selectShowSaveForStudents } from "../layout/layoutSlice";
4
- import { selectHasEvaluations, selectIsDirty, selectMode, selectPreventEditIfHasEvaluations, selectShowSaveButton, setIsPlayerDirty, setSaveState } from "./activityDataSlice";
3
+ import { selectHasEvaluations, selectMode, selectPreventEditIfHasEvaluations, setIsPlayerDirty, setSaveState } from "./activityDataSlice";
5
4
 
6
5
  export const useNotifyIsDirty = () => {
7
6
  const dispatch = useAppDispatch();
@@ -9,30 +8,17 @@ export const useNotifyIsDirty = () => {
9
8
  };
10
9
 
11
10
  export const useCanSave = () => {
12
- const isDirty = useAppSelector(selectIsDirty);
13
11
  const preventEditIfHasEvaluations = useAppSelector(
14
12
  selectPreventEditIfHasEvaluations,
15
13
  );
16
14
  const hasEvaluations = useAppSelector(selectHasEvaluations);
17
15
 
18
16
  const mode = useAppSelector(selectMode);
19
- const showSaveButton = useAppSelector(selectShowSaveButton);
20
- const showSaveForStudents = useAppSelector(selectShowSaveForStudents);
21
- const hasSaveButton =
22
- showSaveButton && !(mode === "assignment" && !showSaveForStudents);
23
-
24
- if (!hasSaveButton) {
25
- return false;
26
- }
27
17
 
28
18
  if (mode === "create" && hasEvaluations && preventEditIfHasEvaluations) {
29
19
  return false;
30
20
  }
31
21
 
32
- if (!isDirty) {
33
- return false;
34
- }
35
-
36
22
  return true;
37
23
  }
38
24