Creating assetURL in localState

This commit is contained in:
Belén Curcio
2018-07-26 11:13:39 -03:00
parent 89472bfe9f
commit db09033367
5 changed files with 15 additions and 24 deletions
@@ -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<InnerProps> {
public render() {
const { commentID, origin, assetID } = this.props;
const { commentID, assetURL } = this.props;
return (
<Popover
placement="top"
body={({ toggleVisibility, forwardRef }) => (
<PermalinkPopover
// TODO (bc) temporary needed to pass the assetID to go back to the correct asset until the backend
// returns the correct asset url
permalinkUrl={`${origin}/?commentID=${commentID}&assetID=${assetID}`}
permalinkUrl={`${assetURL}&commentID=${commentID}`}
forwardRef={forwardRef}
toggleVisibility={toggleVisibility}
/>
@@ -11,20 +11,13 @@ interface InnerProps {
}
export const PermalinkContainer: StatelessComponent<InnerProps> = props => {
return (
<Permalink
{...props}
origin={props.local.origin}
assetID={props.local.assetID}
/>
);
return <Permalink {...props} assetURL={props.local.assetURL} />;
};
const enhanced = withLocalStateContainer<Local>(
graphql`
fragment PermalinkContainerLocal on Local {
assetID
origin
assetURL
}
`
)(PermalinkContainer);
@@ -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");
}
+1 -2
View File
@@ -7,8 +7,7 @@ type Local {
network: Network!
assetID: String
commentID: String
host: String
origin: String
assetURL: String
}
extend type Query {
+1 -1
View File
@@ -78,7 +78,7 @@ const enhanced = withLocalStateContainer<Local>(
fragment AppQueryLocal on Local {
assetID
commentID
origin
assetURL
}
`
)(AppQuery);