返回提交历史
Modified
src/controllers/api/loginRewardsController.ts
+1
-3
Modified
src/controllers/api/loginRewardsSelectionController.ts
+1
-3
XFEstudio/XFESpaceNinjaServer
chore: save inventory and account in parallel when claiming login reward (#2371)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2371 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
5a5f6106
代码差异
2 个文件
+2
-6
@@ -48,10 +48,8 @@ export const loginRewardsController: RequestHandler = async (req, res) => {
48
48
response.DailyTributeInfo.HasChosenReward = true;
49
49
response.DailyTributeInfo.ChosenReward = randomRewards[0];
50
50
response.DailyTributeInfo.NewInventory = await claimLoginReward(inventory, randomRewards[0]);
51
await inventory.save();
52
53
51
setAccountGotLoginRewardToday(account);
54
await account.save();
52
await Promise.all([inventory.save(), account.save()]);
55
53
56
54
sendWsBroadcastTo(account._id.toString(), { update_inventory: true });
57
55
}
@@ -35,10 +35,8 @@ export const loginRewardsSelectionController: RequestHandler = async (req, res)
35
35
chosenReward = randomRewards.find(x => x.StoreItemType == body.ChosenReward)!;
36
36
inventoryChanges = await claimLoginReward(inventory, chosenReward);
37
37
}
38
await inventory.save();
39
40
38
setAccountGotLoginRewardToday(account);
41
await account.save();
39
await Promise.all([inventory.save(), account.save()]);
42
40
43
41
sendWsBroadcastTo(account._id.toString(), { update_inventory: true });
44
42
res.json({