@etsoo/react 1.3.49 → 1.3.53

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.
@@ -27,13 +27,18 @@ export function CommonPage(props) {
27
27
  Object.assign(sx, {
28
28
  padding: paddings
29
29
  });
30
+ const ref = React.useRef({});
30
31
  // Fab padding
31
32
  const fabPadding = MUGlobal.increase(MUGlobal.pagePaddings, fabPaddingAdjust);
32
33
  // Labels
33
34
  const labels = Labels.CommonPage;
34
35
  // Update
35
36
  const update = onUpdateAll
36
- ? onUpdateAll
37
+ ? async (authorized) => {
38
+ ref.current.loading = true;
39
+ await onUpdateAll(authorized);
40
+ ref.current.firstLoaded = true;
41
+ }
37
42
  : onUpdate
38
43
  ? (authorized) => {
39
44
  if (authorized == null || authorized)
@@ -45,6 +50,22 @@ export function CommonPage(props) {
45
50
  onRefresh();
46
51
  }
47
52
  : undefined;
53
+ React.useEffect(() => {
54
+ return () => {
55
+ ref.current.loading = false;
56
+ ref.current.firstLoaded = false;
57
+ };
58
+ }, []);
59
+ React.useEffect(() => {
60
+ if (ref.current.loading) {
61
+ ref.current.loading = false;
62
+ return;
63
+ }
64
+ // onUpdateAll support to load after page loaded
65
+ if (onUpdateAll != null && ref.current.firstLoaded) {
66
+ onUpdateAll();
67
+ }
68
+ });
48
69
  // Return the UI
49
70
  return (React.createElement(React.Fragment, null,
50
71
  update && React.createElement(ReactAppStateDetector, { update: update }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.3.49",
3
+ "version": "1.3.53",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -53,8 +53,8 @@
53
53
  "@etsoo/appscript": "^1.1.77",
54
54
  "@etsoo/notificationbase": "^1.0.94",
55
55
  "@etsoo/shared": "^1.0.76",
56
- "@mui/icons-material": "^5.2.1",
57
- "@mui/material": "^5.2.3",
56
+ "@mui/icons-material": "^5.2.4",
57
+ "@mui/material": "^5.2.4",
58
58
  "@reach/router": "^1.3.4",
59
59
  "@types/pica": "^5.1.3",
60
60
  "@types/pulltorefreshjs": "^0.1.5",
@@ -64,7 +64,7 @@
64
64
  "@types/react-dom": "^17.0.11",
65
65
  "@types/react-input-mask": "^3.0.1",
66
66
  "@types/react-window": "^1.8.5",
67
- "pica": "^9.0.0",
67
+ "pica": "^9.0.1",
68
68
  "pulltorefreshjs": "^0.1.22",
69
69
  "react": "^17.0.2",
70
70
  "react-avatar-editor": "^12.0.0",
@@ -75,10 +75,10 @@
75
75
  },
76
76
  "devDependencies": {
77
77
  "@babel/cli": "^7.16.0",
78
- "@babel/core": "^7.16.0",
79
- "@babel/plugin-transform-runtime": "^7.16.4",
80
- "@babel/preset-env": "^7.16.4",
81
- "@babel/runtime-corejs3": "^7.16.3",
78
+ "@babel/core": "^7.16.5",
79
+ "@babel/plugin-transform-runtime": "^7.16.5",
80
+ "@babel/preset-env": "^7.16.5",
81
+ "@babel/runtime-corejs3": "^7.16.5",
82
82
  "@types/jest": "^27.0.3",
83
83
  "@types/react-test-renderer": "^17.0.1",
84
84
  "@typescript-eslint/eslint-plugin": "^5.7.0",
@@ -90,6 +90,6 @@
90
90
  "jest": "^27.4.5",
91
91
  "react-test-renderer": "^17.0.2",
92
92
  "ts-jest": "^27.1.1",
93
- "typescript": "^4.5.3"
93
+ "typescript": "^4.5.4"
94
94
  }
95
95
  }
@@ -50,6 +50,11 @@ export function CommonPage(props: CommonPageProps) {
50
50
  padding: paddings
51
51
  });
52
52
 
53
+ const ref = React.useRef<{
54
+ firstLoaded?: boolean;
55
+ loading?: boolean;
56
+ }>({});
57
+
53
58
  // Fab padding
54
59
  const fabPadding = MUGlobal.increase(
55
60
  MUGlobal.pagePaddings,
@@ -61,7 +66,11 @@ export function CommonPage(props: CommonPageProps) {
61
66
 
62
67
  // Update
63
68
  const update = onUpdateAll
64
- ? onUpdateAll
69
+ ? async (authorized?: boolean) => {
70
+ ref.current.loading = true;
71
+ await onUpdateAll(authorized);
72
+ ref.current.firstLoaded = true;
73
+ }
65
74
  : onUpdate
66
75
  ? (authorized?: boolean) => {
67
76
  if (authorized == null || authorized) onUpdate();
@@ -72,6 +81,25 @@ export function CommonPage(props: CommonPageProps) {
72
81
  }
73
82
  : undefined;
74
83
 
84
+ React.useEffect(() => {
85
+ return () => {
86
+ ref.current.loading = false;
87
+ ref.current.firstLoaded = false;
88
+ };
89
+ }, []);
90
+
91
+ React.useEffect(() => {
92
+ if (ref.current.loading) {
93
+ ref.current.loading = false;
94
+ return;
95
+ }
96
+
97
+ // onUpdateAll support to load after page loaded
98
+ if (onUpdateAll != null && ref.current.firstLoaded) {
99
+ onUpdateAll();
100
+ }
101
+ });
102
+
75
103
  // Return the UI
76
104
  return (
77
105
  <React.Fragment>