fix embedly
This commit is contained in:
parent
4eab4cefe8
commit
9f29a24321
1 changed files with 38 additions and 29 deletions
|
@ -61,7 +61,7 @@ class Attachments extends Component {
|
|||
loadLink = () => {
|
||||
this.setState({embedlyLinkStarted: true})
|
||||
var e = embedly('card', document.getElementById('embedlyLink'))
|
||||
if (e.type === 'error') this.setState({embedlyLinkError: true})
|
||||
if (e && e.type === 'error') this.setState({embedlyLinkError: true})
|
||||
}
|
||||
|
||||
removeLink = () => {
|
||||
|
@ -76,24 +76,21 @@ class Attachments extends Component {
|
|||
render = () => {
|
||||
const { topic, ActiveMapper } = this.props
|
||||
const { linkEdit, embedlyLinkLoaded, embedlyLinkStarted, embedlyLinkError } = this.state
|
||||
var authorizedToEdit = topic.authorizeToEdit(ActiveMapper)
|
||||
|
||||
const authorizedToEdit = topic.authorizeToEdit(ActiveMapper)
|
||||
const hasAttachment = topic.get('link') && topic.get('link') !== ''
|
||||
|
||||
if (hasAttachment) {
|
||||
if (!hasAttachment && !authorizedToEdit) return null
|
||||
|
||||
const className = hasAttachment
|
||||
? `embeds ${embedlyLinkLoaded ? '' : 'nonEmbedlyLink'}`
|
||||
: 'attachments'
|
||||
|
||||
return (
|
||||
<div className={`embeds ${embedlyLinkLoaded ? '' : 'nonEmbedlyLink'}`}>
|
||||
<a href={topic.get('link')} id="embedlyLink" target="_blank" data-card-description="0">
|
||||
{topic.get('link')}
|
||||
</a>
|
||||
{embedlyLinkStarted && !embedlyLinkLoaded && !embedlyLinkError && <div id="embedlyLinkLoader">loading...</div>}
|
||||
{authorizedToEdit && <div id="linkremove" onClick={this.removeLink}></div>}
|
||||
</div>
|
||||
)
|
||||
} else if (authorizedToEdit) {
|
||||
return (
|
||||
<div className="attachments">
|
||||
<div className="addLink">
|
||||
<div className={className}>
|
||||
<div className="addLink"
|
||||
style={{ display: hasAttachment ? 'none' : 'block' }}
|
||||
>
|
||||
<div id="addLinkIcon"></div>
|
||||
<div id="addLinkInput">
|
||||
<input ref={input => this.linkInput = input}
|
||||
|
@ -104,11 +101,23 @@ class Attachments extends Component {
|
|||
{linkEdit && <div id="addLinkReset"></div>}
|
||||
</div>
|
||||
</div>
|
||||
<a style={{ display: hasAttachment ? 'block' : 'none' }}
|
||||
href={topic.get('link')}
|
||||
id="embedlyLink"
|
||||
target="_blank"
|
||||
data-card-description="0"
|
||||
>
|
||||
{topic.get('link')}
|
||||
</a>
|
||||
{embedlyLinkStarted && !embedlyLinkLoaded && !embedlyLinkError && <div id="embedlyLinkLoader">loading...</div>}
|
||||
{authorizedToEdit && (
|
||||
<div id="linkremove"
|
||||
style={{ display: hasAttachment ? 'block' : 'none' }}
|
||||
onClick={this.removeLink}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue