From 97e3d7220e2098f86901a571b4629af8e4e517ad Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Mon, 10 Apr 2017 14:39:50 -0600 Subject: [PATCH] Removed test code --- client/coral-embed-live-stream/src/Embed.js | 115 ------------------ client/coral-embed-live-stream/src/index.js | 16 --- .../coral-embed-live-stream/style/default.css | 0 client/coral-framework/services/client.js | 2 + webpack.config.js | 3 +- 5 files changed, 3 insertions(+), 133 deletions(-) delete mode 100644 client/coral-embed-live-stream/src/Embed.js delete mode 100644 client/coral-embed-live-stream/src/index.js delete mode 100644 client/coral-embed-live-stream/style/default.css diff --git a/client/coral-embed-live-stream/src/Embed.js b/client/coral-embed-live-stream/src/Embed.js deleted file mode 100644 index 6be149007..000000000 --- a/client/coral-embed-live-stream/src/Embed.js +++ /dev/null @@ -1,115 +0,0 @@ -import React from 'react'; - -import {graphql} from 'react-apollo'; -import gql from 'graphql-tag'; - -import PubDate from 'coral-plugin-pubdate/PubDate'; - -class Embed extends React.Component { - - static propTypes = { - assetID: React.PropTypes.string.isRequired, - subscribeToNewComments: React.PropTypes.func.isRequired, - data: React.PropTypes.shape({ - loading: React.PropTypes.bool.isRequired, - asset: React.PropTypes.object, - }).isRequired - } - - componentWillMount() { - const {assetID} = this.props; - this.props.subscribeToNewComments({assetID}); - } - - render() { - const {asset, loading} = this.props.data; - return ( -
-

Wyatt's Awesome Live Stream

-
- {!loading && asset && asset.comments && asset.comments.map((comment) => ( -
- - {comment.user.username} - {comment.body} - - - - -
- ))} -
-
- ); - } -} - -const COMMENT_QUERY = gql` - query Comment($assetID: ID!) { - asset(id: $assetID) { - comments(limit: 50) { - id - body - user { - username - } - created_at - } - } - } -`; - -const COMMENTS_SUBSCRIPTION = gql` - subscription onCommentAdded($assetID: ID!){ - commentAdded(asset_id: $assetID) { - id - body - user { - username - } - created_at - } - } -`; - -const withData = graphql(COMMENT_QUERY, { - options: ({assetID}) => ({ - variables: { - assetID - }, - }), - props: (props) => ({ - ...props, - subscribeToNewComments: ({assetID}) => { - return props.data.subscribeToMore({ - document: COMMENTS_SUBSCRIPTION, - variables: {assetID}, - updateQuery: (before, {subscriptionData}) => { - if (!subscriptionData.data) { - return before; - } - - const newComment = subscriptionData.data.commentAdded; - - if (!newComment) { - console.warn('last comment was null :/'); - return before; - } - - let after = { - ...before, - asset: { - ...before.asset, - comments: [newComment, ...before.asset.comments] - } - }; - - return after; - } - }); - } - }) -}); - -export default withData(Embed); diff --git a/client/coral-embed-live-stream/src/index.js b/client/coral-embed-live-stream/src/index.js deleted file mode 100644 index 564ea0ed6..000000000 --- a/client/coral-embed-live-stream/src/index.js +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; -import {render} from 'react-dom'; -import {ApolloProvider} from 'react-apollo'; - -import {client} from 'coral-framework/services/client'; - -// import store from 'coral-framework/services/store'; - -import Embed from './Embed'; - -render( - - - - , document.querySelector('#coralStream') -); diff --git a/client/coral-embed-live-stream/style/default.css b/client/coral-embed-live-stream/style/default.css deleted file mode 100644 index e69de29bb..000000000 diff --git a/client/coral-framework/services/client.js b/client/coral-framework/services/client.js index 3ad43fee4..4673171b9 100644 --- a/client/coral-framework/services/client.js +++ b/client/coral-framework/services/client.js @@ -2,6 +2,8 @@ import ApolloClient, {addTypename} from 'apollo-client'; import getNetworkInterface from './transport'; import {SubscriptionClient, addGraphQLSubscriptions} from 'subscriptions-transport-ws'; + +// TODO: replace absolute reference with something loaded from the store/page. const wsClient = new SubscriptionClient('ws://localhost:3000/api/v1/live', { reconnect: true }); diff --git a/webpack.config.js b/webpack.config.js index c951c996d..3a54e85c0 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -33,8 +33,7 @@ const buildTargets = [ ]; const buildEmbeds = [ - 'stream', - 'live-stream' + 'stream' ]; module.exports = {