Skip to content

Commit

Permalink
Merge pull request #812 from jhaals/fix-dual-download
Browse files Browse the repository at this point in the history
Do not download multiple times
  • Loading branch information
jhaals committed Mar 11, 2021
2 parents c12ca35 + 25cd97e commit ab5d0a9
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions website/src/displaySecret/Secret.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { faCopy } from '@fortawesome/free-solid-svg-icons';
import { Button, Typography, makeStyles } from '@material-ui/core';
import { useCopyToClipboard } from 'react-use';
import { saveAs } from 'file-saver';
import { useEffect } from 'react';

const useStyles = makeStyles(() => ({
pre: {
Expand All @@ -29,13 +30,17 @@ const Secret = ({
const [copy, copyToClipboard] = useCopyToClipboard();
const classes = useStyles();

useEffect(() => {
fileName &&
saveAs(
new Blob([secret], {
type: 'application/octet-stream',
}),
fileName,
);
}, [fileName, secret]);

if (fileName) {
saveAs(
new Blob([secret], {
type: 'application/octet-stream',
}),
fileName,
);
return (
<div>
<Typography variant="h4">{t('File downloaded')}</Typography>
Expand Down

0 comments on commit ab5d0a9

Please sign in to comment.