summaryrefslogtreecommitdiffstats
path: root/web/react/components/post_body.jsx
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-12-04 12:28:46 -0500
committerJoramWilander <jwawilander@gmail.com>2015-12-04 12:28:46 -0500
commit975074b2ae2692f596edb263bb27727b43f33489 (patch)
tree3ed8a698464cd87da20da04201fa0698ad4789d0 /web/react/components/post_body.jsx
parent622fbc67402fe36bc01163a5a80643a15758e094 (diff)
downloadchat-975074b2ae2692f596edb263bb27727b43f33489.tar.gz
chat-975074b2ae2692f596edb263bb27727b43f33489.tar.bz2
chat-975074b2ae2692f596edb263bb27727b43f33489.zip
Fix embeds and add default fixed height
Diffstat (limited to 'web/react/components/post_body.jsx')
-rw-r--r--web/react/components/post_body.jsx12
1 files changed, 7 insertions, 5 deletions
diff --git a/web/react/components/post_body.jsx b/web/react/components/post_body.jsx
index 27f7ad2de..3e335b901 100644
--- a/web/react/components/post_body.jsx
+++ b/web/react/components/post_body.jsx
@@ -109,10 +109,11 @@ export default class PostBody extends React.Component {
const trimmedLink = link.trim();
- if (this.checkForOembedContent(trimmedLink)) {
+ const provider = this.getOembedProvider(trimmedLink);
+ if (provider != null) {
post.props.oEmbedLink = trimmedLink;
post.type = 'oEmbed';
- this.setState({post});
+ this.setState({post, provider});
return '';
}
@@ -133,15 +134,15 @@ export default class PostBody extends React.Component {
return null;
}
- checkForOembedContent(link) {
+ getOembedProvider(link) {
for (let i = 0; i < providers.length; i++) {
for (let j = 0; j < providers[i].patterns.length; j++) {
if (link.match(providers[i].patterns[j])) {
- return true;
+ return providers[i];
}
}
}
- return false;
+ return null;
}
loadImg(src) {
@@ -399,6 +400,7 @@ export default class PostBody extends React.Component {
</div>
<PostBodyAdditionalContent
post={this.state.post}
+ provider={this.state.provider}
/>
{fileAttachmentHolder}
{this.embed}