@jetthai/cuora 1.2.0 → 2.0.0-beta.0
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/BREAKING_CHANGES.md +9 -0
- package/CHANGELOG.md +36 -0
- package/package.json +5 -2
- package/resetGitBranch.sh +16 -16
- package/src/api/account.js +8 -0
- package/src/api/auth.js +1 -1
- package/src/api/common.js +6 -1
- package/src/api/index.js +3 -1
- package/src/api/otp.js +5 -0
- package/src/api/user.js +1 -0
- package/src/machine/activity/activity.js +23 -19
- package/src/machine/activity/activity_cash.js +27 -22
- package/src/machine/activity/cash_rain_activity.js +1 -0
- package/src/machine/activity/continue_deposit_activity.js +1 -0
- package/src/machine/activity/deposit_activity.js +1 -0
- package/src/machine/activity/diamond_shop_activity_cash.js +7 -0
- package/src/machine/activity/diamond_shop_activity_fc.js +1 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +1 -0
- package/src/machine/activity/fafafa_activity.js +1 -0
- package/src/machine/activity/friend_invite_friends_activity.js +7 -8
- package/src/machine/activity/instant_rebate_activity.js +1 -0
- package/src/machine/activity/invite_friends_activity.js +1 -0
- package/src/machine/activity/jackpot.js +1 -0
- package/src/machine/activity/mini_game_activity.js +1 -0
- package/src/machine/activity/otp_verified_activity.js +1 -0
- package/src/machine/activity/ranking_activity.js +1 -0
- package/src/machine/activity/return_bonus_activity.js +3 -1
- package/src/machine/activity/roulette_activity_v2.js +6 -0
- package/src/machine/activity/sign_in_activity.js +1 -0
- package/src/machine/activity/sign_in_monthly_activity.js +2 -1
- package/src/machine/activity/specify_bets_activity.js +1 -0
- package/src/machine/activity/specify_turnover_activity.js +1 -0
- package/src/machine/activity/time_bomb_activity.js +1 -0
- package/src/machine/activity/vip_card_activity.js +1 -0
- package/src/machine/auth.js +18 -6
- package/src/machine/auth_otp_v2.js +1 -0
- package/src/machine/auth_otp_v3.js +48 -11
- package/src/machine/bank_binding.js +1 -0
- package/src/machine/bank_binding_amb.js +1 -0
- package/src/machine/bonus.js +1 -0
- package/src/machine/common.js +24 -4
- package/src/machine/deposit/amb.js +1 -0
- package/src/machine/deposit/crypto_bank.js +20 -5
- package/src/machine/deposit/crypto_bank_cash.js +35 -9
- package/src/machine/deposit/crypto_qrcode.js +11 -1
- package/src/machine/deposit/crypto_qrcode_cash.js +24 -1
- package/src/machine/deposit/crypto_way.js +11 -5
- package/src/machine/deposit/crypto_way_cash.js +15 -6
- package/src/machine/deposit/deposit_fc.js +1 -0
- package/src/machine/deposit/direct.js +1 -0
- package/src/machine/deposit/direct_cash.js +1 -0
- package/src/machine/deposit/float.js +1 -0
- package/src/machine/deposit/krway.js +1 -0
- package/src/machine/deposit/loadcard_cash.js +2 -1
- package/src/machine/deposit/loadcard_vn.js +1 -0
- package/src/machine/deposit/manual_cash.js +1 -0
- package/src/machine/deposit/manual_vn.js +1 -0
- package/src/machine/deposit/qrcode_cash.js +6 -5
- package/src/machine/deposit/qrcode_v2.js +1 -0
- package/src/machine/deposit/usdt.js +23 -4
- package/src/machine/deposit/usdt_cash.js +15 -1
- package/src/machine/deposit/virtual_bank_cash.js +11 -9
- package/src/machine/deposit/virtual_bank_vn.js +1 -0
- package/src/machine/deposit/vpay.js +7 -0
- package/src/machine/error.js +1 -0
- package/src/machine/game_betslip.js +1 -0
- package/src/machine/game_favorite_v2.js +1 -0
- package/src/machine/game_hot_new.js +1 -0
- package/src/machine/game_info.js +5 -0
- package/src/machine/game_replay.js +1 -0
- package/src/machine/game_search_cash.js +1 -0
- package/src/machine/game_search_v2.js +1 -0
- package/src/machine/game_v2_1.js +88 -46
- package/src/machine/honor_board.js +1 -0
- package/src/machine/honor_board_cash.js +11 -8
- package/src/machine/inbox.js +93 -43
- package/src/machine/leaderboard.js +1 -0
- package/src/machine/merge.js +1 -0
- package/src/machine/navbar.js +3 -1
- package/src/machine/payment_data.js +1 -0
- package/src/machine/promotions.js +11 -18
- package/src/machine/ranking.js +5 -2
- package/src/machine/reward.js +1 -0
- package/src/machine/reward_cash.js +1 -0
- package/src/machine/reward_fc.js +1 -0
- package/src/machine/roulette_v2.js +18 -26
- package/src/machine/setting.js +1 -0
- package/src/machine/side.js +10 -4
- package/src/machine/side_cash.js +1 -0
- package/src/machine/side_v2.js +38 -24
- package/src/machine/user_info.js +1 -0
- package/src/machine/user_photo.js +1 -0
- package/src/machine/user_reset_password.js +5 -2
- package/src/machine/user_sign_up.js +1 -0
- package/src/machine/vip_table.js +1 -0
- package/src/machine/websocket.js +42 -14
- package/src/machine/welcome.js +1 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +1 -0
- package/src/machine/withdraw/withdraw_krway.js +1 -0
- package/src/machine/withdraw/withdraw_manual.js +16 -8
- package/src/machine/withdraw/withdraw_manual_cash.js +1 -0
- package/src/request/request.js +34 -30
- package/src/util/deviceToken.js +7 -6
- package/src/util/storage.js +4 -3
- package/test/api.behavior.test.js +69 -0
- package/test/api.contract.test.js +18 -0
- package/test/config.test.js +27 -0
- package/test/deviceToken.test.js +139 -0
- package/test/helpers.coverage.test.js +11 -0
- package/test/helpers.js +91 -0
- package/test/index.exports.test.js +14 -0
- package/test/machine.activity.core.coverage.test.js +337 -0
- package/test/machine.activity.gap.coverage.test.js +252 -0
- package/test/machine.activity.more.coverage.test.js +180 -0
- package/test/machine.activity_plus_and_binding_amb.coverage.test.js +201 -0
- package/test/machine.activity_timer_bonus.coverage.test.js +136 -0
- package/test/machine.activity_welcome.low.coverage.test.js +211 -0
- package/test/machine.amb_rewardfc_websocket.more.coverage.test.js +201 -0
- package/test/machine.auth.coverage.test.js +215 -0
- package/test/machine.bank_binding.test.js +143 -0
- package/test/machine.binding_otp_krway.coverage.test.js +223 -0
- package/test/machine.contract.test.js +50 -0
- package/test/machine.crypto_bank.coverage.test.js +270 -0
- package/test/machine.crypto_way.coverage.test.js +108 -0
- package/test/machine.crypto_way_cash.coverage.test.js +114 -0
- package/test/machine.definition.test.js +137 -0
- package/test/machine.deposit.manual.coverage.test.js +365 -0
- package/test/machine.deposit_fc.coverage.test.js +126 -0
- package/test/machine.direct.coverage.test.js +96 -0
- package/test/machine.direct_cash.coverage.test.js +108 -0
- package/test/machine.error.coverage.test.js +37 -0
- package/test/machine.events.test.js +126 -0
- package/test/machine.favorite_jackpot.coverage.test.js +82 -0
- package/test/machine.float.coverage.test.js +136 -0
- package/test/machine.flow.test.js +226 -0
- package/test/machine.game_hot_new_vip_table.coverage.test.js +105 -0
- package/test/machine.game_search_cash.coverage.test.js +155 -0
- package/test/machine.game_search_v2.test.js +199 -0
- package/test/machine.game_user_profile.coverage.test.js +100 -0
- package/test/machine.honor_board.test.js +133 -0
- package/test/machine.inbox.common.coverage.test.js +304 -0
- package/test/machine.loadcard_cash.coverage.test.js +101 -0
- package/test/machine.loadcard_vn.coverage.test.js +122 -0
- package/test/machine.misc.coverage.test.js +361 -0
- package/test/machine.more2.coverage.test.js +261 -0
- package/test/machine.options.execution.test.js +272 -0
- package/test/machine.priority.coverage.test.js +603 -0
- package/test/machine.qrcode_cash.coverage.test.js +107 -0
- package/test/machine.qrcode_v2.coverage.test.js +121 -0
- package/test/machine.regression.test.js +82 -0
- package/test/machine.roulette_v2.test.js +142 -0
- package/test/machine.side_reward_reset.coverage.test.js +220 -0
- package/test/machine.targeted.coverage.test.js +313 -0
- package/test/machine.usdt.coverage.test.js +95 -0
- package/test/machine.usdt_cash.coverage.test.js +73 -0
- package/test/machine.vip_card_activity.test.js +114 -0
- package/test/machine.virtual_bank_cash.coverage.test.js +105 -0
- package/test/machine.virtual_bank_vn.coverage.test.js +105 -0
- package/test/machine.vpay.coverage.test.js +142 -0
- package/test/machine.withdraw_crypto_cash.coverage.test.js +166 -0
- package/test/machine.withdraw_krway.coverage.test.js +123 -0
- package/test/machine.withdraw_manual.coverage.test.js +185 -0
- package/test/machine.withdraw_manual_cash.coverage.test.js +123 -0
- package/test/request.test.js +325 -0
- package/test/util.storage.errors.test.js +47 -0
- package/test/util.test.js +41 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Breaking Changes
|
|
2
|
+
|
|
3
|
+
## 2026-02-17
|
|
4
|
+
|
|
5
|
+
- `Request.send` maintenance-mode behavior changed.
|
|
6
|
+
- Before: when `isBlocked === true` and request URL was not `getConfig/get-config`, it returned `undefined` silently.
|
|
7
|
+
- After: it throws `{ code: 'ERR_MAINTENANCE_BLOCKED', url }`.
|
|
8
|
+
- Impact: callers that relied on `undefined` fallback must now handle `ERR_MAINTENANCE_BLOCKED` explicitly.
|
|
9
|
+
- File: `src/request/request.js`
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,42 @@
|
|
|
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
|
+
## Unreleased
|
|
6
|
+
|
|
7
|
+
### Chore
|
|
8
|
+
|
|
9
|
+
- xstate: enable `predictableActionArguments: true` on all machines to remove integration warning in downstream projects ([aeba6ec](https://github.com/jetthai/cuora-module/commit/aeba6ec))
|
|
10
|
+
|
|
11
|
+
### [1.1.413](https://github.com/jetthai/cuora-module/compare/v1.1.412...v1.1.413) (2026-02-09)
|
|
12
|
+
|
|
13
|
+
### [1.1.412](https://github.com/jetthai/cuora-module/compare/v1.1.411...v1.1.412) (2026-02-09)
|
|
14
|
+
|
|
15
|
+
### [1.1.411](https://github.com/jetthai/cuora-module/compare/v1.1.410...v1.1.411) (2026-02-05)
|
|
16
|
+
|
|
17
|
+
### [1.1.410](https://github.com/jetthai/cuora-module/compare/v1.1.409...v1.1.410) (2026-02-02)
|
|
18
|
+
|
|
19
|
+
### [1.1.409](https://github.com/jetthai/cuora-module/compare/v1.1.408...v1.1.409) (2026-01-27)
|
|
20
|
+
|
|
21
|
+
### [1.1.408](https://github.com/jetthai/cuora-module/compare/v1.1.407...v1.1.408) (2026-01-12)
|
|
22
|
+
|
|
23
|
+
### [1.1.407](https://github.com/jetthai/cuora-module/compare/v1.1.406...v1.1.407) (2025-12-22)
|
|
24
|
+
|
|
25
|
+
### [1.1.406](https://github.com/jetthai/cuora-module/compare/v1.1.405...v1.1.406) (2025-12-16)
|
|
26
|
+
|
|
27
|
+
### [1.1.405](https://github.com/jetthai/cuora-module/compare/v1.1.404...v1.1.405) (2025-12-16)
|
|
28
|
+
|
|
29
|
+
### [1.1.404](https://github.com/jetthai/cuora-module/compare/v1.1.403...v1.1.404) (2025-12-16)
|
|
30
|
+
|
|
31
|
+
### [1.1.403](https://github.com/jetthai/cuora-module/compare/v1.1.402...v1.1.403) (2025-12-16)
|
|
32
|
+
|
|
33
|
+
### [1.1.402](https://github.com/jetthai/cuora-module/compare/v1.1.401...v1.1.402) (2025-12-16)
|
|
34
|
+
|
|
35
|
+
### [1.1.401](https://github.com/jetthai/cuora-module/compare/v1.1.400...v1.1.401) (2025-12-15)
|
|
36
|
+
|
|
37
|
+
### [1.1.400](https://github.com/jetthai/cuora-module/compare/v1.1.399...v1.1.400) (2025-11-25)
|
|
38
|
+
|
|
39
|
+
### [1.1.399](https://github.com/jetthai/cuora-module/compare/v1.2.0...v1.1.399) (2025-11-19)
|
|
40
|
+
|
|
5
41
|
## [1.2.0](https://github.com/jetthai/cuora-module/compare/v1.1.398...v1.2.0) (2025-11-19)
|
|
6
42
|
|
|
7
43
|
### Features
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jetthai/cuora",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"release": "standard-version && git push --follow-tags origin master && npm publish",
|
|
9
|
+
"release:latest": "standard-version && git push --follow-tags origin master && npm publish && npm dist-tag add @jetthai/cuora@$(node -p \"require('./package.json').version\") latest",
|
|
10
|
+
"test": "node --test",
|
|
11
|
+
"test:coverage": "node --test --experimental-test-coverage --test-coverage-include=src/**/*.js --test-coverage-exclude=src/lib/fingerprint_v3_11_12.js",
|
|
9
12
|
"format": "prettier --write .",
|
|
10
13
|
"prepare": "husky install"
|
|
11
14
|
},
|
|
@@ -26,6 +29,6 @@
|
|
|
26
29
|
"universal-cookie": "^4.0.4",
|
|
27
30
|
"url-join": "^4.0.1",
|
|
28
31
|
"xstate": "^4.25.0",
|
|
29
|
-
"socket.io-client": "^4.8.
|
|
32
|
+
"socket.io-client": "^4.8.3"
|
|
30
33
|
}
|
|
31
34
|
}
|
package/resetGitBranch.sh
CHANGED
|
@@ -51,27 +51,13 @@ if [ $? -ne 0 ]; then
|
|
|
51
51
|
exit 1
|
|
52
52
|
fi
|
|
53
53
|
|
|
54
|
-
# 切換到 master
|
|
54
|
+
# 切換到 master
|
|
55
55
|
git checkout master
|
|
56
56
|
if [ $? -ne 0 ]; then
|
|
57
57
|
echo "切換到 master 分支失敗"
|
|
58
58
|
exit 1
|
|
59
59
|
fi
|
|
60
60
|
|
|
61
|
-
# 刪除本地的 qa 分支
|
|
62
|
-
git branch -D qa
|
|
63
|
-
if [ $? -ne 0 ]; then
|
|
64
|
-
echo "刪除本地 qa 分支失敗"
|
|
65
|
-
exit 1
|
|
66
|
-
fi
|
|
67
|
-
|
|
68
|
-
# 刪除遠端的 qa 分支
|
|
69
|
-
git push origin --delete qa
|
|
70
|
-
if [ $? -ne 0 ]; then
|
|
71
|
-
echo "刪除遠端 qa 分支失敗"
|
|
72
|
-
exit 1
|
|
73
|
-
fi
|
|
74
|
-
|
|
75
61
|
# 建立並切換到新的 qa 分支
|
|
76
62
|
git checkout -b qa
|
|
77
63
|
if [ $? -ne 0 ]; then
|
|
@@ -93,9 +79,23 @@ if [ $? -ne 0 ]; then
|
|
|
93
79
|
exit 1
|
|
94
80
|
fi
|
|
95
81
|
|
|
96
|
-
# 切換到 master
|
|
82
|
+
# 切換到 master
|
|
97
83
|
git checkout master
|
|
98
84
|
if [ $? -ne 0 ]; then
|
|
99
85
|
echo "切換到 master 分支失敗"
|
|
100
86
|
exit 1
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
# 刪除所有已經合併到 master 分支的本地分支,除了 master 分支本身
|
|
90
|
+
git branch --merged master | grep -v "^\* master$" | grep -vE "^[* ]*(dev|qa)$" | xargs -r git branch -d
|
|
91
|
+
if [ $? -ne 0 ]; then
|
|
92
|
+
echo "刪除已合併到 master 分支的本地分支失敗"
|
|
93
|
+
exit 1
|
|
94
|
+
fi
|
|
95
|
+
|
|
96
|
+
# 刪除所有已經合併到 master 分支的遠端分支,除了 master 分支本身
|
|
97
|
+
git branch -r --merged master | grep -v "master" | grep -vE "(dev|qa)$" | sed 's/origin\///' | xargs -r -I {} git push origin --delete {}
|
|
98
|
+
if [ $? -ne 0 ]; then
|
|
99
|
+
echo "刪除已合併到 master 分支的遠端分支失敗"
|
|
100
|
+
exit 1
|
|
101
101
|
fi
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
bindingStatus: () => ({ url: 'account-binding/status', method: 'GET' }),
|
|
3
|
+
applyBinding: (data) => ({ url: 'account-binding/bind', method: 'POST', params: data }),
|
|
4
|
+
bindingVerification: (data) => ({ url: 'account-binding/acknowledge', method: 'POST', params: data }),
|
|
5
|
+
bindThirdParty: (data) => ({ url: 'account-binding/bind-third-party', method: 'GET', params: data }),
|
|
6
|
+
bindPassword: (data) => ({ url: 'account-binding/bind-password', method: 'POST', params: data }),
|
|
7
|
+
resetOtp: (data) => ({ url: 'account-binding/reset-otp', method: 'POST', params: data }),
|
|
8
|
+
}
|
package/src/api/auth.js
CHANGED
package/src/api/common.js
CHANGED
|
@@ -2,9 +2,14 @@ export default {
|
|
|
2
2
|
getConfig: ({ appSecret }) => ({ url: 'getConfig', method: 'get', params: { appSecret }, isPublic: true }),
|
|
3
3
|
getLayoutConfig: ({ appSecret }) => ({ url: 'getQuickLayout', method: 'get', params: { appSecret }, isPublic: true }),
|
|
4
4
|
feeds: ({ appSecret }) => ({ url: 'feeds', method: 'get', params: { appSecret }, isPublic: true }),
|
|
5
|
-
broadcast: () => ({ url: 'broadcast', method: 'get', params: { appSecret }, isPublic: true }),
|
|
5
|
+
broadcast: ({ appSecret } = {}) => ({ url: 'broadcast', method: 'get', params: { appSecret }, isPublic: true }),
|
|
6
6
|
getAnnouncements: ({ appSecret }) => ({ url: 'getAnnouncements', params: { appSecret }, method: 'get', isPublic: true }),
|
|
7
7
|
getNavbar: ({ appSecret } = {}) => ({ url: 'getNavbarSetting', params: { appSecret }, method: 'get', isPublic: true }),
|
|
8
8
|
getDefaultAffiliateCode: ({ appSecret }) => ({ url: 'getAffiliateCode', params: { appSecret }, method: 'get', isPublic: true }),
|
|
9
9
|
getSiteInfoConfig: ({ appSecret, config }) => ({ url: 'get-site-config', method: 'get', params: { appSecret, config }, isPublic: true }),
|
|
10
|
+
sendPixel: ({ appSecret, eventId, fbc, fbp, event, eventSourceUrl }) => ({
|
|
11
|
+
url: 'pixel',
|
|
12
|
+
method: 'post',
|
|
13
|
+
params: { appSecret, eventId, fbc, fbp, event, eventSourceUrl },
|
|
14
|
+
}),
|
|
10
15
|
}
|
package/src/api/index.js
CHANGED
|
@@ -7,5 +7,7 @@ import payment from './payment.js'
|
|
|
7
7
|
import user from './user.js'
|
|
8
8
|
import form from './form.js'
|
|
9
9
|
import ranking from './ranking.js'
|
|
10
|
+
import account from './account.js'
|
|
11
|
+
import otp from './otp.js'
|
|
10
12
|
|
|
11
|
-
export default { activity, auth, common, game, mailbox, payment, user, form, ranking }
|
|
13
|
+
export default { activity, auth, common, game, mailbox, payment, user, form, ranking, account, otp }
|
package/src/api/otp.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
verification: (data) => ({ url: 'otp-verification-point/verify', method: 'POST', params: data }),
|
|
3
|
+
acknowledge: (data) => ({ url: 'otp-verification-point/acknowledge', method: 'POST', params: data }),
|
|
4
|
+
reset: (data) => ({ url: 'otp-verification-point/reset-otp', method: 'POST', params: data }),
|
|
5
|
+
}
|
package/src/api/user.js
CHANGED
|
@@ -65,4 +65,5 @@ export default {
|
|
|
65
65
|
otpReset: ({ requestId, target }) => ({ url: '/otpsso/reset', method: 'post', params: { requestId, target }, isPublic: true }),
|
|
66
66
|
getUserPhotoList: () => ({ url: 'getAllAvatar', method: 'get' }),
|
|
67
67
|
updateUserPhoto: (data) => ({ url: 'updateUserAvatar', method: 'post', params: data }),
|
|
68
|
+
getUserProfile: () => ({ url: 'user-info/get-profile', method: 'get' }),
|
|
68
69
|
}
|
|
@@ -7,6 +7,7 @@ export default function (request) {
|
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'activity',
|
|
10
|
+
predictableActionArguments: true,
|
|
10
11
|
initial: 'init',
|
|
11
12
|
context: {
|
|
12
13
|
tick: 2000,
|
|
@@ -108,17 +109,17 @@ export default function (request) {
|
|
|
108
109
|
}),
|
|
109
110
|
setActivityList: assign((context, event) => {
|
|
110
111
|
const noRedActivity = [2, 4, 13, 20, 90, 91, 92]
|
|
112
|
+
const noReadSet = new Set(noRedActivity)
|
|
111
113
|
const { uidSite } = context
|
|
112
114
|
const { activityList } = event.data
|
|
113
|
-
|
|
114
|
-
list.forEach((activity) => {
|
|
115
|
+
const list = (activityList || []).map((activity) => {
|
|
115
116
|
const storageUnread = localStorage.getItem(`unread_${activity.activityNo}_${uidSite}`)
|
|
116
|
-
if (
|
|
117
|
-
activity
|
|
117
|
+
if (noReadSet.has(activity.activityType)) {
|
|
118
|
+
return { ...activity, unread: false }
|
|
118
119
|
} else if (storageUnread) {
|
|
119
|
-
activity
|
|
120
|
+
return { ...activity, unread: JSON.parse(storageUnread) }
|
|
120
121
|
} else {
|
|
121
|
-
activity
|
|
122
|
+
return { ...activity, unread: true }
|
|
122
123
|
}
|
|
123
124
|
})
|
|
124
125
|
return {
|
|
@@ -138,14 +139,15 @@ export default function (request) {
|
|
|
138
139
|
}),
|
|
139
140
|
setUnread: assign((context, event) => {
|
|
140
141
|
const { uidSite, activityNo, unread } = event.data
|
|
141
|
-
const list = JSON.parse(JSON.stringify(context.activityList))
|
|
142
142
|
localStorage.setItem(`unread_${activityNo}_${uidSite}`, `${unread}`)
|
|
143
|
-
list.map((item) =>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
const list = (context.activityList || []).map((item) =>
|
|
144
|
+
item.activityNo === activityNo
|
|
145
|
+
? {
|
|
146
|
+
...item,
|
|
147
|
+
unread: JSON.parse(`${unread}`),
|
|
148
|
+
}
|
|
149
|
+
: item
|
|
150
|
+
)
|
|
149
151
|
return {
|
|
150
152
|
activityList: list,
|
|
151
153
|
uidSite,
|
|
@@ -165,8 +167,7 @@ export default function (request) {
|
|
|
165
167
|
guards: {
|
|
166
168
|
hasSpecifyActivities: (context, event) => {
|
|
167
169
|
const { activityList = [], specifyActivities = [] } = context
|
|
168
|
-
|
|
169
|
-
return filterActivityList.length > 0
|
|
170
|
+
return activityList.some((activity) => specifyActivities.includes(activity.activityType))
|
|
170
171
|
},
|
|
171
172
|
isInGame: (context, event) => {
|
|
172
173
|
return context.isPlaying
|
|
@@ -196,10 +197,13 @@ export default function (request) {
|
|
|
196
197
|
await new Promise((resolve) => setTimeout(resolve, 1000)) // delay 1 second
|
|
197
198
|
|
|
198
199
|
const { activityList = [], specifyActivities = [] } = context
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
200
|
+
const promiseArray = []
|
|
201
|
+
for (let i = 0; i < activityList.length; i++) {
|
|
202
|
+
const item = activityList[i]
|
|
203
|
+
if (specifyActivities.includes(item.activityType)) {
|
|
204
|
+
promiseArray.push(request.send(activity.getActivityDetail({ activityNo: item.activityNo, appSecret })))
|
|
205
|
+
}
|
|
206
|
+
}
|
|
203
207
|
const activitiesDetail = await Promise.all(promiseArray)
|
|
204
208
|
return activitiesDetail
|
|
205
209
|
},
|
|
@@ -7,6 +7,7 @@ export default function (request) {
|
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'activity',
|
|
10
|
+
predictableActionArguments: true,
|
|
10
11
|
initial: 'fetchingList',
|
|
11
12
|
context: {
|
|
12
13
|
tick: 2000,
|
|
@@ -79,17 +80,17 @@ export default function (request) {
|
|
|
79
80
|
}),
|
|
80
81
|
setActivityList: assign((context, event) => {
|
|
81
82
|
const noReadActivity = [2, 4, 13, 20, 90, 91, 92]
|
|
83
|
+
const noReadSet = new Set(noReadActivity)
|
|
82
84
|
const { uidSite } = context
|
|
83
85
|
const { activityList } = event.data
|
|
84
|
-
|
|
85
|
-
list.forEach((activity) => {
|
|
86
|
+
const list = (activityList || []).map((activity) => {
|
|
86
87
|
const storageUnread = localStorage.getItem(`unread_${activity.activityNo}_${uidSite}`)
|
|
87
|
-
if (
|
|
88
|
-
activity
|
|
88
|
+
if (noReadSet.has(activity.activityType)) {
|
|
89
|
+
return { ...activity, unread: false }
|
|
89
90
|
} else if (storageUnread) {
|
|
90
|
-
activity
|
|
91
|
+
return { ...activity, unread: JSON.parse(storageUnread) }
|
|
91
92
|
} else {
|
|
92
|
-
activity
|
|
93
|
+
return { ...activity, unread: true }
|
|
93
94
|
}
|
|
94
95
|
})
|
|
95
96
|
return {
|
|
@@ -104,14 +105,15 @@ export default function (request) {
|
|
|
104
105
|
}),
|
|
105
106
|
setUnread: assign((context, event) => {
|
|
106
107
|
const { uidSite, activityNo, unread } = event.data
|
|
107
|
-
const list = JSON.parse(JSON.stringify(context.activityList))
|
|
108
108
|
localStorage.setItem(`unread_${activityNo}_${uidSite}`, `${unread}`)
|
|
109
|
-
list.map((item) =>
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
const list = (context.activityList || []).map((item) =>
|
|
110
|
+
item.activityNo === activityNo
|
|
111
|
+
? {
|
|
112
|
+
...item,
|
|
113
|
+
unread: JSON.parse(`${unread}`),
|
|
114
|
+
}
|
|
115
|
+
: item
|
|
116
|
+
)
|
|
115
117
|
return {
|
|
116
118
|
activityList: list,
|
|
117
119
|
uidSite,
|
|
@@ -136,7 +138,7 @@ export default function (request) {
|
|
|
136
138
|
guards: {
|
|
137
139
|
needFetchingDetail: (context, event) => {
|
|
138
140
|
const { activityList = [], detailNeededActivityTypes } = context
|
|
139
|
-
return activityList.
|
|
141
|
+
return activityList.some((activity) => detailNeededActivityTypes.includes(activity.activityType))
|
|
140
142
|
},
|
|
141
143
|
isInGame: (context, event) => {
|
|
142
144
|
return context.isPlaying
|
|
@@ -166,14 +168,17 @@ export default function (request) {
|
|
|
166
168
|
const hasToken = request.getToken()
|
|
167
169
|
|
|
168
170
|
const { activityList = [], detailNeededActivityTypes } = context
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
171
|
+
if (!hasToken) {
|
|
172
|
+
return []
|
|
173
|
+
}
|
|
174
|
+
const promiseArray = []
|
|
175
|
+
for (let i = 0; i < activityList.length; i++) {
|
|
176
|
+
const item = activityList[i]
|
|
177
|
+
if (detailNeededActivityTypes.includes(item.activityType)) {
|
|
178
|
+
promiseArray.push(request.send(activity.getActivityDetail({ activityNo: item.activityNo, appSecret })))
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return await Promise.all(promiseArray)
|
|
177
182
|
},
|
|
178
183
|
},
|
|
179
184
|
}
|
|
@@ -6,6 +6,7 @@ export default function (request) {
|
|
|
6
6
|
return createMachine(
|
|
7
7
|
{
|
|
8
8
|
id: 'diamond_shop_activity',
|
|
9
|
+
predictableActionArguments: true,
|
|
9
10
|
context: {
|
|
10
11
|
activityNo: null,
|
|
11
12
|
activityDetail: null,
|
|
@@ -13,6 +14,7 @@ export default function (request) {
|
|
|
13
14
|
awardList: [],
|
|
14
15
|
totalAmount: 0,
|
|
15
16
|
subtractPoints: 0,
|
|
17
|
+
callback: () => {},
|
|
16
18
|
},
|
|
17
19
|
initial: 'fetching',
|
|
18
20
|
states: {
|
|
@@ -144,6 +146,11 @@ export default function (request) {
|
|
|
144
146
|
totalPoints: event.data,
|
|
145
147
|
}
|
|
146
148
|
}),
|
|
149
|
+
setCallback: assign((context, event) => {
|
|
150
|
+
return {
|
|
151
|
+
callback: event.data?.callback || (() => {}),
|
|
152
|
+
}
|
|
153
|
+
}),
|
|
147
154
|
},
|
|
148
155
|
guards: {
|
|
149
156
|
settlable: (context, event) => {
|
|
@@ -7,6 +7,7 @@ export default function (request) {
|
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'friend_invite_friends_activity',
|
|
10
|
+
predictableActionArguments: true,
|
|
10
11
|
context: {
|
|
11
12
|
friendsEnable: false,
|
|
12
13
|
activityNo: null,
|
|
@@ -253,13 +254,12 @@ export default function (request) {
|
|
|
253
254
|
},
|
|
254
255
|
fetchLevelDownLineList: async (context, event) => {
|
|
255
256
|
const { currentLevel, page, levelDownLine } = context
|
|
256
|
-
const
|
|
257
|
-
const copiedList = copiedObj.data
|
|
257
|
+
const existingList = Array.isArray(levelDownLine?.data) ? levelDownLine.data : null
|
|
258
258
|
const resopnseData = await request.send(user.getFriendsDashboardList({ level: currentLevel, page, row: 10 }))
|
|
259
|
-
if (
|
|
259
|
+
if (existingList && resopnseData?.data) {
|
|
260
260
|
const combindData = {
|
|
261
261
|
...resopnseData,
|
|
262
|
-
data: [...
|
|
262
|
+
data: [...existingList, ...resopnseData.data],
|
|
263
263
|
}
|
|
264
264
|
return combindData
|
|
265
265
|
} else {
|
|
@@ -268,13 +268,12 @@ export default function (request) {
|
|
|
268
268
|
},
|
|
269
269
|
fetchFriendsList: async (context, event) => {
|
|
270
270
|
const { currentType, listPage, friendsList } = context
|
|
271
|
-
const
|
|
272
|
-
const copiedList = copiedObj.list
|
|
271
|
+
const existingList = Array.isArray(friendsList?.list) ? friendsList.list : null
|
|
273
272
|
const resopnseData = await request.send(user.getFriendsList({ type: currentType, page: listPage, row: 15 }))
|
|
274
|
-
if (
|
|
273
|
+
if (existingList && resopnseData?.data?.list) {
|
|
275
274
|
const combindData = {
|
|
276
275
|
...resopnseData.data,
|
|
277
|
-
list: [...
|
|
276
|
+
list: [...existingList, ...resopnseData.data.list],
|
|
278
277
|
}
|
|
279
278
|
return combindData
|
|
280
279
|
} else {
|
|
@@ -9,6 +9,7 @@ export default function (request) {
|
|
|
9
9
|
return createMachine(
|
|
10
10
|
{
|
|
11
11
|
id: 'return_bonus_activity',
|
|
12
|
+
predictableActionArguments: true,
|
|
12
13
|
context: {
|
|
13
14
|
activityNo: null,
|
|
14
15
|
activityDetail: null,
|
|
@@ -105,7 +106,8 @@ export default function (request) {
|
|
|
105
106
|
}
|
|
106
107
|
}),
|
|
107
108
|
setRewardList: assign((context, event) => {
|
|
108
|
-
const
|
|
109
|
+
const source = Array.isArray(event.data) ? event.data : []
|
|
110
|
+
const rewardList = source.filter((item) => item.activityType === 4 && item.receiveStatus === 0)
|
|
109
111
|
return { rewardList }
|
|
110
112
|
}),
|
|
111
113
|
setCallback: assign((context, event) => {
|
|
@@ -7,6 +7,7 @@ export default function (request, context) {
|
|
|
7
7
|
return createMachine(
|
|
8
8
|
{
|
|
9
9
|
id: 'roulette_activity_v2',
|
|
10
|
+
predictableActionArguments: true,
|
|
10
11
|
context: {
|
|
11
12
|
activityNo,
|
|
12
13
|
activityDetail: null,
|
|
@@ -42,6 +43,11 @@ export default function (request, context) {
|
|
|
42
43
|
target: 'loaded',
|
|
43
44
|
},
|
|
44
45
|
},
|
|
46
|
+
on: {
|
|
47
|
+
REFRESH_ACTIVITY_DETAIL: {
|
|
48
|
+
target: 'loading',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
45
51
|
},
|
|
46
52
|
expired: {},
|
|
47
53
|
},
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import api from '
|
|
2
|
+
import api from '../../api/activity.js'
|
|
3
3
|
|
|
4
4
|
export default function (request) {
|
|
5
5
|
const { appSecret } = request.config
|
|
6
6
|
return createMachine(
|
|
7
7
|
{
|
|
8
8
|
id: 'sign_in_monthly',
|
|
9
|
+
predictableActionArguments: true,
|
|
9
10
|
context: {
|
|
10
11
|
activityNo: null,
|
|
11
12
|
activityDetail: null,
|