Skip to content

Commit

Permalink
Added error handeling and h5webParams if domain is absent
Browse files Browse the repository at this point in the history
  • Loading branch information
sergesoroka committed Sep 15, 2024
1 parent a3d99a2 commit e52434e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
13 changes: 2 additions & 11 deletions components/Chart/Chart.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react/prop-types */
import * as Plot from "@observablehq/plot";
import { useEffect, useRef, useState } from "react";
import { Link, useNavigate } from "react-router-dom";
import { useNavigate } from "react-router-dom";
import useSWR from "swr";

export default function Chart({ imageSelected, setDomain, isNexusFile }) {
Expand Down Expand Up @@ -103,21 +103,12 @@ export default function Chart({ imageSelected, setDomain, isNexusFile }) {
>
{copied ? "Copied to clipboard" : "Share a link"}
</button>
{/* <Link target="_blank" rel="noopener noreferrer"
onClick={() => {
navigate(`?h5web=${imageSelected}`);
if(!isNexusFile) {
setDomain(data.domain);
}
}}
>Share</Link> */}

<button
className="shareBtn"
target="_blank" rel="noopener noreferrer"
style={{ marginLeft: "16px" }}
onClick={() => {
// navigate(`?h5web=${imageSelected}`);
window.open(`?h5web=${imageSelected}`, "_blank")
if(!isNexusFile) {
setDomain(data.domain);
Expand Down
4 changes: 2 additions & 2 deletions components/h5web/h5web.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export default function H5web({ domain }) {
const a = document.createElement("a");
a.style.display = "none";
a.href = url;
a.download = `${domain}`;
a.download = `${domain ? domain : h5webParams}`;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);

})
.catch(() => alert("oh no!"));
.catch(() => alert("Failed to download the file!"));
}

return (
Expand Down

0 comments on commit e52434e

Please sign in to comment.