@@ -7,6 +7,8 @@ import type {
77 MCPQueryProfile ,
88} from '../../../types/services/mcp'
99
10+ import { BrowserWindow } from 'electron'
11+
1012import { Authentication } from '../authentication'
1113
1214import {
@@ -24,6 +26,7 @@ import {
2426
2527export class MCPClaimRewards {
2628 static async openCardPackBatch (
29+ currentWindow : BrowserWindow ,
2730 queryProfile : MCPQueryProfile ,
2831 account : AccountData
2932 ) {
@@ -51,17 +54,22 @@ export class MCPClaimRewards {
5154 return defaultResponse
5255 }
5356
54- const accessToken = await Authentication . verifyAccessToken ( account )
55-
56- if ( accessToken ) {
57- const response = await setOpenCardPackBatch ( {
58- accessToken,
59- accountId : account . accountId ,
60- cardPackItemIds : cardPackIds ,
61- } )
57+ const accessToken = await Authentication . verifyAccessToken (
58+ account ,
59+ currentWindow
60+ )
6261
63- return [ response . data ]
62+ if ( ! accessToken ) {
63+ return defaultResponse
6464 }
65+
66+ const response = await setOpenCardPackBatch ( {
67+ accessToken,
68+ accountId : account . accountId ,
69+ cardPackItemIds : cardPackIds ,
70+ } )
71+
72+ return [ response . data ]
6573 } catch ( error ) {
6674 //
6775 }
@@ -70,6 +78,7 @@ export class MCPClaimRewards {
7078 }
7179
7280 static async claimQuestReward (
81+ currentWindow : BrowserWindow ,
7382 queryProfile : MCPQueryProfile ,
7483 account : AccountData
7584 ) {
@@ -98,20 +107,22 @@ export class MCPClaimRewards {
98107
99108 const response = await Promise . allSettled (
100109 questIds . map ( async ( questId ) => {
101- const accessToken =
102- await Authentication . verifyAccessToken ( account )
103-
104- if ( accessToken ) {
105- const response = await setClaimQuestReward ( {
106- accessToken,
107- questId,
108- accountId : account . accountId ,
109- } )
110+ const accessToken = await Authentication . verifyAccessToken (
111+ account ,
112+ currentWindow
113+ )
110114
111- return response . data
115+ if ( ! accessToken ) {
116+ return null
112117 }
113118
114- return null
119+ const response = await setClaimQuestReward ( {
120+ accessToken,
121+ questId,
122+ accountId : account . accountId ,
123+ } )
124+
125+ return response . data
115126 } )
116127 )
117128
@@ -129,56 +140,80 @@ export class MCPClaimRewards {
129140 return defaultResponse
130141 }
131142
132- static async claimMissionAlertRewards ( account : AccountData ) {
143+ static async claimMissionAlertRewards (
144+ currentWindow : BrowserWindow ,
145+ account : AccountData
146+ ) {
133147 try {
134- const accessToken = await Authentication . verifyAccessToken ( account )
135-
136- if ( accessToken ) {
137- const response = await setClaimMissionAlertRewards ( {
138- accessToken,
139- accountId : account . accountId ,
140- } )
148+ const accessToken = await Authentication . verifyAccessToken (
149+ account ,
150+ currentWindow
151+ )
141152
142- return [ response . data ]
153+ if ( ! accessToken ) {
154+ return [ ]
143155 }
156+
157+ const response = await setClaimMissionAlertRewards ( {
158+ accessToken,
159+ accountId : account . accountId ,
160+ } )
161+
162+ return [ response . data ]
144163 } catch ( error ) {
145164 //
146165 }
147166
148167 return [ ] as Array < MCPClaimMissionAlertRewardsResponse >
149168 }
150169
151- static async claimDifficultyIncreaseRewards ( account : AccountData ) {
170+ static async claimDifficultyIncreaseRewards (
171+ currentWindow : BrowserWindow ,
172+ account : AccountData
173+ ) {
152174 try {
153- const accessToken = await Authentication . verifyAccessToken ( account )
154-
155- if ( accessToken ) {
156- const response = await setClaimDifficultyIncreaseRewards ( {
157- accessToken,
158- accountId : account . accountId ,
159- } )
175+ const accessToken = await Authentication . verifyAccessToken (
176+ account ,
177+ currentWindow
178+ )
160179
161- return [ response . data ]
180+ if ( ! accessToken ) {
181+ return [ ]
162182 }
183+
184+ const response = await setClaimDifficultyIncreaseRewards ( {
185+ accessToken,
186+ accountId : account . accountId ,
187+ } )
188+
189+ return [ response . data ]
163190 } catch ( error ) {
164191 //
165192 }
166193
167194 return [ ] as Array < MCPClaimDifficultyIncreaseRewardsResponse >
168195 }
169196
170- static async redeemSTWAccoladeTokens ( account : AccountData ) {
197+ static async redeemSTWAccoladeTokens (
198+ currentWindow : BrowserWindow ,
199+ account : AccountData
200+ ) {
171201 try {
172- const accessToken = await Authentication . verifyAccessToken ( account )
173-
174- if ( accessToken ) {
175- const response = await setRedeemSTWAccoladeTokens ( {
176- accessToken,
177- accountId : account . accountId ,
178- } )
202+ const accessToken = await Authentication . verifyAccessToken (
203+ account ,
204+ currentWindow
205+ )
179206
180- return response . data
207+ if ( ! accessToken ) {
208+ return null
181209 }
210+
211+ const response = await setRedeemSTWAccoladeTokens ( {
212+ accessToken,
213+ accountId : account . accountId ,
214+ } )
215+
216+ return response . data
182217 } catch ( error ) {
183218 //
184219 }
0 commit comments