@etsoo/react 1.3.56 → 1.3.60

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.
@@ -13,6 +13,7 @@ import { InputDialogProps } from './InputDialogProps';
13
13
  * Case 1: undefined, when refresh the whole page
14
14
  * Case 2: false, unauthorized
15
15
  * Case 3: true, authorized or considered as authorized (maynot, like token expiry)
16
+ * Case 4: property or properties changed
16
17
  * @param props Props
17
18
  * @returns Component
18
19
  */
@@ -13,6 +13,7 @@ let globalApp;
13
13
  * Case 1: undefined, when refresh the whole page
14
14
  * Case 2: false, unauthorized
15
15
  * Case 3: true, authorized or considered as authorized (maynot, like token expiry)
16
+ * Case 4: property or properties changed
16
17
  * @param props Props
17
18
  * @returns Component
18
19
  */
@@ -24,6 +25,7 @@ export function ReactAppStateDetector(props) {
24
25
  ? { state: {} }
25
26
  : React.useContext(globalApp.userState.context);
26
27
  // Match fields
28
+ const authorized = state.authorized;
27
29
  const changedFields = state.lastChangedFields;
28
30
  let matchedFields;
29
31
  if (targetFields == null || changedFields == null) {
@@ -36,11 +38,12 @@ export function ReactAppStateDetector(props) {
36
38
  matchedFields === null || matchedFields === void 0 ? void 0 : matchedFields.push(targetField);
37
39
  });
38
40
  }
41
+ console.log('ReactAppStateDetector', changedFields, targetFields, matchedFields);
39
42
  // Ready
40
43
  React.useEffect(() => {
41
44
  // Callback
42
- update(state.authorized, matchedFields);
43
- }, [state.authorized, matchedFields]);
45
+ update(authorized, matchedFields);
46
+ }, [authorized, matchedFields]);
44
47
  // return
45
48
  return React.createElement(React.Fragment);
46
49
  }
@@ -30,6 +30,7 @@ export class UserState {
30
30
  const lastChangedFields = state.authorized && action.user
31
31
  ? this.getChangedFields(action.user, state)
32
32
  : [];
33
+ console.log('UserState', state, action.user, lastChangedFields);
33
34
  return {
34
35
  ...action.user,
35
36
  authorized: true,
@@ -68,6 +69,7 @@ export class UserState {
68
69
  }
69
70
  getChangedFields(input, init) {
70
71
  return Utils.objectUpdated(input, init, [
72
+ 'authorized',
71
73
  'seconds',
72
74
  'lastChangedFields'
73
75
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.3.56",
3
+ "version": "1.3.60",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -37,6 +37,7 @@ let globalApp: IReactApp<IAppSettings, any, IPageData>;
37
37
  * Case 1: undefined, when refresh the whole page
38
38
  * Case 2: false, unauthorized
39
39
  * Case 3: true, authorized or considered as authorized (maynot, like token expiry)
40
+ * Case 4: property or properties changed
40
41
  * @param props Props
41
42
  * @returns Component
42
43
  */
@@ -53,6 +54,7 @@ export function ReactAppStateDetector(props: IStateProps) {
53
54
  );
54
55
 
55
56
  // Match fields
57
+ const authorized = state.authorized;
56
58
  const changedFields = state.lastChangedFields;
57
59
  let matchedFields: string[] | undefined;
58
60
  if (targetFields == null || changedFields == null) {
@@ -65,11 +67,18 @@ export function ReactAppStateDetector(props: IStateProps) {
65
67
  });
66
68
  }
67
69
 
70
+ console.log(
71
+ 'ReactAppStateDetector',
72
+ changedFields,
73
+ targetFields,
74
+ matchedFields
75
+ );
76
+
68
77
  // Ready
69
78
  React.useEffect(() => {
70
79
  // Callback
71
- update(state.authorized, matchedFields);
72
- }, [state.authorized, matchedFields]);
80
+ update(authorized, matchedFields);
81
+ }, [authorized, matchedFields]);
73
82
 
74
83
  // return
75
84
  return React.createElement(React.Fragment);
@@ -78,6 +78,12 @@ export class UserState<D extends IUser> {
78
78
  state.authorized && action.user
79
79
  ? this.getChangedFields(action.user, state)
80
80
  : [];
81
+ console.log(
82
+ 'UserState',
83
+ state,
84
+ action.user,
85
+ lastChangedFields
86
+ );
81
87
  return {
82
88
  ...action.user!,
83
89
  authorized: true,
@@ -124,6 +130,7 @@ export class UserState<D extends IUser> {
124
130
 
125
131
  private getChangedFields(input: {}, init: {}) {
126
132
  return Utils.objectUpdated(input, init, [
133
+ 'authorized',
127
134
  'seconds',
128
135
  'lastChangedFields'
129
136
  ]);