From db0903336757eb35bf5be72347c793249b6d15bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Curcio?= Date: Thu, 26 Jul 2018 11:13:39 -0300 Subject: [PATCH] Creating assetURL in localState --- .../stream/components/Permalink/Permalink.tsx | 9 +++------ .../stream/containers/PermalinkContainer.tsx | 11 ++--------- src/core/client/stream/local/initLocalState.ts | 14 ++++++++------ src/core/client/stream/local/local.graphql | 3 +-- src/core/client/stream/queries/AppQuery.tsx | 2 +- 5 files changed, 15 insertions(+), 24 deletions(-) diff --git a/src/core/client/stream/components/Permalink/Permalink.tsx b/src/core/client/stream/components/Permalink/Permalink.tsx index eefd8859d..3acfc3d71 100644 --- a/src/core/client/stream/components/Permalink/Permalink.tsx +++ b/src/core/client/stream/components/Permalink/Permalink.tsx @@ -5,21 +5,18 @@ import PermalinkPopover from "./PermalinkPopover"; interface InnerProps { commentID: string; - origin: string | null; - assetID: string | null; + assetURL: string | null; } class Permalink extends React.Component { public render() { - const { commentID, origin, assetID } = this.props; + const { commentID, assetURL } = this.props; return ( ( diff --git a/src/core/client/stream/containers/PermalinkContainer.tsx b/src/core/client/stream/containers/PermalinkContainer.tsx index a203dedcc..ea4630391 100644 --- a/src/core/client/stream/containers/PermalinkContainer.tsx +++ b/src/core/client/stream/containers/PermalinkContainer.tsx @@ -11,20 +11,13 @@ interface InnerProps { } export const PermalinkContainer: StatelessComponent = props => { - return ( - - ); + return ; }; const enhanced = withLocalStateContainer( graphql` fragment PermalinkContainerLocal on Local { - assetID - origin + assetURL } ` )(PermalinkContainer); diff --git a/src/core/client/stream/local/initLocalState.ts b/src/core/client/stream/local/initLocalState.ts index f43b14406..434c60e32 100644 --- a/src/core/client/stream/local/initLocalState.ts +++ b/src/core/client/stream/local/initLocalState.ts @@ -22,16 +22,18 @@ export default async function initLocalState(environment: Environment) { // Parse query params const query = qs.parse(location.search); - // Saving location host for permalink until we get the asset url - the url now points to the tenant - if (location) { - localRecord.setValue(location.host, "host"); - localRecord.setValue(location.origin, "origin"); - } - if (query.assetID) { localRecord.setValue(query.assetID, "assetID"); } + // Saving location host for permalink until we get the asset url - the url now points to the tenant + if (location && query.assetID) { + localRecord.setValue( + `${location.origin}/?assetID=${query.assetID}`, + "assetURL" + ); + } + if (query.commentID) { localRecord.setValue(query.commentID, "commentID"); } diff --git a/src/core/client/stream/local/local.graphql b/src/core/client/stream/local/local.graphql index f7152b2ce..9a2991607 100644 --- a/src/core/client/stream/local/local.graphql +++ b/src/core/client/stream/local/local.graphql @@ -7,8 +7,7 @@ type Local { network: Network! assetID: String commentID: String - host: String - origin: String + assetURL: String } extend type Query { diff --git a/src/core/client/stream/queries/AppQuery.tsx b/src/core/client/stream/queries/AppQuery.tsx index 64a005795..48ac6e5c5 100644 --- a/src/core/client/stream/queries/AppQuery.tsx +++ b/src/core/client/stream/queries/AppQuery.tsx @@ -78,7 +78,7 @@ const enhanced = withLocalStateContainer( fragment AppQueryLocal on Local { assetID commentID - origin + assetURL } ` )(AppQuery);