@jetthai/cuora 1.1.161-barbet → 1.1.161-barbet2
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 +2 -0
- package/package.json +1 -1
- package/src/machine/game_v2_1.js +65 -0
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.161-barbet2](https://github.com/jetthai/cuora-module/compare/v1.1.161-barbet...v1.1.161-barbet2) (2023-08-11)
|
|
6
|
+
|
|
5
7
|
### [1.1.161-barbet](https://github.com/jetthai/cuora-module/compare/v1.1.161...v1.1.161-barbet) (2023-08-11)
|
|
6
8
|
|
|
7
9
|
### [1.1.159-barbet](https://github.com/jetthai/cuora-module/compare/v1.1.159...v1.1.159-barbet) (2023-08-09)
|
package/package.json
CHANGED
package/src/machine/game_v2_1.js
CHANGED
|
@@ -11,6 +11,7 @@ export default function (request) {
|
|
|
11
11
|
type: 'parallel',
|
|
12
12
|
context: {
|
|
13
13
|
base: '/',
|
|
14
|
+
batch: null,
|
|
14
15
|
loadable: false,
|
|
15
16
|
isLastPage: false,
|
|
16
17
|
room: null,
|
|
@@ -63,12 +64,27 @@ export default function (request) {
|
|
|
63
64
|
cond: 'isDifferentRoom',
|
|
64
65
|
actions: ['setRoom', 'resetContent'],
|
|
65
66
|
},
|
|
67
|
+
BATCH: {
|
|
68
|
+
target: 'batchFetching',
|
|
69
|
+
},
|
|
66
70
|
ENTER_GAME: {
|
|
67
71
|
target: 'connecting',
|
|
68
72
|
actions: ['setGameInfo', 'setLang'],
|
|
69
73
|
},
|
|
70
74
|
},
|
|
71
75
|
},
|
|
76
|
+
batchFetching: {
|
|
77
|
+
invoke: {
|
|
78
|
+
src: 'batchFetch',
|
|
79
|
+
onDone: {
|
|
80
|
+
target: 'idle',
|
|
81
|
+
actions: 'setBatch',
|
|
82
|
+
},
|
|
83
|
+
onError: {
|
|
84
|
+
target: 'idle',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
72
88
|
loading: {
|
|
73
89
|
entry: 'increaseIndex',
|
|
74
90
|
invoke: {
|
|
@@ -242,6 +258,11 @@ export default function (request) {
|
|
|
242
258
|
room: event.data,
|
|
243
259
|
}
|
|
244
260
|
}),
|
|
261
|
+
setBatch: assign((context, event) => {
|
|
262
|
+
return {
|
|
263
|
+
batch: event.data,
|
|
264
|
+
}
|
|
265
|
+
}),
|
|
245
266
|
resetContent: assign((context, event) => {
|
|
246
267
|
return {
|
|
247
268
|
loadable: false,
|
|
@@ -333,6 +354,50 @@ export default function (request) {
|
|
|
333
354
|
...oldGuards,
|
|
334
355
|
},
|
|
335
356
|
services: {
|
|
357
|
+
batchFetch: async (context, event) => {
|
|
358
|
+
const { room, index, additionEnable, staticData } = context
|
|
359
|
+
let requestChain = null
|
|
360
|
+
if (!request.getToken()) {
|
|
361
|
+
// 如果沒 token ,id 列表去 static 找
|
|
362
|
+
const list = event.data.list.map((targetCategory, b) => {
|
|
363
|
+
return {
|
|
364
|
+
i18n: targetCategory.i18n,
|
|
365
|
+
downLine: staticData
|
|
366
|
+
.find((item) => item.category === targetCategory.id)
|
|
367
|
+
.info.filter((item) => item.isGame === true)
|
|
368
|
+
.slice(0, 20),
|
|
369
|
+
}
|
|
370
|
+
})
|
|
371
|
+
return list.filter((item) => item.downLine.length > 0).slice(0, 6)
|
|
372
|
+
} else if (additionEnable) {
|
|
373
|
+
const param = { categoryId: room.categoryId, index }
|
|
374
|
+
requestChain = event.data.list.map((category, b) => {
|
|
375
|
+
return request
|
|
376
|
+
.send(
|
|
377
|
+
api.getListCategory({
|
|
378
|
+
categoryId: category.id,
|
|
379
|
+
index: 0,
|
|
380
|
+
})
|
|
381
|
+
)
|
|
382
|
+
.then((res) => Object.assign({ downLine: res.data.filter((item) => item.isGame === true).slice(0, 20) }, category))
|
|
383
|
+
})
|
|
384
|
+
const result = await Promise.all([...requestChain, request.send(api.getListAddition(param))])
|
|
385
|
+
return result.filter((item) => item.downLine.length > 0).slice(0, 6)
|
|
386
|
+
} else {
|
|
387
|
+
requestChain = event.data.list.map((category, b) => {
|
|
388
|
+
return request
|
|
389
|
+
.send(
|
|
390
|
+
api.getListCategory({
|
|
391
|
+
categoryId: category.id,
|
|
392
|
+
index: 0,
|
|
393
|
+
})
|
|
394
|
+
)
|
|
395
|
+
.then((res) => Object.assign({ downLine: res.data.filter((item) => item.isGame === true).slice(0, 20) }, category))
|
|
396
|
+
})
|
|
397
|
+
const result = await Promise.all([...requestChain])
|
|
398
|
+
return result.filter((item) => item.downLine.length > 0).slice(0, 6)
|
|
399
|
+
}
|
|
400
|
+
},
|
|
336
401
|
getPageContent: async (context, event) => {
|
|
337
402
|
const { room, index, additionEnable, staticData } = context
|
|
338
403
|
if (room.categoryId === GAME_SEARCH) {
|