mirror of
https://github.com/wassname/talk.git
synced 2026-07-03 05:46:15 +08:00
Creating assetURL in localState
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ type Local {
|
||||
network: Network!
|
||||
assetID: String
|
||||
commentID: String
|
||||
host: String
|
||||
origin: String
|
||||
assetURL: String
|
||||
}
|
||||
|
||||
extend type Query {
|
||||
|
||||
@@ -78,7 +78,7 @@ const enhanced = withLocalStateContainer<Local>(
|
||||
fragment AppQueryLocal on Local {
|
||||
assetID
|
||||
commentID
|
||||
origin
|
||||
assetURL
|
||||
}
|
||||
`
|
||||
)(AppQuery);
|
||||
|
||||
Reference in New Issue
Block a user