mirror of
https://github.com/wassname/talk.git
synced 2026-09-09 11:38:08 +08:00
Adding the mutation
This commit is contained in:
@@ -1,42 +1,62 @@
|
||||
import React, { StatelessComponent } from "react";
|
||||
import React from "react";
|
||||
import { graphql } from "react-relay";
|
||||
import { withFragmentContainer } from "talk-framework/lib/relay";
|
||||
import { withLocalStateContainer } from "talk-framework/lib/relay";
|
||||
import { PropTypesOf } from "talk-framework/types";
|
||||
import {
|
||||
withFragmentContainer,
|
||||
withLocalStateContainer,
|
||||
} from "talk-framework/lib/relay";
|
||||
import { AppQueryLocal as Local } from "talk-stream/__generated__/AppQueryLocal.graphql";
|
||||
import { PermalinkViewContainerQuery as Data } from "talk-stream/__generated__/PermalinkViewContainerQuery.graphql";
|
||||
import {
|
||||
SetCommentIDMutation,
|
||||
withSetCommentIDMutation,
|
||||
} from "talk-stream/mutations";
|
||||
import PermalinkView from "../components/Permalink/PermalinkView";
|
||||
|
||||
interface InnerProps {
|
||||
interface PermalinkViewContainerProps {
|
||||
data: Data;
|
||||
local: Local;
|
||||
setCommentID: SetCommentIDMutation;
|
||||
}
|
||||
|
||||
export const PermalinkViewContainer: StatelessComponent<InnerProps> = ({
|
||||
local,
|
||||
data,
|
||||
}) => {
|
||||
return <PermalinkView {...data} assetURL={local.assetURL} />;
|
||||
};
|
||||
class PermalinkViewContainer extends React.Component<
|
||||
PermalinkViewContainerProps
|
||||
> {
|
||||
private showAllComments = () => {
|
||||
const { local } = this.props;
|
||||
window.location.href = local.assetURL!;
|
||||
// mutation
|
||||
};
|
||||
public render() {
|
||||
const { data, local } = this.props;
|
||||
return (
|
||||
<PermalinkView
|
||||
{...data}
|
||||
assetURL={local.assetURL}
|
||||
onShowAllComments={this.showAllComments}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const enhanced = withFragmentContainer<{ data: Data }>({
|
||||
data: graphql`
|
||||
fragment PermalinkViewContainerQuery on Query
|
||||
@argumentDefinitions(commentID: { type: "ID!" }) {
|
||||
comment(id: $commentID) {
|
||||
...CommentContainer
|
||||
const enhanced = withSetCommentIDMutation(
|
||||
withFragmentContainer<{ data: Data }>({
|
||||
data: graphql`
|
||||
fragment PermalinkViewContainerQuery on Query
|
||||
@argumentDefinitions(commentID: { type: "ID!" }) {
|
||||
comment(id: $commentID) {
|
||||
...CommentContainer
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
})(
|
||||
withLocalStateContainer<Local>(
|
||||
graphql`
|
||||
fragment PermalinkViewContainerLocal on Local {
|
||||
assetURL
|
||||
}
|
||||
`
|
||||
)(PermalinkViewContainer)
|
||||
`,
|
||||
})(
|
||||
withLocalStateContainer<Local>(
|
||||
graphql`
|
||||
fragment PermalinkViewContainerLocal on Local {
|
||||
assetURL
|
||||
}
|
||||
`
|
||||
)(PermalinkViewContainer)
|
||||
)
|
||||
);
|
||||
|
||||
export type PermalinkViewContainerProps = PropTypesOf<typeof enhanced>;
|
||||
export default enhanced;
|
||||
|
||||
Reference in New Issue
Block a user