Fix linkfile prefix

This commit is contained in:
PJ 2020-01-23 20:38:31 +01:00
parent c6260b9d12
commit 92107e1b8f
2 changed files with 23 additions and 21 deletions

View File

@ -1,5 +1,6 @@
/** @jsx jsx */ /** @jsx jsx */
import { AppBar, Button, Card, CardContent, Container, Input, Tab, Tabs, Typography } from "@material-ui/core" import { AppBar, Button, Card, CardContent, Container, Input, Tab, Tabs, Typography } from "@material-ui/core"
import * as R from "ramda"
import { useState } from "react" import { useState } from "react"
import { Box, Flex, jsx } from "theme-ui" import { Box, Flex, jsx } from "theme-ui"
import Dropzone from "../src/components/Dropzone" import Dropzone from "../src/components/Dropzone"
@ -14,8 +15,10 @@ const Index = () => {
} }
const directView = () => { const directView = () => {
const removeHead = R.compose(R.tail, R.split("sia://"))
const hash = removeHead(linkfileUrl)[0]
if (window) { if (window) {
var win = window.open(`/direct/${linkfileUrl}`, "_blank") var win = window.open(`/direct/${hash}`, "_blank")
win.focus() win.focus()
} }
} }
@ -73,7 +76,7 @@ const Index = () => {
<p>Download a file by pasting in a Sia linkfile below:</p> <p>Download a file by pasting in a Sia linkfile below:</p>
<Box sx={{ width: "60%" }}> <Box sx={{ width: "60%" }}>
<Input <Input
// placeholder="sia://" placeholder="sia://"
value={linkfileUrl} value={linkfileUrl}
onChange={e => setInput(e.target.value)} onChange={e => setInput(e.target.value)}
sx={{ width: "100%" }} sx={{ width: "100%" }}

View File

@ -1,10 +1,9 @@
/** @jsx jsx */ /** @jsx jsx */
import { CircularProgress } from "@material-ui/core"
import * as R from "ramda" import * as R from "ramda"
import { useCallback, useState, useRef } from "react" import { useCallback, useState } from "react"
import { useDropzone } from "react-dropzone" import { useDropzone } from "react-dropzone"
import { Box, Flex, jsx } from "theme-ui" 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. * nginx is setup to automatically handle and rewrite the url path.
*/ */
@ -38,7 +37,7 @@ function MyDropzone() {
}) })
.then(({ sialink }) => { .then(({ sialink }) => {
console.log("WE OUT HERE BOYS", sialink) console.log("WE OUT HERE BOYS", sialink)
setLink(sialink) setLink(`sia://${sialink}`)
setLoading(false) setLoading(false)
}) })
.catch(e => { .catch(e => {