@jetthai/cuora 1.0.46 → 1.0.48
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,10 @@
|
|
|
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.0.48](https://github.com/jetthai/cuora-module/compare/v1.0.47...v1.0.48) (2021-12-01)
|
|
6
|
+
|
|
7
|
+
### [1.0.47](https://github.com/jetthai/cuora-module/compare/v1.0.46...v1.0.47) (2021-11-24)
|
|
8
|
+
|
|
5
9
|
### [1.0.46](https://github.com/jetthai/cuora-module/compare/v1.0.45...v1.0.46) (2021-11-23)
|
|
6
10
|
|
|
7
11
|
### [1.0.45](https://github.com/jetthai/cuora-module/compare/v1.0.44...v1.0.45) (2021-11-23)
|
package/package.json
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import api from '../api/game'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'game_hot_new',
|
|
8
|
+
initial: 'preparing',
|
|
9
|
+
context: {
|
|
10
|
+
hot: {
|
|
11
|
+
id: null,
|
|
12
|
+
name: 'SYSTEM_TOP_GAME',
|
|
13
|
+
list: [],
|
|
14
|
+
games: [],
|
|
15
|
+
length: 10,
|
|
16
|
+
},
|
|
17
|
+
new: {
|
|
18
|
+
id: null,
|
|
19
|
+
name: 'SYSTEM_NEW_GAME',
|
|
20
|
+
list: [],
|
|
21
|
+
games: [],
|
|
22
|
+
length: 10,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
states: {
|
|
26
|
+
preparing: {
|
|
27
|
+
invoke: {
|
|
28
|
+
src: 'getRoomItems',
|
|
29
|
+
onDone: {
|
|
30
|
+
target: 'fetchingGames',
|
|
31
|
+
actions: 'setId',
|
|
32
|
+
},
|
|
33
|
+
onError: {
|
|
34
|
+
target: 'fetchingGames',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
fetchingGames: {
|
|
39
|
+
invoke: {
|
|
40
|
+
src: 'getGames',
|
|
41
|
+
onDone: {
|
|
42
|
+
actions: 'setGames',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
actions: {
|
|
50
|
+
setId: assign((context, event) => {
|
|
51
|
+
const { list = [] } = event.data
|
|
52
|
+
const hotId = list.find((item) => item.category === context.hot.name)?.id
|
|
53
|
+
const newId = list.find((item) => item.category === context.new.name)?.id
|
|
54
|
+
return {
|
|
55
|
+
hot: { ...context.hot, id: hotId },
|
|
56
|
+
new: { ...context.new, id: newId },
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
setGames: assign((context, event) => {
|
|
60
|
+
const { games } = event.data
|
|
61
|
+
return {
|
|
62
|
+
hot: { ...context.hot, list: games.hot, games: games.hot.slice(0, context.hot.length) },
|
|
63
|
+
new: { ...context.new, list: games.new, games: games.new.slice(0, context.new.length) },
|
|
64
|
+
}
|
|
65
|
+
}),
|
|
66
|
+
},
|
|
67
|
+
services: {
|
|
68
|
+
getRoomItems: async (context, event) => {
|
|
69
|
+
return await request.send(api.getGameCategory({ id: context.roomId }))
|
|
70
|
+
},
|
|
71
|
+
getGames: async (context, event) => {
|
|
72
|
+
const [resHot, resNew] = await Promise.all([
|
|
73
|
+
request.send(api.getGameCategory({ id: context.hot.id })),
|
|
74
|
+
request.send(api.getGameCategory({ id: context.new.id })),
|
|
75
|
+
])
|
|
76
|
+
const hotGames = resHot?.list?.map?.((item) => item.g)
|
|
77
|
+
const newGames = resNew?.list?.map?.((item) => item.g)
|
|
78
|
+
return { games: { hot: hotGames, new: newGames } }
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
)
|
|
83
|
+
}
|
package/src/machine/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import error from './error'
|
|
|
8
8
|
import game from './game'
|
|
9
9
|
import game_favorite from './game_favorite'
|
|
10
10
|
import game_search from './game_search'
|
|
11
|
+
import game_hot_new from './game_hot_new'
|
|
11
12
|
import inbox from './inbox'
|
|
12
13
|
import merge from './merge'
|
|
13
14
|
import payment_data from './payment_data'
|
|
@@ -30,6 +31,7 @@ export default {
|
|
|
30
31
|
game,
|
|
31
32
|
game_favorite,
|
|
32
33
|
game_search,
|
|
34
|
+
game_hot_new,
|
|
33
35
|
inbox,
|
|
34
36
|
merge,
|
|
35
37
|
payment_data,
|
|
@@ -17,6 +17,7 @@ export default function (request) {
|
|
|
17
17
|
requestId: null,
|
|
18
18
|
ttl: null,
|
|
19
19
|
target: {},
|
|
20
|
+
acknowledgeTtl: null,
|
|
20
21
|
newPassword: null,
|
|
21
22
|
},
|
|
22
23
|
states: {
|
|
@@ -50,11 +51,16 @@ export default function (request) {
|
|
|
50
51
|
},
|
|
51
52
|
otp: {
|
|
52
53
|
after: {
|
|
53
|
-
1000:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
1000: [
|
|
55
|
+
{
|
|
56
|
+
target: 'otp',
|
|
57
|
+
actions: 'decreaseTtl',
|
|
58
|
+
cond: (context) => context.ttl > 0,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
target: 'idle',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
58
64
|
},
|
|
59
65
|
on: {
|
|
60
66
|
ACKNOWLEDGE: {
|
|
@@ -85,6 +91,7 @@ export default function (request) {
|
|
|
85
91
|
src: 'acknowledge',
|
|
86
92
|
onDone: {
|
|
87
93
|
target: 'acknowledged',
|
|
94
|
+
actions: 'setAcknowledgeResult',
|
|
88
95
|
},
|
|
89
96
|
onError: [
|
|
90
97
|
{
|
|
@@ -98,6 +105,18 @@ export default function (request) {
|
|
|
98
105
|
},
|
|
99
106
|
},
|
|
100
107
|
acknowledged: {
|
|
108
|
+
after: {
|
|
109
|
+
1000: [
|
|
110
|
+
{
|
|
111
|
+
target: 'acknowledged',
|
|
112
|
+
actions: 'decreaseAcknowledgeTtl',
|
|
113
|
+
cond: (context) => context.acknowledgeTtl > 0,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
target: 'idle',
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
101
120
|
on: {
|
|
102
121
|
CHANGE: {
|
|
103
122
|
target: 'changing',
|
|
@@ -168,6 +187,17 @@ export default function (request) {
|
|
|
168
187
|
ttl: Math.max(context.ttl - 1, 0),
|
|
169
188
|
}
|
|
170
189
|
}),
|
|
190
|
+
setAcknowledgeResult: assign((context, event) => {
|
|
191
|
+
const { requestId, ttl, target } = event.data
|
|
192
|
+
return {
|
|
193
|
+
acknowledgeTtl: ttl,
|
|
194
|
+
}
|
|
195
|
+
}),
|
|
196
|
+
decreaseAcknowledgeTtl: assign((context, event) => {
|
|
197
|
+
return {
|
|
198
|
+
acknowledgeTtl: Math.max(context.acknowledgeTtl - 1, 0),
|
|
199
|
+
}
|
|
200
|
+
}),
|
|
171
201
|
setNewPassword: assign((context, event) => {
|
|
172
202
|
return {
|
|
173
203
|
newPassword: event.data,
|