mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-13 23:42:12 +00:00
fix(promo): handle Gems sale defined outside of single top event
This commit is contained in:
parent
10f5011781
commit
9a8d1854b9
1 changed files with 6 additions and 4 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import find from 'lodash/find';
|
||||
import { getAnalyticsServiceByEnvironment } from '../analyticsService';
|
||||
import { getCurrentEvent } from '../worldState'; // eslint-disable-line import/no-cycle
|
||||
import { getCurrentEventList } from '../worldState'; // eslint-disable-line import/no-cycle
|
||||
import { // eslint-disable-line import/no-cycle
|
||||
getUserInfo,
|
||||
sendTxn as txnEmail,
|
||||
|
|
@ -86,9 +87,10 @@ function getAmountForGems (data) {
|
|||
|
||||
const { gemsBlock } = data;
|
||||
|
||||
const currentEvent = getCurrentEvent();
|
||||
if (currentEvent && currentEvent.gemsPromo && currentEvent.gemsPromo[gemsBlock.key]) {
|
||||
return currentEvent.gemsPromo[gemsBlock.key] / 4;
|
||||
const currentEventsList = getCurrentEventList();
|
||||
const promoEvent = find(currentEventsList, event => Boolean(event.gemsPromo));
|
||||
if (promoEvent && promoEvent.gemsPromo[gemsBlock.key]) {
|
||||
return promoEvent.gemsPromo[gemsBlock.key] / 4;
|
||||
}
|
||||
|
||||
return gemsBlock.gems / 4;
|
||||
|
|
|
|||
Loading…
Reference in a new issue