@jetthai/cuora 1.1.290-dev-1 → 1.1.290-dev-3

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.1.290-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.290-dev-2...v1.1.290-dev-3) (2024-08-06)
6
+
7
+ ### [1.1.290-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.290-dev-1...v1.1.290-dev-2) (2024-08-01)
8
+
5
9
  ### [1.1.290-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.290-dev...v1.1.290-dev-1) (2024-08-01)
6
10
 
7
11
  ### [1.1.290-dev](https://github.com/jetthai/cuora-module/compare/v1.1.290...v1.1.290-dev) (2024-08-01)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.290-dev-1",
3
+ "version": "1.1.290-dev-3",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -6,6 +6,12 @@ export default {
6
6
  params: { appSecret, include },
7
7
  isPublic: true,
8
8
  }),
9
+ getJackpotList: ({ appSecret }) => ({
10
+ url: 'activities/jackpot/list',
11
+ method: 'get',
12
+ params: { appSecret },
13
+ isPublic: true,
14
+ }),
9
15
  getTournamentDetail: ({ activityNo, appSecret }) => ({
10
16
  url: 'tournament/detail',
11
17
  method: 'get',
@@ -7,6 +7,7 @@ import diamond_shop_activity_vn from './diamond_shop_activity_vn.js'
7
7
  import diamond_shop_activity_cash from './diamond_shop_activity_cash.js'
8
8
  import fafafa_activity from './fafafa_activity.js'
9
9
  import invite_friends_activity from './invite_friends_activity.js'
10
+ import jackpot from './jackpot.js'
10
11
  import friend_invite_friends_activity from './friend_invite_friends_activity.js'
11
12
  import ranking_activity from './ranking_activity.js'
12
13
  import return_bonus_activity from './return_bonus_activity.js'
@@ -32,6 +33,7 @@ export default {
32
33
  diamond_shop_activity_cash,
33
34
  fafafa_activity,
34
35
  invite_friends_activity,
36
+ jackpot,
35
37
  friend_invite_friends_activity,
36
38
  ranking_activity,
37
39
  return_bonus_activity,
@@ -0,0 +1,74 @@
1
+ import { createMachine, assign } from 'xstate'
2
+ import activity from '../../api/activity.js'
3
+
4
+ export default function (request) {
5
+ const { appSecret } = request.config
6
+ return createMachine(
7
+ {
8
+ id: 'jackpot',
9
+ initial: 'pending',
10
+ context: {
11
+ tick: 6000,
12
+ jackpotList: [],
13
+ jackpotEnable: false,
14
+ },
15
+ states: {
16
+ fetchingList: {
17
+ invoke: {
18
+ src: 'fetchList',
19
+ onDone: {
20
+ target: 'pending',
21
+ actions: ['setJackpotList'],
22
+ },
23
+ onError: {
24
+ target: 'pending',
25
+ },
26
+ },
27
+ },
28
+ pending: {
29
+ after: {
30
+ TIMEOUT: {
31
+ target: 'fetchingList',
32
+ },
33
+ },
34
+ on: {
35
+ SET_JACKPOT_ENABLE: {
36
+ actions: 'setJackpotEnable',
37
+ target: 'fetchingList',
38
+ },
39
+ },
40
+ },
41
+ },
42
+ },
43
+ {
44
+ actions: {
45
+ setJackpotList: assign((context, event) => {
46
+ const { jackpotList } = event.data
47
+ return {
48
+ jackpotList,
49
+ }
50
+ }),
51
+ setJackpotEnable: assign((context, event) => {
52
+ return {
53
+ jackpotEnable: event.data,
54
+ }
55
+ }),
56
+ },
57
+ delays: {
58
+ TIMEOUT: (context, event) => {
59
+ const { tick } = context
60
+ return tick * 10
61
+ },
62
+ },
63
+ services: {
64
+ fetchList: async (context, event) => {
65
+ const { jackpotEnable } = context
66
+
67
+ const [jackpotList] = await Promise.all([jackpotEnable ? request.send(activity.getJackpotList({ appSecret })) : { data: [] }])
68
+
69
+ return { jackpotList: jackpotList.data }
70
+ },
71
+ },
72
+ }
73
+ )
74
+ }
@@ -79,6 +79,9 @@ export default function (request) {
79
79
  target: 'connecting',
80
80
  actions: ['setGameInfo', 'setLang'],
81
81
  },
82
+ UPDATE: {
83
+ target: 'updating',
84
+ },
82
85
  },
83
86
  },
84
87
  batchFetching: {
@@ -118,6 +121,18 @@ export default function (request) {
118
121
  { target: 'idle' },
119
122
  ],
120
123
  },
124
+ updating: {
125
+ invoke: {
126
+ src: 'updatePageContent',
127
+ onDone: {
128
+ target: 'idle',
129
+ actions: 'swapContent',
130
+ },
131
+ onError: {
132
+ target: 'idle',
133
+ },
134
+ },
135
+ },
121
136
  connecting: {
122
137
  invoke: {
123
138
  src: 'connectGame',
@@ -342,7 +357,7 @@ export default function (request) {
342
357
  if (room.categoryId === GAME_SEARCH) {
343
358
  return
344
359
  } else if (additionEnable) {
345
- const [content, addition] = event.data
360
+ const [content, addition = {}] = event.data
346
361
  return {
347
362
  content: {
348
363
  ...context.content,