Skip to content

Commit

Permalink
Make requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
netalondon committed Jan 30, 2024
1 parent 5767259 commit b6ebc3b
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions web/src/pages/chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,27 +132,24 @@ export const Chip = () => {

const downloadRef = useRef<HTMLAnchorElement>(null);

const download = (blob: Blob) => {
const url = URL.createObjectURL(blob);

const downloadProject = async () => {
if (!downloadRef.current) {
return;
}
downloadRef.current.href = url;
downloadRef.current.download = `Project${state.controls.project}`;
downloadRef.current.click();

URL.revokeObjectURL(url);
};

const downloadProject = async () => {
const files = await actions.getProjectFiles();
const zip = new JSZip();

for (const file of files) {
zip.file(file.name, file.content);
}
await zip.generateAsync({ type: "blob" }).then(download);
const blob = await zip.generateAsync({ type: "blob" });
const url = URL.createObjectURL(blob);
downloadRef.current.href = url;
downloadRef.current.download = `Project${state.controls.project}`;
downloadRef.current.click();

URL.revokeObjectURL(url);
};

const [useBuiltin, setUseBuiltin] = useState(false);
Expand Down

0 comments on commit b6ebc3b

Please sign in to comment.