Merge pull request #3515 from tylershuster/link-title

links: prevents title from being overwritten
This commit is contained in:
matildepark 2020-09-18 14:45:23 -04:00 committed by GitHub
commit f4a3ff77c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,11 +83,11 @@ export class LinkSubmit extends Component<LinkSubmitProps, LinkSubmitState> {
fetch(`https://noembed.com/embed?url=${linkValue}`) fetch(`https://noembed.com/embed?url=${linkValue}`)
.then(response => response.json()) .then(response => response.json())
.then((result) => { .then((result) => {
if (result.title) { if (result.title && !this.state.linkTitle) {
this.setState({ linkTitle: result.title }); this.setState({ linkTitle: result.title });
} }
}).catch((error) => {/*noop*/}); }).catch((error) => {/*noop*/});
} else { } else if (!this.state.linkTitle) {
this.setState({ this.setState({
linkTitle: decodeURIComponent(linkValue linkTitle: decodeURIComponent(linkValue
.split('/') .split('/')