Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: filter out empty tiers in bundle overview (#2120) #2121

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/js/Content/Modules/Prices/BundleOverview.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@

export let data: TBundle[];

/**
* Filters out tiers that contain no games to prevent displaying empty tier sections
* @param bundle The bundle containing tiers to filter
* @returns Array of tiers that have at least one game
*/
function getNonEmptyTiers(bundle: TBundle) {
return bundle.tiers.filter(tier => tier.games.length > 0);
}

function getPrice(price: TPrice): Price {
let tierPrice = new Price(price.amount, price.currency);
try {
Expand Down Expand Up @@ -57,7 +66,7 @@
{/if}

<p class="package_contents">
{#each bundle.tiers as tier, num}
{#each getNonEmptyTiers(bundle) as tier, num}
<b class="as_bundle_tier_title"> <!-- class added for compatibility with Steam Currency Converter -->
{#if bundle.tiers.length > 1}
{L(__bundle_tierIncludes, {
Expand Down
Loading