@jetthai/cuora 1.0.97 → 1.0.98

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.0.98](https://github.com/jetthai/cuora-module/compare/v1.0.97...v1.0.98) (2022-03-09)
6
+
5
7
  ### [1.0.97](https://github.com/jetthai/cuora-module/compare/v1.0.96...v1.0.97) (2022-03-09)
6
8
 
7
9
  ### [1.0.96](https://github.com/jetthai/cuora-module/compare/v1.0.95...v1.0.96) (2022-03-09)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.97",
3
+ "version": "1.0.98",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -11,13 +11,17 @@ export default function (request) {
11
11
  activityDetail: null,
12
12
  callback: () => {},
13
13
  },
14
- initial: 'idle',
14
+ initial: 'fetching',
15
15
  states: {
16
- idle: {
17
- on: {
18
- SET_ACTIVITY_NO: {
16
+ fetching: {
17
+ invoke: {
18
+ src: 'fetchActivityList',
19
+ onDone: {
19
20
  target: 'loading',
20
- actions: 'setActivityNo',
21
+ actions: 'setDiamondShopActivities',
22
+ },
23
+ onError: {
24
+ target: 'idle',
21
25
  },
22
26
  },
23
27
  },
@@ -43,6 +47,13 @@ export default function (request) {
43
47
  activityNo: event.data,
44
48
  }
45
49
  }),
50
+ setDiamondShopActivities: assign((context, event) => {
51
+ const rankActivities = event.data.filter((item) => item.activityType === 92)
52
+ return {
53
+ rankActivities,
54
+ activityNo: rankActivities?.[0]?.activityNo,
55
+ }
56
+ }),
46
57
  setActivityDetail: assign((context, event) => {
47
58
  return {
48
59
  activityDetail: event.data,
@@ -39,17 +39,12 @@ export default function (request) {
39
39
  idle: {
40
40
  enter: 'clearGameInfo',
41
41
  on: {
42
- // todo - deprecated
43
- ENTER_ROOM: {
44
- target: 'loading',
45
- actions: 'setRoomId',
46
- cond: (context, event) => {
47
- return context.roomId !== event.roomId
48
- },
49
- },
50
42
  SET_ROOM: {
51
43
  target: 'loading',
52
44
  actions: 'setRoom',
45
+ cond: (context, event) => {
46
+ return context.room?.id !== event.data?.id
47
+ },
53
48
  },
54
49
  ENTER_GAME: {
55
50
  target: 'connecting',
@@ -8,7 +8,7 @@ export default function (request) {
8
8
  initial: 'preparing',
9
9
  context: {
10
10
  menu: {},
11
- roomId: null,
11
+ room: null,
12
12
  roomHistory: [],
13
13
  },
14
14
  states: {
@@ -29,28 +29,28 @@ export default function (request) {
29
29
  initial: 'home',
30
30
  states: {
31
31
  home: {
32
- entry: assign({ roomId: (context, event) => context.menu['home'] }),
32
+ entry: assign({ room: (context, event) => context.menu['home'] }),
33
33
  },
34
34
  favorite: {
35
- entry: assign({ roomId: (context, event) => context.menu['favorite'] }),
35
+ entry: assign({ room: (context, event) => context.menu['favorite'] }),
36
36
  },
37
37
  hot: {
38
- entry: assign({ roomId: (context, event) => context.menu['hot'] }),
38
+ entry: assign({ room: (context, event) => context.menu['hot'] }),
39
39
  },
40
40
  new: {
41
- entry: assign({ roomId: (context, event) => context.menu['new'] }),
41
+ entry: assign({ room: (context, event) => context.menu['new'] }),
42
42
  },
43
43
  slot: {
44
- entry: assign({ roomId: (context, event) => context.menu['slot'] }),
44
+ entry: assign({ room: (context, event) => context.menu['slot'] }),
45
45
  },
46
46
  fish: {
47
- entry: assign({ roomId: (context, event) => context.menu['fish'] }),
47
+ entry: assign({ room: (context, event) => context.menu['fish'] }),
48
48
  },
49
49
  arcade: {
50
- entry: assign({ roomId: (context, event) => context.menu['arcade'] }),
50
+ entry: assign({ room: (context, event) => context.menu['arcade'] }),
51
51
  },
52
52
  table: {
53
- entry: assign({ roomId: (context, event) => context.menu['table'] }),
53
+ entry: assign({ room: (context, event) => context.menu['table'] }),
54
54
  },
55
55
  search: {},
56
56
  history: {
@@ -104,30 +104,30 @@ export default function (request) {
104
104
  if (Array.isArray(map[key])) {
105
105
  // 若是陣列則依順序決定館別內容
106
106
  map[key].some((val) => {
107
- const id = list.find((item) => item.category === val)?.id
108
- if (id) {
109
- menu[key] = id
107
+ const category = list.find((item) => item.category === val)
108
+ if (category) {
109
+ menu[key] = category
110
110
  return true
111
111
  } else {
112
112
  return false
113
113
  }
114
114
  })
115
115
  } else {
116
- menu[key] = list.find((item) => item.category === map[key])?.id
116
+ menu[key] = list.find((item) => item.category === map[key])
117
117
  }
118
118
  })
119
119
  return { menu }
120
120
  }),
121
121
  forwardRoom: assign((context, event) => {
122
122
  return {
123
- roomId: event.data,
124
- roomHistory: [...context.roomHistory, context.roomId],
123
+ room: event.data,
124
+ roomHistory: [...context.roomHistory, context.room],
125
125
  }
126
126
  }),
127
127
  backwardRoom: assign((context, event) => {
128
128
  const { roomHistory } = context
129
129
  return {
130
- roomId: roomHistory.slice(-1)[0],
130
+ room: roomHistory.slice(-1)[0],
131
131
  roomHistory: roomHistory.slice(0, -1),
132
132
  }
133
133
  }),
@@ -139,7 +139,7 @@ export default function (request) {
139
139
  },
140
140
  services: {
141
141
  getRoomItems: async (context, event) => {
142
- return await request.send(api.getGameCategory({ id: context.roomId }))
142
+ return await request.send(api.getGameCategory({ id: context.room?.id }))
143
143
  },
144
144
  },
145
145
  }