awing-library 2.1.25 → 2.1.26

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.
@@ -70,11 +70,14 @@ var NotificationDetail = function (props) {
70
70
  status: Constant_1.Constants.ALL_STATUS,
71
71
  }), valueFilter = _a[0], setValueFilter = _a[1];
72
72
  var _b = react_1.default.useState(false), isLoading = _b[0], setIsLoading = _b[1];
73
- var _c = react_1.default.useState(-1), count = _c[0], setCount = _c[1];
74
- var _d = (0, react_1.useState)([]), notificationMessage = _d[0], setNotificationMessage = _d[1];
73
+ var _c = react_1.default.useState(0), count = _c[0], setCount = _c[1];
74
+ var _d = react_1.default.useState(true), isInViewPort = _d[0], setIsInViewPort = _d[1];
75
+ var _e = (0, react_1.useState)([]), notificationMessage = _e[0], setNotificationMessage = _e[1];
75
76
  var totalItemCount = (0, react_1.useRef)(0);
76
77
  (0, react_1.useEffect)(function () {
77
- var observer = new IntersectionObserver(handleIntersection);
78
+ var observer = new IntersectionObserver(function (entries) {
79
+ entries.map(function (entry) { return entry.isIntersecting; }).forEach(setIsInViewPort);
80
+ });
78
81
  var lastItem = document.getElementById('last-Item');
79
82
  if (observer && lastItem) {
80
83
  setIsLoading(true);
@@ -83,40 +86,40 @@ var NotificationDetail = function (props) {
83
86
  return function () {
84
87
  if (observer) {
85
88
  observer.disconnect();
89
+ observer = null;
86
90
  }
87
91
  };
92
+ // eslint-disable-next-line react-hooks/exhaustive-deps
88
93
  }, []);
89
94
  (0, react_1.useEffect)(function () {
90
- if (count >= 0 &&
91
- (totalItemCount.current > notificationMessage.length ||
92
- notificationMessage.length === 0)) {
93
- setIsLoading(true);
94
- service
95
- .notificationsPaging(count, Constant_1.Constants.PAGE_SIZE_DEFAULT, valueFilter.textSearch, valueFilter.status, [])
96
- .then(function (res) {
97
- setNotificationMessage(function (prevMessages) {
98
- var newItems = res.items.filter(function (newItem) {
99
- return !prevMessages.some(function (prevItem) { return prevItem.id === newItem.id; });
100
- });
101
- return __spreadArray(__spreadArray([], prevMessages, true), newItems, true);
95
+ setIsLoading(true);
96
+ service
97
+ .notificationsPaging(count, Constant_1.Constants.PAGE_SIZE_DEFAULT, valueFilter.textSearch, valueFilter.status, [])
98
+ .then(function (res) {
99
+ setNotificationMessage(function (prevMessages) {
100
+ var newItems = res.items.filter(function (newItem) {
101
+ return !prevMessages.some(function (prevItem) { return prevItem.id === newItem.id; });
102
102
  });
103
- totalItemCount.current = res.totalItemCount;
104
- })
105
- .finally(function () {
106
- setIsLoading(false);
103
+ return __spreadArray(__spreadArray([], prevMessages, true), newItems, true);
107
104
  });
108
- }
105
+ totalItemCount.current = res.totalItemCount;
106
+ })
107
+ .finally(function () {
108
+ setIsLoading(false);
109
+ });
109
110
  // eslint-disable-next-line react-hooks/exhaustive-deps
110
111
  }, [count, valueFilter.textSearch, valueFilter.status]);
111
- var handleIntersection = (0, react_1.useCallback)(function (entries) {
112
- var firsEntry = entries[0];
113
- if (firsEntry.isIntersecting) {
112
+ (0, react_1.useEffect)(function () {
113
+ if (isInViewPort &&
114
+ notificationMessage.length < totalItemCount.current &&
115
+ !isLoading) {
114
116
  setCount(function (old) { return old + 1; });
115
117
  }
116
- }, []);
118
+ // eslint-disable-next-line react-hooks/exhaustive-deps
119
+ }, [isInViewPort]);
117
120
  var handleValueFilter = function (textSearch, tabs) {
118
- textSearch.length === 0 ? setCount(0) : setCount(-1);
119
121
  setNotificationMessage([]);
122
+ setCount(0);
120
123
  totalItemCount.current = 0;
121
124
  setValueFilter({
122
125
  textSearch: textSearch,
@@ -76,7 +76,7 @@ export interface NotificationMessageField {
76
76
  export interface PagedList_1OfNotificationMessage {
77
77
  items?: NotificationMessage[] | undefined;
78
78
  pageCount?: number;
79
- totalItemCount?: number;
79
+ totalItemCount: number;
80
80
  pageNumber?: number;
81
81
  pageSize?: number;
82
82
  hasPreviousPage?: boolean;
@@ -116,7 +116,7 @@ var ViewContent = function (_a) {
116
116
  }, [events]);
117
117
  var handleResData = function (res) {
118
118
  onChange(['viewDatas'], (0, Utils_1.getTemplateDatas)(res.templateParameters, viewInfoData, pageId, viewNumber));
119
- setEvent(function (prev) { return __spreadArray(__spreadArray([], res.templateEvents.map(function (item) { return ({ id: item.id, event: item.event, viewNumber: viewNumber + 1, pageId: pageId, protected: true }); }), true), prev, true); });
119
+ setEvent(function (prev) { var _a; return __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, viewNumber: viewNumber + 1, pageId: pageId, protected: true }); }), true), prev, true); });
120
120
  isUniq.current = false;
121
121
  onChange(['templateValidation'], res.template.validation);
122
122
  onChange(['templateHandleEvent'], res.template.autoField);
@@ -161,7 +161,7 @@
161
161
  },
162
162
  "InvalidMessage": {
163
163
  "InvalidNotExistedUsername": "Username is invalid or not existed",
164
- "InvalidAccountConnected": "Account has been added to this domain!"
164
+ "InvalidAccountConnected": "Account is already existed!"
165
165
  },
166
166
  "ViewTemplate": {
167
167
  "Value": "Value",
@@ -125,7 +125,7 @@
125
125
  },
126
126
  "InvalidMessage": {
127
127
  "InvalidNotExistedUsername": "Tài khoản không tồn tại",
128
- "InvalidAccountConnected": "Tài khoản đã được gắn vào domain này rồi!"
128
+ "InvalidAccountConnected": "Tài khoản đã tồn tại!"
129
129
  },
130
130
  "User": {
131
131
  "Username": "Tài khoản",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.25",
3
+ "version": "2.1.26",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",