fix: Change confusing hide prices setting

This commit is contained in:
Samir L. Boulema 2026-05-09 12:45:57 +02:00
parent 4755fabfe9
commit 34fc19ff3c
5 changed files with 17 additions and 17 deletions

10
main.ts
View file

@ -22,7 +22,7 @@ const DEFAULT_SETTINGS: ObsidianPluginMtgSettings = {
showCardNamesAsHyperlinks: true,
showCardPreviews: true,
showBuylist: true,
hidePrices: false,
showCardPrices: true,
showManaCosts: true,
},
};
@ -220,13 +220,13 @@ class ObsidianPluginMtgSettingsTab extends PluginSettingTab {
);
new Setting(containerEl)
.setName("Hide prices")
.setDesc("Toggles card prices in decklists")
.setName("Show card prices")
.setDesc("Enables card prices to be displayed in decklists")
.addToggle((toggle) =>
toggle
.setValue(this.plugin.settings.decklist.hidePrices)
.setValue(this.plugin.settings.decklist.showCardPrices)
.onChange(async (value: boolean) => {
this.plugin.settings.decklist.hidePrices = value;
this.plugin.settings.decklist.showCardPrices = value;
await this.plugin.saveSettings();
})
);

View file

@ -52,7 +52,7 @@ describe("Collection", () => {
showCardNamesAsHyperlinks: true,
showCardPreviews: true,
showBuylist: true,
hidePrices: false,
showCardPrices: true,
showManaCosts: true,
},
};

View file

@ -32,7 +32,7 @@ describe("Renderer", () => {
showCardNamesAsHyperlinks: true,
showCardPreviews: true,
showBuylist: true,
hidePrices: false,
showCardPrices: true,
showManaCosts: true,
},
};
@ -57,7 +57,7 @@ describe("Renderer", () => {
...settings,
decklist: {
...settings.decklist,
hidePrices: true,
showCardPrices: false,
},
},
fakeFetcher

View file

@ -69,9 +69,9 @@ export const getCardPrice = (
const cardId = nameToId(cardName);
const cardData = cardDataById[cardId];
const preferredCurrency = settings.decklist.preferredCurrency;
const hidePrices = settings.decklist.hidePrices;
const showCardPrices = settings.decklist.showCardPrices;
if (!cardData || hidePrices) {
if (!cardData || !showCardPrices) {
return null;
} else {
if (preferredCurrency === "eur") {
@ -330,7 +330,7 @@ export const renderDecklist = async (
sectionListHeadRow.createEl("th", { text: "Cost" });
}
if (!settings.decklist.hidePrices) {
if (settings.decklist.showCardPrices) {
sectionListHeadRow.createEl("th", { text: "Price" });
}
@ -404,7 +404,7 @@ export const renderDecklist = async (
let cardPrice;
let cardPriceEl;
if (!settings.decklist.hidePrices) {
if (settings.decklist.showCardPrices) {
const cardPriceCell = lineEl.createEl("td");
cardPriceEl = cardPriceCell.createSpan({ cls: "card-price" });
@ -600,7 +600,7 @@ export const renderDecklist = async (
sectionListFootRow.createEl("td");
let totalCostEl;
if (hasCardInfo && !settings.decklist.hidePrices) {
if (hasCardInfo && settings.decklist.showCardPrices) {
totalCostEl = sectionListFootRow.createEl("td", { cls: "decklist__section-totals__cost fit" });
}
@ -641,7 +641,7 @@ export const renderDecklist = async (
}, 0.0);
// Value
if (hasCardInfo && !settings.decklist.hidePrices) {
if (hasCardInfo && settings.decklist.showCardPrices) {
const totalValueOwned =
sectionTotalCost[section] - totalMissingCostInSection;
totalCostEl!.createSpan({
@ -660,7 +660,7 @@ export const renderDecklist = async (
} else {
totalCardsEl.textContent = `${sectionTotalCounts[section]}`;
if (!settings.decklist.hidePrices) {
if (settings.decklist.showCardPrices) {
totalCostEl!.textContent = `${currencyMapping[settings.decklist.preferredCurrency]
}${sectionTotalCost[section].toFixed(2)}`;
}
@ -735,7 +735,7 @@ export const renderDecklist = async (
text: "cards",
});
if (hasCardInfo && !settings.decklist.hidePrices) {
if (hasCardInfo && settings.decklist.showCardPrices) {
buylistLineEl.createSpan({
cls: "decklist__section-totals",
text: `${currencyMapping[settings.decklist.preferredCurrency]

View file

@ -19,7 +19,7 @@ export interface ObsidianPluginMtgSettings {
// Show buylist
showBuylist: boolean;
// Show prices
hidePrices: boolean;
showCardPrices: boolean;
// Show mana costs
showManaCosts: boolean;
};