@jetthai/cuora 1.1.99 → 1.1.100

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/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.1.100](https://github.com/jetthai/cuora-module/compare/v1.1.99...v1.1.100) (2023-05-22)
6
+
5
7
  ### [1.1.99](https://github.com/jetthai/cuora-module/compare/v1.1.97...v1.1.99) (2023-05-22)
6
8
 
7
9
  ### [1.1.98](https://github.com/jetthai/cuora-module/compare/v1.1.97...v1.1.98) (2023-05-18)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.99",
3
+ "version": "1.1.100",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -7,9 +7,23 @@ export default function (request) {
7
7
  id: 'favorite',
8
8
  initial: 'fetching',
9
9
  context: {
10
+ auth: false,
10
11
  list: [],
11
12
  },
12
13
  states: {
14
+ idle: {},
15
+ checking: {
16
+ always: [
17
+ {
18
+ target: 'fetching',
19
+ cond: 'hasAuth',
20
+ },
21
+ {
22
+ target: 'idle',
23
+ actions: 'clearList',
24
+ },
25
+ ],
26
+ },
13
27
  fetching: {
14
28
  invoke: {
15
29
  src: 'fetchList',
@@ -17,7 +31,7 @@ export default function (request) {
17
31
  actions: 'setList',
18
32
  },
19
33
  onError: {
20
- actions: assign({ list: [] }),
34
+ actions: 'clearList',
21
35
  },
22
36
  },
23
37
  },
@@ -68,6 +82,13 @@ export default function (request) {
68
82
  actions: 'removeFromList',
69
83
  cond: 'isExist',
70
84
  },
85
+ SET_AUTH: [
86
+ {
87
+ target: 'checking',
88
+ actions: 'setAuth',
89
+ cond: 'isAuthChanged',
90
+ },
91
+ ],
71
92
  },
72
93
  },
73
94
  {
@@ -77,6 +98,11 @@ export default function (request) {
77
98
  list: event.data,
78
99
  }
79
100
  }),
101
+ clearList: assign((context, event) => {
102
+ return {
103
+ list: [],
104
+ }
105
+ }),
80
106
  addToList: assign((context, event) => {
81
107
  return {
82
108
  list: [...context.list, event.data],
@@ -87,10 +113,17 @@ export default function (request) {
87
113
  list: context.list.filter((item) => item.gameCode !== event.data.gameCode),
88
114
  }
89
115
  }),
116
+ setAuth: assign((context, event) => {
117
+ return {
118
+ auth: !!event.data,
119
+ }
120
+ }),
90
121
  },
91
122
  guards: {
92
123
  isExist: (context, event) => context.list.some((item) => item.gameCode === event.data.gameCode),
93
124
  isNotExist: (context, event) => !context.list.some((item) => item.gameCode === event.data.gameCode),
125
+ isAuthChanged: (context, event) => context.auth !== !!event.data,
126
+ hasAuth: (context, event) => context.auth,
94
127
  },
95
128
  services: {
96
129
  add: async (context, event) => {
@@ -9,7 +9,7 @@ export default function (request) {
9
9
  id: 'reward_cash',
10
10
  type: 'parallel',
11
11
  context: {
12
- hasAuth: false,
12
+ auth: false,
13
13
  otherRewardList: [],
14
14
  pointsRewardList: [],
15
15
  rewardList: [],
@@ -27,7 +27,7 @@ export default function (request) {
27
27
  {
28
28
  target: 'loading',
29
29
  cond: (context, event) => {
30
- return context.hasAuth
30
+ return context.auth
31
31
  },
32
32
  },
33
33
  ],
@@ -137,8 +137,7 @@ export default function (request) {
137
137
  target: '.timer.checking',
138
138
  actions: 'setAuth',
139
139
  cond: (context, event) => {
140
- console.log(context.hasAuth, event.data)
141
- return context.hasAuth !== event.data
140
+ return context.auth !== !!event.data
142
141
  },
143
142
  },
144
143
  },
@@ -146,7 +145,7 @@ export default function (request) {
146
145
  {
147
146
  actions: {
148
147
  setAuth: assign((context, event) => {
149
- return { hasAuth: event.data }
148
+ return { auth: !!event.data }
150
149
  }),
151
150
  setRewardList: assign((context, event) => {
152
151
  return {