awing-library 2.1.131 → 2.1.132

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.
@@ -52,6 +52,7 @@ var jsx_runtime_1 = require("react/jsx-runtime");
52
52
  var material_1 = require("@mui/material");
53
53
  var AWING_1 = require("../../../../AWING");
54
54
  var Context_1 = require("../../../../Context");
55
+ var lodash_1 = require("lodash");
55
56
  var react_1 = __importDefault(require("react"));
56
57
  var recoil_1 = require("recoil");
57
58
  var ViewTemplate_1 = __importDefault(require("../../../ViewTemplate"));
@@ -70,6 +71,7 @@ var ViewContent = function (_a) {
70
71
  var _h = react_1.default.useState(''), scriptValidationTemplate = _h[0], setScriptValidationTemplate = _h[1];
71
72
  var _j = react_1.default.useState(''), scriptAutoField = _j[0], setScriptAutoField = _j[1];
72
73
  var _k = react_1.default.useState(false), loading = _k[0], setLoading = _k[1];
74
+ var isUniq = react_1.default.useRef(false);
73
75
  var rootDirectory = (0, recoil_1.useRecoilValue)(Recoil_1.pageRootDeirectory);
74
76
  // const [events, setEvent] = useRecoilState(pageEventState)
75
77
  react_1.default.useEffect(function () {
@@ -84,10 +86,24 @@ var ViewContent = function (_a) {
84
86
  }
85
87
  // eslint-disable-next-line react-hooks/exhaustive-deps
86
88
  }, [viewInfoData.templateId]);
89
+ react_1.default.useEffect(function () {
90
+ if (!isUniq.current) {
91
+ onChange(['events'], (0, lodash_1.uniqBy)(viewInfoData.events, function (a) {
92
+ return JSON.stringify({
93
+ event: a.event,
94
+ viewNumber: a.viewNumber,
95
+ pageId: a.pageId,
96
+ });
97
+ }));
98
+ isUniq.current = true;
99
+ }
100
+ // eslint-disable-next-line react-hooks/exhaustive-deps
101
+ }, [viewInfoData.events]);
87
102
  var handleResData = function (res) {
88
103
  var _a;
89
104
  onChange(['viewDatas'], (0, Utils_1.getTemplateDatas)(res.templateParameters, viewInfoData, pageId, viewNumber));
90
105
  onChange(['events'], __spreadArray(__spreadArray([], (_a = res === null || res === void 0 ? void 0 : res.templateEvents) === null || _a === void 0 ? void 0 : _a.map(function (item) { return ({ id: item.id, event: item.event, pageId: pageId, protected: true }); }), true), viewInfoData.events, true));
106
+ isUniq.current = false;
91
107
  onChange(['templateValidation'], res.template.validation);
92
108
  onChange(['templateHandleEvent'], res.template.autoField);
93
109
  setScriptValidationTemplate(res.template.validation || '');
@@ -152,6 +168,7 @@ var ViewContent = function (_a) {
152
168
  appHelper.snackbar('error', errorMessage);
153
169
  }, onUploadFile: onUploadFile, onChangeEvent: function (values) {
154
170
  onChange(['events'], values);
171
+ isUniq.current = false;
155
172
  } }) }) })) })) }));
156
173
  };
157
174
  exports.default = ViewContent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.131",
3
+ "version": "2.1.132",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",