@jetthai/cuora 1.1.407-1 → 1.1.407

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.407-1",
3
+ "version": "1.1.407",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -49,10 +49,6 @@ export default function (request, context) {
49
49
  services: {
50
50
  // 取得遊戲資訊
51
51
  fetchGameInfo: async (context, event) => {
52
- // [防呆] 確保有 gameCode
53
- if (!gameCode) {
54
- return { data: {} }
55
- }
56
52
  return await request.send(game.getGameInfo({ appSecret, gameCode }))
57
53
  },
58
54
  },
@@ -390,10 +390,6 @@ export default function (request) {
390
390
  }),
391
391
  appendContent: assign((context, event) => {
392
392
  const { room, additionEnable } = context
393
- // [防呆] 確保有 categoryId
394
- if (!room?.categoryId) {
395
- return
396
- }
397
393
  if (room.categoryId === GAME_SEARCH) {
398
394
  return
399
395
  } else if (additionEnable) {
@@ -521,60 +517,38 @@ export default function (request) {
521
517
  })
522
518
  return list.filter((item) => item.downLine.length > 0).slice(0, 6)
523
519
  } else if (additionEnable) {
524
- // [防呆] 確保有 categoryId
525
- const hasCategoryId = !!room?.categoryId
526
- const param = hasCategoryId ? { categoryId: room.categoryId, index, appSecret } : null
527
- // [防呆] 確保有 categoryId
528
- requestChain = event.data.list
529
- .filter((category) => category && category.id !== undefined && category.id !== null)
530
- .map((category) =>
531
- request
532
- .send(
533
- api.getListCategory({
534
- categoryId: category.id,
535
- index: 0,
536
- appSecret,
537
- })
538
- )
539
- .then((res) => Object.assign({ downLine: res.data.filter((item) => item.isGame).slice(0, 20) }, category))
540
- )
541
- const promises = [...requestChain]
542
- if (hasCategoryId) {
543
- promises.push(request.send(api.getListAddition(param)))
544
- }
545
- const result = await Promise.all(promises)
546
- return result.filter((item) => item.downLine?.length > 0).slice(0, 6)
520
+ const param = { categoryId: room.categoryId, index, appSecret }
521
+ requestChain = event.data.list.map((category, b) => {
522
+ return request
523
+ .send(
524
+ api.getListCategory({
525
+ categoryId: category.id,
526
+ index: 0,
527
+ appSecret,
528
+ })
529
+ )
530
+ .then((res) => Object.assign({ downLine: res.data.filter((item) => item.isGame).slice(0, 20) }, category))
531
+ })
532
+ const result = await Promise.all([...requestChain, request.send(api.getListAddition(param))])
533
+ return result.filter((item) => item.downLine.length > 0).slice(0, 6)
547
534
  } else {
548
- // [防呆] 確保有 categoryId
549
- requestChain = event.data.list
550
- .filter((category) => category && category.id !== undefined && category.id !== null)
551
- .map((category) =>
552
- request
553
- .send(
554
- api.getListCategory({
555
- categoryId: category.id,
556
- index: 0,
557
- appSecret,
558
- })
559
- )
560
- .then((res) => Object.assign({ downLine: res.data.filter((item) => item.isGame).slice(0, 20) }, category))
561
- )
535
+ requestChain = event.data.list.map((category, b) => {
536
+ return request
537
+ .send(
538
+ api.getListCategory({
539
+ categoryId: category.id,
540
+ index: 0,
541
+ appSecret,
542
+ })
543
+ )
544
+ .then((res) => Object.assign({ downLine: res.data.filter((item) => item.isGame).slice(0, 20) }, category))
545
+ })
562
546
  const result = await Promise.all([...requestChain])
563
547
  return result.filter((item) => item.downLine.length > 0).slice(0, 6)
564
548
  }
565
549
  },
566
550
  getPageContent: async (context, event) => {
567
551
  const { room, index, additionEnable, staticData } = context
568
- // [防呆] 確保有 categoryId
569
- if (!room?.categoryId) {
570
- return [
571
- {
572
- data: [],
573
- totalPage: 0,
574
- timestamp: context.content?.timestamp ?? null,
575
- },
576
- ]
577
- }
578
552
  if (room.categoryId === GAME_SEARCH) {
579
553
  return
580
554
  } else if (!request.getToken()) {
@@ -597,10 +571,6 @@ export default function (request) {
597
571
  },
598
572
  updatePageContent: async (context, event) => {
599
573
  const { room, content, index, additionEnable } = context
600
- // [防呆] 確保有 categoryId
601
- if (!room?.categoryId) {
602
- return []
603
- }
604
574
  if (room.categoryId === GAME_SEARCH) {
605
575
  return []
606
576
  } else if (!request.getToken()) {