Skip to content

Commit

Permalink
[Ice] #70
Browse files Browse the repository at this point in the history
  • Loading branch information
icegriffinguru committed Aug 1, 2023
1 parent 3b74378 commit f916a59
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
23 changes: 22 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"react-dom": "18.2.0",
"react-hot-toast": "2.4.0",
"react-icons": "4.8.0",
"react-inlinesvg": "^3.0.2",
"react-modal": "3.16.1",
"react-router-dom": "6.4.2",
"react-tooltip": "5.11.1",
Expand Down
1 change: 1 addition & 0 deletions src/libs/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export enum BlobDataType {
TEXT,
IMAGE,
AUDIO,
SVG,
}
19 changes: 15 additions & 4 deletions src/pages/MyWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useGetLoginInfo } from "@multiversx/sdk-dapp/hooks";
import { ModalBody } from "react-bootstrap";
import ModalHeader from "react-bootstrap/esm/ModalHeader";
import { IoClose } from "react-icons/io5";
import SVG from 'react-inlinesvg';
import Modal from "react-modal";
import { useNavigate, useParams } from "react-router-dom";
import { DataNftCard, Loader, TrailBlazerModal } from "components";
Expand Down Expand Up @@ -111,10 +112,15 @@ export const MyWallet = () => {
let blobDataType = BlobDataType.TEXT;
if (!res.error) {
if (res.contentType.search("image") >= 0) {
res.data = window.URL.createObjectURL(
new Blob([res.data], { type: res.contentType })
);
blobDataType = BlobDataType.IMAGE;
if (res.contentType == "image/svg+xml") {
blobDataType = BlobDataType.SVG;
res.data = await (res.data as Blob).text();
} else {
blobDataType = BlobDataType.IMAGE;
res.data = window.URL.createObjectURL(
new Blob([res.data], { type: res.contentType })
);
}
} else if (res.contentType.search("audio") >= 0) {
res.data = window.URL.createObjectURL(
new Blob([res.data], { type: res.contentType })
Expand Down Expand Up @@ -371,6 +377,11 @@ export const MyWallet = () => {
>
<audio controls autoPlay src={viewDataRes.data} />
</div>
) : viewDataRes.blobDataType === BlobDataType.SVG ? (
<SVG
src={viewDataRes.data}
style={{ width: "100%", height: "auto" }}
/>
) : (
<p
className="p-2"
Expand Down

0 comments on commit f916a59

Please sign in to comment.