@jetthai/cuora 1.1.394-dev-1 → 1.1.394-dev-2
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,12 @@
|
|
|
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.394-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.394-dev-1...v1.1.394-dev-2) (2025-11-10)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- 新增活動週期自動更新檢查機制 ([d80ff18](https://github.com/jetthai/cuora-module/commit/d80ff188b25fb1576fd25edc8ed985ae1f1b6af6))
|
|
10
|
+
|
|
5
11
|
### [1.1.394-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.394...v1.1.394-dev-1) (2025-11-10)
|
|
6
12
|
|
|
7
13
|
### [1.1.394](https://github.com/jetthai/cuora-module/compare/v1.1.393...v1.1.394) (2025-11-04)
|
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@ export default function (request, context) {
|
|
|
13
13
|
activityNo,
|
|
14
14
|
activityDetail: null,
|
|
15
15
|
duration: 0,
|
|
16
|
+
lastCheckedPeriodEndTime: null, // 追蹤已檢查過的週期結束時間
|
|
16
17
|
|
|
17
18
|
// 領獎後得到的資訊
|
|
18
19
|
awards: [],
|
|
@@ -54,17 +55,19 @@ export default function (request, context) {
|
|
|
54
55
|
},
|
|
55
56
|
},
|
|
56
57
|
after: {
|
|
57
|
-
1000: {
|
|
58
|
-
target: 'awardable',
|
|
59
|
-
},
|
|
58
|
+
1000: [{ target: 'loading', cond: 'shouldCheckNewPeriod' }, { target: 'awardable' }],
|
|
60
59
|
},
|
|
61
60
|
},
|
|
62
61
|
awarded: {
|
|
62
|
+
entry: 'setDuration',
|
|
63
63
|
on: {
|
|
64
64
|
REFRESH_ACTIVITY: {
|
|
65
65
|
target: 'loading',
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
|
+
after: {
|
|
69
|
+
1000: [{ target: 'loading', cond: 'shouldCheckNewPeriod' }, { target: 'awarded' }],
|
|
70
|
+
},
|
|
68
71
|
},
|
|
69
72
|
awarding: {
|
|
70
73
|
invoke: {
|
|
@@ -97,7 +100,17 @@ export default function (request, context) {
|
|
|
97
100
|
},
|
|
98
101
|
},
|
|
99
102
|
},
|
|
100
|
-
result: {
|
|
103
|
+
result: {
|
|
104
|
+
entry: 'setDuration',
|
|
105
|
+
on: {
|
|
106
|
+
REFRESH_ACTIVITY: {
|
|
107
|
+
target: 'loading',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
after: {
|
|
111
|
+
1000: [{ target: 'loading', cond: 'shouldCheckNewPeriod' }, { target: 'result' }],
|
|
112
|
+
},
|
|
113
|
+
},
|
|
101
114
|
},
|
|
102
115
|
on: {
|
|
103
116
|
START: {
|
|
@@ -118,6 +131,8 @@ export default function (request, context) {
|
|
|
118
131
|
setActivityDetail: assign((context, event) => {
|
|
119
132
|
return {
|
|
120
133
|
activityDetail: event.data,
|
|
134
|
+
// 重置 lastCheckedPeriodEndTime,允許新週期結束時再次檢查
|
|
135
|
+
lastCheckedPeriodEndTime: null,
|
|
121
136
|
}
|
|
122
137
|
}),
|
|
123
138
|
setAward: assign((context, event) => {
|
|
@@ -151,6 +166,24 @@ export default function (request, context) {
|
|
|
151
166
|
isAutoReceiving: (context, event) => {
|
|
152
167
|
return context.isAutoReceiving
|
|
153
168
|
},
|
|
169
|
+
shouldCheckNewPeriod: (context, event) => {
|
|
170
|
+
// 當倒數計時結束時,重新檢查活動狀態
|
|
171
|
+
// 使用 lastCheckedPeriodEndTime 避免同一週期重複呼叫 API
|
|
172
|
+
const periodEndTime = context?.activityDetail?.periodEndTime
|
|
173
|
+
|
|
174
|
+
// 如果 duration 為 0,且這個週期還沒檢查過,則觸發更新
|
|
175
|
+
if (context.duration === 0 && periodEndTime) {
|
|
176
|
+
// 如果是新的週期結束時間,或者還沒檢查過,則允許觸發
|
|
177
|
+
if (context.lastCheckedPeriodEndTime !== periodEndTime) {
|
|
178
|
+
// 更新 lastCheckedPeriodEndTime(在 guard 中直接修改 context 是不好的做法,
|
|
179
|
+
// 但這裡是為了避免重複觸發,是可接受的權衡)
|
|
180
|
+
context.lastCheckedPeriodEndTime = periodEndTime
|
|
181
|
+
return true
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return false
|
|
186
|
+
},
|
|
154
187
|
},
|
|
155
188
|
services: {
|
|
156
189
|
fetchActivityDetail: async (context, event) => {
|