mirror of
https://github.com/oceanprotocol/market.git
synced 2024-11-15 01:34:57 +01:00
Merge branch 'fix/490' into main
This commit is contained in:
commit
e21780530a
@ -27,7 +27,7 @@ export default function FileInput({
|
||||
<Button
|
||||
style="primary"
|
||||
size="small"
|
||||
onClick={(e: React.SyntheticEvent) => handleButtonClick(e, field.value)}
|
||||
onClick={(e: React.SyntheticEvent) => e.preventDefault()}
|
||||
disabled={!field.value}
|
||||
>
|
||||
{isLoading ? <Loader /> : 'Add File'}
|
||||
|
@ -14,7 +14,7 @@ export default function FilesInput(props: InputProps): ReactElement {
|
||||
const [fileUrl, setFileUrl] = useState<string>()
|
||||
const { config } = useOcean()
|
||||
|
||||
useEffect(() => {
|
||||
function loadFileInfo() {
|
||||
const source = axios.CancelToken.source()
|
||||
|
||||
async function validateUrl() {
|
||||
@ -33,11 +33,16 @@ export default function FilesInput(props: InputProps): ReactElement {
|
||||
setIsLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
fileUrl && validateUrl()
|
||||
|
||||
return () => {
|
||||
source.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
loadFileInfo()
|
||||
}, [fileUrl, config.providerUri])
|
||||
|
||||
async function handleButtonClick(e: React.SyntheticEvent, url: string) {
|
||||
@ -48,6 +53,11 @@ export default function FilesInput(props: InputProps): ReactElement {
|
||||
// File example 'https://oceanprotocol.com/tech-whitepaper.pdf'
|
||||
e.preventDefault()
|
||||
|
||||
// In the case when the user re-add the same URL after it was removed (by accident or intentionally)
|
||||
if (fileUrl === url) {
|
||||
loadFileInfo()
|
||||
}
|
||||
|
||||
setFileUrl(url)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user