From 6bc8d247bd65f13c693c6bfd4b1ca0b5c9bf5f2e Mon Sep 17 00:00:00 2001 From: finned-palmer Date: Sat, 10 Jul 2021 08:27:49 -0500 Subject: [PATCH] Map dollar sign to USD --- pkg/btc-wallet/src/js/hooks/useSettings.js | 3 ++- pkg/btc-wallet/src/js/lib/util.js | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/btc-wallet/src/js/hooks/useSettings.js b/pkg/btc-wallet/src/js/hooks/useSettings.js index 55e7038e4..c6e491753 100644 --- a/pkg/btc-wallet/src/js/hooks/useSettings.js +++ b/pkg/btc-wallet/src/js/hooks/useSettings.js @@ -1,7 +1,7 @@ import React, { createContext, useContext, useEffect, useState } from 'react'; import _ from 'lodash'; import { api } from '../api'; -import { reduceHistory } from '../lib/util'; +import { mapDenominationToSymbol, reduceHistory } from '../lib/util'; export const SettingsContext = createContext({ network: 'bitcoin', @@ -120,6 +120,7 @@ export const SettingsProvider = ({ channel, children }) => { const newCurrencyRates = currencyRates; for (let c in n) { newCurrencyRates[c] = n[c]; + newCurrencyRates[c].symbol = mapDenominationToSymbol(c); } setCurrencyRates(newCurrencyRates); setTimeout(() => initializeCurrencyPoll(), 1000 * 60 * 15); diff --git a/pkg/btc-wallet/src/js/lib/util.js b/pkg/btc-wallet/src/js/lib/util.js index 131ec4012..2c133559a 100644 --- a/pkg/btc-wallet/src/js/lib/util.js +++ b/pkg/btc-wallet/src/js/lib/util.js @@ -118,3 +118,12 @@ export function reduceHistory(history) { return hest2.recvd - hest1.recvd; }); } + +export function mapDenominationToSymbol(denomination) { + switch (denomination) { + case 'USD': + return '$'; + default: + return denomination; + } +}