diff --git a/configschema.json b/configschema.json index 8192850..06ff7bd 100644 --- a/configschema.json +++ b/configschema.json @@ -109,13 +109,18 @@ "type": "string", "default": "en-US" } - } + }, + "required": [ + "symbol", + "countryCode" + ] } }, "required": [ "shorts", "thisEvent", - "online" + "online", + "currency" ] }, "omnibar": { diff --git a/src/graphics/_misc/helpers.ts b/src/graphics/_misc/helpers.ts index 23750c4..f5c3b61 100644 --- a/src/graphics/_misc/helpers.ts +++ b/src/graphics/_misc/helpers.ts @@ -36,10 +36,8 @@ export function msToTimeStr(ms: number): string { /** * Simple formatter for displaying currency amounts. * @param amount Amount as a integer/float. - * @param _symbol The currency symbol - * (defaults to what's set in the config, or `$` if the config isn't set) - * @param _countryCode The country code - * (defaults to what's set in the config, or `en-US` if the config isn't set) + * @param _symbol The currency symbol (defaults to what's set in the config) + * @param _countryCode The country code (defaults to what's set in the config) */ export function formatCurrency( amount: number, @@ -47,8 +45,8 @@ export function formatCurrency( _countryCode?: string, ): string { const cfg = (config as DeepWritable).event.currency; - const symbol = _symbol || cfg?.symbol || '$'; - const countryCode = _countryCode || cfg?.countryCode || 'en-US'; + const symbol = _symbol || cfg.symbol; + const countryCode = _countryCode || cfg.countryCode; if (amount >= 100) { return `${symbol}${Math.floor(amount).toLocaleString( diff --git a/src/graphics/omnibar/components/Total.vue b/src/graphics/omnibar/components/Total.vue index e417c56..4e3521d 100644 --- a/src/graphics/omnibar/components/Total.vue +++ b/src/graphics/omnibar/components/Total.vue @@ -155,8 +155,8 @@ export default class extends Vue { get totalStr(): string { // "Reset" value every 10k, specific to ESA Legends 2023. - const symbol = nodecg.bundleConfig.event.currency?.symbol || '$'; - const countryCode = nodecg.bundleConfig.event.currency?.countryCode || 'en-US'; + const symbol = nodecg.bundleConfig.event.currency.symbol; + const countryCode = nodecg.bundleConfig.event.currency.countryCode; const esal23 = nodecg.bundleConfig.event.shorts === 'esal23'; diff --git a/src/types/schemas/configschema.d.ts b/src/types/schemas/configschema.d.ts index 4d38d0b..5a29d35 100644 --- a/src/types/schemas/configschema.d.ts +++ b/src/types/schemas/configschema.d.ts @@ -13,9 +13,9 @@ export interface Configschema { thisEvent: number; online: boolean | ("partial" | "full"); fallbackTwitchTitle?: string; - currency?: { - symbol?: string; - countryCode?: string; + currency: { + symbol: string; + countryCode: string; }; }; omnibar: {