forked from OpenWF/SpaceNinjaServer
chore: save inventory and account in parallel when claiming login reward (#2371)
Reviewed-on: OpenWF/SpaceNinjaServer#2371 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
parent
24d9dc27e2
commit
5a5f6106a3
@ -48,10 +48,8 @@ export const loginRewardsController: RequestHandler = async (req, res) => {
|
|||||||
response.DailyTributeInfo.HasChosenReward = true;
|
response.DailyTributeInfo.HasChosenReward = true;
|
||||||
response.DailyTributeInfo.ChosenReward = randomRewards[0];
|
response.DailyTributeInfo.ChosenReward = randomRewards[0];
|
||||||
response.DailyTributeInfo.NewInventory = await claimLoginReward(inventory, randomRewards[0]);
|
response.DailyTributeInfo.NewInventory = await claimLoginReward(inventory, randomRewards[0]);
|
||||||
await inventory.save();
|
|
||||||
|
|
||||||
setAccountGotLoginRewardToday(account);
|
setAccountGotLoginRewardToday(account);
|
||||||
await account.save();
|
await Promise.all([inventory.save(), account.save()]);
|
||||||
|
|
||||||
sendWsBroadcastTo(account._id.toString(), { update_inventory: true });
|
sendWsBroadcastTo(account._id.toString(), { update_inventory: true });
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,8 @@ export const loginRewardsSelectionController: RequestHandler = async (req, res)
|
|||||||
chosenReward = randomRewards.find(x => x.StoreItemType == body.ChosenReward)!;
|
chosenReward = randomRewards.find(x => x.StoreItemType == body.ChosenReward)!;
|
||||||
inventoryChanges = await claimLoginReward(inventory, chosenReward);
|
inventoryChanges = await claimLoginReward(inventory, chosenReward);
|
||||||
}
|
}
|
||||||
await inventory.save();
|
|
||||||
|
|
||||||
setAccountGotLoginRewardToday(account);
|
setAccountGotLoginRewardToday(account);
|
||||||
await account.save();
|
await Promise.all([inventory.save(), account.save()]);
|
||||||
|
|
||||||
sendWsBroadcastTo(account._id.toString(), { update_inventory: true });
|
sendWsBroadcastTo(account._id.toString(), { update_inventory: true });
|
||||||
res.json({
|
res.json({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user