Skip to content

Commit

Permalink
Merge pull request #232 from CityOfZion/CU-86a5awrtq
Browse files Browse the repository at this point in the history
CU-86a5awrtq-NEON3 - BUG - Investigate issue where the app is consumi…
  • Loading branch information
thiagocbalducci authored Oct 22, 2024
2 parents 716b6c1 + 3658dad commit b481aa1
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/renderer/src/components/ButtonDownloadPasswordQRCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export const ButtonDownloadPasswordQRCode = ({ label, variant, leftIcon, onDownl
const [decryptedPassword, setDecryptedPassword] = useState<string>('')

const handleDownload = () => {
UtilsHelper.donwloadSVGToPng('QRCode')
UtilsHelper.downloadSVGToPng('QRCode')

if (onDownload) onDownload()
}

Expand Down
12 changes: 10 additions & 2 deletions src/renderer/src/helpers/UtilsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class UtilsHelper {
return uuid.v4()
}

static donwloadSVGToPng(elementId: string, suggestedFileName?: string) {
static downloadSVGToPng(elementId: string, suggestedFileName?: string) {
const svg = document.getElementById(elementId)
if (!svg) return

Expand All @@ -132,13 +132,21 @@ export class UtilsHelper {
img.onload = () => {
canvas.width = img.width
canvas.height = img.height

ctx.drawImage(img, 0, 0)

const pngFile = canvas.toDataURL('image/png')
const downloadLink = document.createElement('a')

downloadLink.download = fileName
downloadLink.href = `${pngFile}`
downloadLink.href = pngFile
downloadLink.click()

canvas.remove()
downloadLink.remove()
img.remove()
}

img.src = `data:image/svg+xml;base64,${btoa(svgData)}`
}

Expand Down
1 change: 0 additions & 1 deletion src/renderer/src/hooks/useExchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ export function useExchange(params: TUseExchangeParams[]): TUseExchangeResult {
currency,
currencyRatio
),
staleTime: 0,
enabled: !isCurrencyRatioLoading && typeof currencyRatio === 'number',
})),
combine: result => ({
Expand Down
2 changes: 0 additions & 2 deletions src/renderer/src/hooks/usePriceHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export const usePriceHistory = (tokenBalances: TTokenBalance[]): TUsePriceHistor
queries: tokenBalances.map(tokenBalance => ({
queryKey: ['prices', tokenBalance.token.symbol, currency],
queryFn: fetchTokenData.bind(null, tokenBalance, currencyRatio),
staleTime: 0,
retry: false,
enabled: !isCurrencyRatioLoading && typeof currencyRatio === 'number',
})),
combine: results => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ReceiveYourAddressContent = ({ account }: TProps) => {
const [selectedAccount, setSelectedAccount] = useState(account)

const handleDownload = () => {
UtilsHelper.donwloadSVGToPng('QRCode', selectedAccount?.address)
UtilsHelper.downloadSVGToPng('QRCode', selectedAccount?.address)
}

return (
Expand Down

0 comments on commit b481aa1

Please sign in to comment.