Fix linkfile prefix
This commit is contained in:
parent
c6260b9d12
commit
92107e1b8f
|
@ -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 = () => {
|
|||
<p>Download a file by pasting in a Sia linkfile below:</p>
|
||||
<Box sx={{ width: "60%" }}>
|
||||
<Input
|
||||
// placeholder="sia://"
|
||||
placeholder="sia://"
|
||||
value={linkfileUrl}
|
||||
onChange={e => setInput(e.target.value)}
|
||||
sx={{ width: "100%" }}
|
||||
|
|
|
@ -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() {
|
|||
<h5>{link}</h5>
|
||||
</Flex>
|
||||
) : (
|
||||
<Flex
|
||||
{...getRootProps()}
|
||||
sx={{ height: 400, justifyContent: "center", alignItems: "center" }}
|
||||
>
|
||||
<input {...getInputProps()} />
|
||||
{isDragActive && !loading && !error && !link && (
|
||||
<p>Drop file here ...</p>
|
||||
)}
|
||||
{!isDragActive && !loading && !error && !link && (
|
||||
<p>Drag 'n' drop a file here, or click to select a file</p>
|
||||
)}
|
||||
{loading && <CircularProgress />}
|
||||
{error && !loading && <h5>{error}</h5>}
|
||||
</Flex>
|
||||
)}
|
||||
<Flex
|
||||
{...getRootProps()}
|
||||
sx={{ height: 400, justifyContent: "center", alignItems: "center" }}
|
||||
>
|
||||
<input {...getInputProps()} />
|
||||
{isDragActive && !loading && !error && !link && (
|
||||
<p>Drop file here ...</p>
|
||||
)}
|
||||
{!isDragActive && !loading && !error && !link && (
|
||||
<p>Drag 'n' drop a file here, or click to select a file</p>
|
||||
)}
|
||||
{loading && <CircularProgress />}
|
||||
{error && !loading && <h5>{error}</h5>}
|
||||
</Flex>
|
||||
)}
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
|
|
Reference in New Issue