Skip to content

Commit 91846bd

Browse files
committed
fix(web/temporary): use cloudflare gateway for evidences
1 parent 4e90b12 commit 91846bd

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

web/src/components/EvidenceCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import styled from "styled-components";
33
import Jazzicon, { jsNumberForAddress } from "react-jazzicon";
44
import { Card } from "@kleros/ui-components-library";
55
import AttachmentIcon from "svgs/icons/attachment.svg";
6-
import { useIPFSQuery } from "hooks/useIPFSQuery";
6+
import { useIPFSQuery } from "hooks/useIPFSCloudflare";
77
import { shortenAddress } from "utils/shortenAddress";
88

99
interface IEvidenceCard {
@@ -32,7 +32,7 @@ const EvidenceCard: React.FC<IEvidenceCard> = ({ evidence, sender, index }) => {
3232
<p>{shortenAddress(sender)}</p>
3333
{data && (
3434
<StyledA
35-
href={`https://ipfs.kleros.io${data.fileURI}`}
35+
href={`https://cloudflare-ipfs.com${data.fileURI}`}
3636
target="_blank"
3737
rel="noreferrer"
3838
>

web/src/hooks/useIPFSCloudflare.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import useSWRImmutable from "swr/immutable";
2+
3+
export const useIPFSQuery = (ipfsPath?: string) => {
4+
return useSWRImmutable(
5+
() => (ipfsPath !== undefined ? ipfsPath : false),
6+
async () => {
7+
if (ipfsPath) {
8+
return fetch(`https://cloudflare-ipfs.com${ipfsPath}`).then((res) =>
9+
res.json()
10+
);
11+
} else throw Error;
12+
}
13+
);
14+
};

web/src/hooks/useIPFSQuery.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ export const useIPFSQuery = (ipfsPath?: string) => {
44
return useSWRImmutable(
55
() => (ipfsPath !== undefined ? ipfsPath : false),
66
async () => {
7-
console.log("ipfsQuery", ipfsPath);
87
if (ipfsPath) {
98
return fetch(`https://ipfs.kleros.io${ipfsPath}`).then((res) =>
109
res.json()

0 commit comments

Comments
 (0)