Integrate with embed

This commit is contained in:
Chi Vinh Le
2018-08-03 18:19:37 +02:00
parent 09cc76a973
commit b3fa5e1e73
14 changed files with 74 additions and 108 deletions
@@ -1,4 +1,6 @@
import { commitLocalUpdate, Environment } from "relay-runtime";
import { TalkContext } from "talk-framework/lib/bootstrap";
import { createMutationContainer } from "talk-framework/lib/relay";
import { LOCAL_ID } from "talk-framework/lib/relay/withLocalStateContainer";
@@ -8,10 +10,18 @@ export interface SetCommentIDInput {
export type SetCommentIDMutation = (input: SetCommentIDInput) => Promise<void>;
async function commit(environment: Environment, input: SetCommentIDInput) {
async function commit(
environment: Environment,
input: SetCommentIDInput,
{ pym }: TalkContext
) {
return commitLocalUpdate(environment, store => {
const record = store.get(LOCAL_ID)!;
record.setValue(input.id, "commentID");
if (pym) {
// This sets the comment id on the parent url.
pym.sendMessage("setCommentID", input.id || "");
}
});
}