mirror of https://github.com/vector-im/riot-web
Merge branch 'develop' of github.com:matrix-org/matrix-react-sdk into develop
commit
3e93930dcc
|
@ -65,11 +65,10 @@ export default React.createClass({
|
||||||
this._scalarClient = new ScalarAuthClient();
|
this._scalarClient = new ScalarAuthClient();
|
||||||
this._scalarClient.getScalarToken().done((token) => {
|
this._scalarClient.getScalarToken().done((token) => {
|
||||||
// Append scalar_token as a query param
|
// Append scalar_token as a query param
|
||||||
let u = url.parse(this.props.url);
|
const u = url.parse(this.props.url);
|
||||||
if (!u.search) {
|
if (!u.search) {
|
||||||
u.search = "?scalar_token=" + encodeURIComponent(token);
|
u.search = "?scalar_token=" + encodeURIComponent(token);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
u.search += "&scalar_token=" + encodeURIComponent(token);
|
u.search += "&scalar_token=" + encodeURIComponent(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,8 +126,7 @@ export default React.createClass({
|
||||||
appTileBody = (
|
appTileBody = (
|
||||||
<div> Loading... </div>
|
<div> Loading... </div>
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
appTileBody = (
|
appTileBody = (
|
||||||
<div className="mx_AppTileBody">
|
<div className="mx_AppTileBody">
|
||||||
<iframe ref="appFrame" src={this.state.widgetUrl} allowFullScreen="true"></iframe>
|
<iframe ref="appFrame" src={this.state.widgetUrl} allowFullScreen="true"></iframe>
|
||||||
|
|
|
@ -143,9 +143,15 @@ module.exports = React.createClass({
|
||||||
if (this.props.showUrlPreview && !this.state.links.length) {
|
if (this.props.showUrlPreview && !this.state.links.length) {
|
||||||
var links = this.findLinks(this.refs.content.children);
|
var links = this.findLinks(this.refs.content.children);
|
||||||
if (links.length) {
|
if (links.length) {
|
||||||
this.setState({ links: links.map((link)=>{
|
// de-dup the links (but preserve ordering)
|
||||||
return link.getAttribute("href");
|
const seen = new Set();
|
||||||
})});
|
links = links.filter((link) => {
|
||||||
|
if (seen.has(link)) return false;
|
||||||
|
seen.add(link);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
this.setState({ links: links });
|
||||||
|
|
||||||
// lazy-load the hidden state of the preview widget from localstorage
|
// lazy-load the hidden state of the preview widget from localstorage
|
||||||
if (global.localStorage) {
|
if (global.localStorage) {
|
||||||
|
@ -158,12 +164,13 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
findLinks: function(nodes) {
|
findLinks: function(nodes) {
|
||||||
var links = [];
|
var links = [];
|
||||||
|
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
var node = nodes[i];
|
var node = nodes[i];
|
||||||
if (node.tagName === "A" && node.getAttribute("href"))
|
if (node.tagName === "A" && node.getAttribute("href"))
|
||||||
{
|
{
|
||||||
if (this.isLinkPreviewable(node)) {
|
if (this.isLinkPreviewable(node)) {
|
||||||
links.push(node);
|
links.push(node.getAttribute("href"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (node.tagName === "PRE" || node.tagName === "CODE" ||
|
else if (node.tagName === "PRE" || node.tagName === "CODE" ||
|
||||||
|
|
Loading…
Reference in New Issue