Fixing permalinks and moving Pym to a seperate file.

This commit is contained in:
David Jay
2017-01-24 12:51:52 -05:00
parent 75bcf29154
commit 58e50b4242
3 changed files with 25 additions and 22 deletions
+20 -19
View File
@@ -1,6 +1,6 @@
import React, {Component, PropTypes} from 'react';
// import Pym from 'pym.js';
import pym from './Pym';
import {compose} from 'react-apollo';
import {connect} from 'react-redux';
@@ -71,24 +71,25 @@ class Embed extends Component {
// this.props.getStream(path || window.location);
// this.path = window.location.href.split('#')[0];
//
// this.pym.sendMessage('childReady');
//
// this.pym.onMessage('DOMContentLoaded', hash => {
// const commentId = hash.replace('#', 'c_');
// let count = 0;
// const interval = setInterval(() => {
// if (document.getElementById(commentId)) {
// window.clearInterval(interval);
// this.pym.scrollParentToChildEl(commentId);
// }
//
// if (++count > 100) { // ~10 seconds
// // give up waiting for the comments to load.
// // it would be weird for the page to jump after that long.
// window.clearInterval(interval);
// }
// }, 100);
// });
pym.sendMessage('childReady');
pym.onMessage('DOMContentLoaded', hash => {
const commentId = hash.replace('#', 'c_');
let count = 0;
const interval = setInterval(() => {
if (document.getElementById(commentId)) {
window.clearInterval(interval);
pym.scrollParentToChildEl(commentId);
}
if (++count > 100) { // ~10 seconds
// give up waiting for the comments to load.
// it would be weird for the page to jump after that long.
window.clearInterval(interval);
}
}, 100);
});
}
+3
View File
@@ -0,0 +1,3 @@
import Pym from 'pym.js';
export default new Pym.Child({polling: 100});
@@ -1,9 +1,8 @@
import {graphql} from 'react-apollo';
import STREAM_QUERY from './streamQuery.graphql';
import Pym from 'pym.js';
import pym from '../../Pym';
const pym = new Pym.Child({polling: 100});
let url = pym.parentUrl || 'http://localhost:3000/';
let url = pym.parentUrl.split('#')[0] || 'http://localhost:3000/';
export const queryStream = graphql(STREAM_QUERY, {
options: {variables: {asset_url: url}}