Creating assetURL in localState

S
This commit is contained in:
Belén Curcio
2018-07-26 11:21:57 -03:00
parent 89472bfe9f
commit ea44227519
6 changed files with 36 additions and 35 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}
/>
@@ -21,22 +21,27 @@ const PermalinkView: StatelessComponent<InnerProps> = props => {
if (props.comment) {
// TODO (bc) temporary needed to pass the assetID to go back to the correct asset until the backend
// returns the correct asset url
const assetURL = `${location.origin}/?assetID=${query.assetID}`;
let assetURL: string = "";
if (query.assetID) {
assetURL = `${location.origin}/?assetID=${query.assetID}`;
}
return (
<div className={styles.root}>
<Logo />
<Flex direction="column" className={styles.comment}>
<CommentContainer data={props.comment} />
<Button
variant="filled"
color="primary"
onClick={() => {
window.location.href = assetURL;
}}
>
Back to the Stream
</Button>
{assetURL && (
<Button
variant="filled"
color="primary"
onClick={() => {
window.location.href = assetURL;
}}
>
Back to the Stream
</Button>
)}
</Flex>
</div>
);