Skip to content

Commit bd42042

Browse files
committed
update react-dropzone, display error if no valid files
1 parent afe08df commit bd42042

3 files changed

Lines changed: 17 additions & 17 deletions

File tree

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"react": "17.0.2",
2828
"react-cookie": "^4.1.1",
2929
"react-dom": "17.0.2",
30-
"react-dropzone": "^11.4.2",
30+
"react-dropzone": "^14.2.3",
3131
"react-markdown": "^7.1.2",
3232
"remark-gfm": "^3.0.1",
3333
"slugify": "^1.6.5",

client/pages/upload.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ const Upload = ({ token, userId }) => {
5858
}
5959
reader.onerror = () => {
6060
console.log(`[DEBUG] upload error: ${reader.error}`)
61-
}
62-
reader.onabort = () => {
63-
console.log(`[DEBUG] upload aborted`)
61+
setDropError(reader.error.message)
6462
}
6563
reader.onprogress = (e) => {
6664
console.log(`[DEBUG] progress: ${e.loaded} bytes`)
6765
}
6866
reader.readAsDataURL(file)
6967
setDropError('')
68+
} else {
69+
setDropError('Must be a .torrent file')
7070
}
7171
} catch (e) {
7272
setDropError(e.message)
@@ -75,7 +75,7 @@ const Upload = ({ token, userId }) => {
7575

7676
const { getRootProps, getInputProps, isDragActive } = useDropzone({
7777
onDrop,
78-
accept: 'application/x-bittorrent',
78+
accept: { 'application/x-bittorrent': ['.torrent'] },
7979
maxFiles: 1,
8080
})
8181

@@ -120,7 +120,7 @@ const Upload = ({ token, userId }) => {
120120
const infoHash = await uploadRes.text()
121121
router.push(`/torrent/${infoHash}`)
122122
} catch (e) {
123-
addNotification('error', `Could not upload torrent: ${e.message}`)
123+
addNotification('error', `Could not upload file: ${e.message}`)
124124
console.error(e)
125125
}
126126

yarn.lock

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3074,12 +3074,12 @@ file-entry-cache@^6.0.1:
30743074
dependencies:
30753075
flat-cache "^3.0.4"
30763076

3077-
file-selector@^0.4.0:
3078-
version "0.4.0"
3079-
resolved "https://registry.yarnpkg.com/file-selector/-/file-selector-0.4.0.tgz#59ec4f27aa5baf0841e9c6385c8386bef4d18b17"
3080-
integrity sha512-iACCiXeMYOvZqlF1kTiYINzgepRBymz1wwjiuup9u9nayhb6g4fSwiyJ/6adli+EPwrWtpgQAh2PoS7HukEGEg==
3077+
file-selector@^0.6.0:
3078+
version "0.6.0"
3079+
resolved "https://registry.yarnpkg.com/file-selector/-/file-selector-0.6.0.tgz#fa0a8d9007b829504db4d07dd4de0310b65287dc"
3080+
integrity sha512-QlZ5yJC0VxHxQQsQhXvBaC7VRJ2uaxTf+Tfpu4Z/OcVQJVpZO+DGU0rkoVW5ce2SccxugvpBJoMvUs59iILYdw==
30813081
dependencies:
3082-
tslib "^2.0.3"
3082+
tslib "^2.4.0"
30833083

30843084
fill-range@^7.0.1:
30853085
version "7.0.1"
@@ -5282,13 +5282,13 @@ react-dom@17.0.2:
52825282
object-assign "^4.1.1"
52835283
scheduler "^0.20.2"
52845284

5285-
react-dropzone@^11.4.2:
5286-
version "11.7.1"
5287-
resolved "https://registry.yarnpkg.com/react-dropzone/-/react-dropzone-11.7.1.tgz#3851bb75b26af0bf1b17ce1449fd980e643b9356"
5288-
integrity sha512-zxCMwhfPy1olUEbw3FLNPLhAm/HnaYH5aELIEglRbqabizKAdHs0h+WuyOpmA+v1JXn0++fpQDdNfUagWt5hJQ==
5285+
react-dropzone@^14.2.3:
5286+
version "14.2.3"
5287+
resolved "https://registry.yarnpkg.com/react-dropzone/-/react-dropzone-14.2.3.tgz#0acab68308fda2d54d1273a1e626264e13d4e84b"
5288+
integrity sha512-O3om8I+PkFKbxCukfIR3QAGftYXDZfOE2N1mr/7qebQJHs7U+/RSL/9xomJNpRg9kM5h9soQSdf0Gc7OHF5Fug==
52895289
dependencies:
52905290
attr-accept "^2.2.2"
5291-
file-selector "^0.4.0"
5291+
file-selector "^0.6.0"
52925292
prop-types "^15.8.1"
52935293

52945294
react-is@^16.13.1, react-is@^16.7.0:
@@ -6155,7 +6155,7 @@ tslib@^1.8.1, tslib@^1.9.3:
61556155
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
61566156
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
61576157

6158-
tslib@^2.0.3, tslib@^2.1.0, tslib@^2.4.0:
6158+
tslib@^2.1.0, tslib@^2.4.0:
61596159
version "2.5.0"
61606160
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
61616161
integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==

0 commit comments

Comments
 (0)