Fixed page breaking if no valid campaigns are found.
This commit is contained in:
parent
7808a3e059
commit
0f6bbaf536
|
@ -57,6 +57,7 @@ export async function getRandomCampaign(options = {}, context = {}) {
|
|||
return true;
|
||||
});
|
||||
|
||||
if (validCampaigns.length > 0) {
|
||||
const campaignsByEntityId = validCampaigns.reduce((acc, campaign) => {
|
||||
const entityId = campaign.entity.parent?.id || campaign.entity.id;
|
||||
|
||||
|
@ -75,7 +76,6 @@ export async function getRandomCampaign(options = {}, context = {}) {
|
|||
|
||||
const primaryCampaigns = randomEntityCampaigns.filter((campaign) => campaign.entity.id === options.entityIds?.[0]);
|
||||
|
||||
if (validCampaigns.length > 0) {
|
||||
const randomCampaign = (primaryCampaigns.length > 0 ? primaryCampaigns[crypto.randomInt(primaryCampaigns.length)] : null)
|
||||
|| (randomEntityCampaigns.length > 0 ? randomEntityCampaigns[crypto.randomInt(randomEntityCampaigns.length)] : null)
|
||||
|| validCampaigns[crypto.randomInt(validCampaigns.length)];
|
||||
|
|
Loading…
Reference in New Issue