diff --git a/packages/siaviewnode-client/pages/index.tsx b/packages/siaviewnode-client/pages/index.tsx index 197ffab8..d0037716 100644 --- a/packages/siaviewnode-client/pages/index.tsx +++ b/packages/siaviewnode-client/pages/index.tsx @@ -1,5 +1,6 @@ /** @jsx jsx */ import { AppBar, Button, Card, CardContent, Container, Input, Tab, Tabs, Typography } from "@material-ui/core" +import * as R from "ramda" import { useState } from "react" import { Box, Flex, jsx } from "theme-ui" import Dropzone from "../src/components/Dropzone" @@ -14,8 +15,10 @@ const Index = () => { } const directView = () => { + const removeHead = R.compose(R.tail, R.split("sia://")) + const hash = removeHead(linkfileUrl)[0] if (window) { - var win = window.open(`/direct/${linkfileUrl}`, "_blank") + var win = window.open(`/direct/${hash}`, "_blank") win.focus() } } @@ -73,7 +76,7 @@ const Index = () => {

Download a file by pasting in a Sia linkfile below:

setInput(e.target.value)} sx={{ width: "100%" }} diff --git a/packages/siaviewnode-client/src/components/Dropzone.tsx b/packages/siaviewnode-client/src/components/Dropzone.tsx index 8b22da66..f3df8d0d 100644 --- a/packages/siaviewnode-client/src/components/Dropzone.tsx +++ b/packages/siaviewnode-client/src/components/Dropzone.tsx @@ -1,10 +1,9 @@ /** @jsx jsx */ +import { CircularProgress } from "@material-ui/core" import * as R from "ramda" -import { useCallback, useState, useRef } from "react" +import { useCallback, useState } from "react" import { useDropzone } from "react-dropzone" import { Box, Flex, jsx } from "theme-ui" -import { CircularProgress, Button } from "@material-ui/core" -import { saveAs } from "file-saver" /** * nginx is setup to automatically handle and rewrite the url path. */ @@ -38,7 +37,7 @@ function MyDropzone() { }) .then(({ sialink }) => { console.log("WE OUT HERE BOYS", sialink) - setLink(sialink) + setLink(`sia://${sialink}`) setLoading(false) }) .catch(e => { @@ -61,21 +60,21 @@ function MyDropzone() {
{link}
) : ( - - - {isDragActive && !loading && !error && !link && ( -

Drop file here ...

- )} - {!isDragActive && !loading && !error && !link && ( -

Drag 'n' drop a file here, or click to select a file

- )} - {loading && } - {error && !loading &&
{error}
} -
- )} + + + {isDragActive && !loading && !error && !link && ( +

Drop file here ...

+ )} + {!isDragActive && !loading && !error && !link && ( +

Drag 'n' drop a file here, or click to select a file

+ )} + {loading && } + {error && !loading &&
{error}
} +
+ )}
) }