Skip to content

Commit

Permalink
Use deep copy of DEFAULT_TIER_TEMPLATE (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
HecticKiwi authored Dec 29, 2024
1 parent 6865550 commit 1330036
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/TierCortex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,18 @@ export class TierCortex {
if (decodedState) return decodedState.tiers;
}

const initialTiers: Tier[] = JSON.parse(JSON.stringify(DEFAULT_TIER_TEMPLATE));

if (initialItemSet) {
const initialTiers = [...DEFAULT_TIER_TEMPLATE];
const lastTierIndex = initialTiers.length - 1;

initialTiers[lastTierIndex].items = initialItemSet.images.map((filename) => {
const itemId = `${initialItemSet.packageName}-${filename}`;
return this.packageItemLookup[itemId] || this.createPlaceholderItem(itemId, filename);
});
return initialTiers;
}

return DEFAULT_TIER_TEMPLATE;
return initialTiers;
}

public getOgSafeImageUrl(url: string): string {
Expand Down
2 changes: 1 addition & 1 deletion models/Tier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default interface Tier {
placeholder?: string;
}

export type TierTemplate = Record<string, Tier[]>;
export type TierTemplate = Record<string, Readonly<Tier>[]>;

export const tierTemplates: TierTemplate = {
'3rows': [
Expand Down

0 comments on commit 1330036

Please sign in to comment.