Merge pull request #1678 from mattermost/plt-1402

PLT-1402 Fix OEmbeds when switching channel, vine/soundcloud heights, and yout…
This commit is contained in:
Corey Hulen
2015-12-09 09:52:13 -08:00
4 changed files with 15 additions and 8 deletions

View File

@@ -14,7 +14,14 @@ export default class PostAttachmentOEmbed extends React.Component {
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
this.fetchData(nextProps.link); if (nextProps.link !== this.props.link) {
this.isLoading = false;
this.fetchData(nextProps.link);
}
}
componentDidMount() {
this.fetchData(this.props.link);
} }
fetchData(link) { fetchData(link) {

View File

@@ -214,14 +214,14 @@ export default class PostBody extends React.Component {
} }
createYoutubeEmbed(link) { createYoutubeEmbed(link) {
const ytRegex = /.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|watch\?(?:[a-zA-Z-_]+=[a-zA-Z0-9-_]+&)+v=)([^#\&\?]*).*/; const ytRegex = /(?:http|https):\/\/(?:www\.)?(?:(?:youtube\.com\/(?:(?:v\/)|(\/u\/\w\/)|(?:(?:watch|embed\/watch)(?:\/|.*v=))|(?:embed\/)|(?:user\/[^\/]+\/u\/[0-9]\/)))|(?:youtu\.be\/))([^#\&\?]*)/;
const match = link.trim().match(ytRegex); const match = link.trim().match(ytRegex);
if (!match || match[1].length !== 11) { if (!match || match[2].length !== 11) {
return null; return null;
} }
const youtubeId = match[1]; const youtubeId = match[2];
const time = this.handleYoutubeTime(link); const time = this.handleYoutubeTime(link);
function onClick(e) { function onClick(e) {

View File

@@ -11,7 +11,7 @@
"https?://soundcloud.com/.*/.*" "https?://soundcloud.com/.*/.*"
], ],
"name": "SoundCloud", "name": "SoundCloud",
"height": 110 "height": 140
}, },
{ {
"patterns": [ "patterns": [
@@ -349,7 +349,7 @@
"https?://vine.co/v/[a-zA-Z0-9]+" "https?://vine.co/v/[a-zA-Z0-9]+"
], ],
"name": "Vine", "name": "Vine",
"height": 110 "height": 490
}, },
{ {
"patterns": [ "patterns": [

View File

@@ -300,7 +300,7 @@ export function extractLinks(text) {
Autolinker.link(text, { Autolinker.link(text, {
replaceFn, replaceFn,
urls: true, urls: {schemeMatches: true, wwwMatches: true, tldMatches: false},
emails: false, emails: false,
twitter: false, twitter: false,
phone: false, phone: false,
@@ -1253,4 +1253,4 @@ export function isFeatureEnabled(feature) {
export function isSystemMessage(post) { export function isSystemMessage(post) {
return post.type && (post.type.lastIndexOf(Constants.SYSTEM_MESSAGE_PREFIX) === 0); return post.type && (post.type.lastIndexOf(Constants.SYSTEM_MESSAGE_PREFIX) === 0);
} }