Fixed page breaking if no valid campaigns are found.

This commit is contained in:
DebaucheryLibrarian 2024-06-14 01:09:23 +02:00
parent 7808a3e059
commit 0f6bbaf536
1 changed files with 18 additions and 18 deletions

View File

@ -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)];