Moving comment id into query.

This commit is contained in:
David Jay
2017-02-28 12:02:51 -05:00
parent ab16e5bfe7
commit bf23fc2974
4 changed files with 35 additions and 7 deletions
+2 -1
View File
@@ -12,7 +12,7 @@ const {logout, showSignInDialog, requestConfirmEmail} = authActions;
const {addNotification, clearNotification} = notificationActions;
const {fetchAssetSuccess} = assetActions;
import {queryStream} from 'coral-framework/graphql/queries';
import {queryStream, commentQuery} from 'coral-framework/graphql/queries';
import {postComment, postFlag, postLike, postDontAgree, deleteAction} from 'coral-framework/graphql/mutations';
import {editName} from 'coral-framework/actions/user';
import {updateCountCache} from 'coral-framework/actions/asset';
@@ -251,5 +251,6 @@ export default compose(
postLike,
postDontAgree,
deleteAction,
commentQuery,
queryStream
)(Embed);
+11 -6
View File
@@ -58,10 +58,11 @@
// ensure el has an id, as pym can't directly accept the HTMLElement
if ( ! el.id) {el.id = '_' + String(Math.random());}
var asset = opts.asset || window.location;
var asset = opts.asset || window.location.href.split('#')[0];
var comment = window.location.hash.slice(1);
var pymParent = new pym.Parent(
el.id,
buildStreamIframeUrl(opts.talk, asset),
buildStreamIframeUrl(opts.talk, asset, comment),
{
title: opts.title,
asset_url: asset,
@@ -76,14 +77,18 @@
return Coral;
// build the URL to load in the pym iframe
function buildStreamIframeUrl(talkBaseUrl, asset) {
var iframeUrl = [
function buildStreamIframeUrl(talkBaseUrl, asset, comment) {
var iframeArray = [
talkBaseUrl,
(talkBaseUrl.match(/\/$/) ? '' : '/'), // make sure no double-'/' if opts.talk already ends with '/'
'embed/stream?asset_url=',
encodeURIComponent(asset)
].join('');
return iframeUrl;
];
if (comment) {
iframeArray.push(`&comment_id=${comment}`);
}
return iframeArray.join('');
}
// Set up postMessage listeners/handlers on the pymParent
@@ -0,0 +1,13 @@
#import "../fragments/commentView.graphql"
query commentQuery($id: ID!) {
comment(id: $id) {
...commentView
parent {
...commentView
replies {
...commentView
}
}
}
}
@@ -2,6 +2,7 @@ import {graphql} from 'react-apollo';
import STREAM_QUERY from './streamQuery.graphql';
import LOAD_MORE from './loadMore.graphql';
import GET_COUNTS from './getCounts.graphql';
import COMMENT_QUERY from './commentQuery.graphql';
import MY_COMMENT_HISTORY from './myCommentHistory.graphql';
function getQueryVariable(variable) {
@@ -97,4 +98,12 @@ export const queryStream = graphql(STREAM_QUERY, {
})
});
export const commentQuery = graphql(COMMENT_QUERY, {
options: () => ({
variables: {
id: getQueryVariable('comment_id')
}
})
});
export const myCommentHistory = graphql(MY_COMMENT_HISTORY, {});