diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-07-05 17:34:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-05 17:34:40 +0300 |
commit | 056bfe1fb3aa23ce45f068cf3c138a02293adaa2 (patch) | |
tree | 31efd6b9c55796cc7d9afd0f96cb4299cbd30220 | |
parent | a5c57253ceb0923aefd8dedcb7bd912cb1fa3d2e (diff) | |
parent | 8b5df9285b3917c63b7904b434354e3d4b58858d (diff) | |
download | which-ui-056bfe1fb3aa23ce45f068cf3c138a02293adaa2.tar.gz |
Merge pull request #65 from which-ecosystem/fix-instagram
Patch 1.0.1
-rw-r--r-- | package-lock.json | 2 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | src/components/UploadImage/UploadImage.tsx | 21 |
3 files changed, 9 insertions, 16 deletions
diff --git a/package-lock.json b/package-lock.json index 41430ec..0f360a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "which", - "version": "0.1.0", + "version": "1.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9d7e0a7..f3ab8c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "which", - "version": "1.0.0", + "version": "1.0.1", "homepage": "https://ilyayudovin.github.io/which", "dependencies": { "@material-ui/core": "^4.10.1", diff --git a/src/components/UploadImage/UploadImage.tsx b/src/components/UploadImage/UploadImage.tsx index 836b2a0..5b2f38e 100644 --- a/src/components/UploadImage/UploadImage.tsx +++ b/src/components/UploadImage/UploadImage.tsx @@ -6,9 +6,7 @@ import { DialogActions, DialogContent, DialogContentText, - DialogTitle, - FormControlLabel, - Switch + DialogTitle } from '@material-ui/core'; interface PropTypes { @@ -19,15 +17,18 @@ interface PropTypes { const UploadImage: React.FC<PropTypes> = ({ setIsOpen, isOpen, callback }) => { const [url, setUrl] = useState<string>(''); - const [isInstagramLink, setIsInstagramLink] = useState<boolean>(false); - const handleClose = () => { setIsOpen(false); }; const handleSubmit = () => { - const result = isInstagramLink ? `${url.slice(0, url.length - 29)}/media/?size=l` : url; + let result = url; + if (url.startsWith('https://www.instagram.com/')) { + const lastSlashIndex = url.lastIndexOf('/'); + const baseUrl = url.slice(0, lastSlashIndex); + result = `${baseUrl}/media/?size=l`; + } callback(result || ''); handleClose(); }; @@ -36,10 +37,6 @@ const UploadImage: React.FC<PropTypes> = ({ setIsOpen, isOpen, callback }) => { setUrl(event.target.value); }; - const handleSwitch = () => { - setIsInstagramLink(!isInstagramLink); - }; - return ( <div> <Dialog open={isOpen} onClose={handleClose}> @@ -58,10 +55,6 @@ const UploadImage: React.FC<PropTypes> = ({ setIsOpen, isOpen, callback }) => { autoComplete="off" onChange={handleChange} /> - <FormControlLabel - control={<Switch color="primary" onClick={handleSwitch} checked={isInstagramLink} size="small" />} - label="It's an Instagram link" - /> </DialogContent> <DialogActions> <Button onClick={handleClose} color="primary"> |