import { commitLocalUpdate , Environment } from "relay-runtime" ; import { getURLWithCommentID } from "coral-framework/helpers" ; import { CoralContext } from "coral-framework/lib/bootstrap" ; import { createMutation , LOCAL_ID } from "coral-framework/lib/relay" ; interface SetCommentIDInput { id : string | null ; } export async function commit ( environment , input , { pym , window } ) { return commitLocalUpdate ( environment , ( store ) => { const record = store . get ( LOCAL_ID ) ! ; record . setValue ( input . id , "commentID" ) ; record . setValue ( "COMMENTS" , "activeTab" ) ; window . history . replaceState ( window . history . state , window . document . title , getURLWithCommentID ( location . href , input . id || undefined ) ) ; if ( pym ) { pym . sendMessage ( "setCommentID" , input . id || "" ) ; } } ) ; } const SetCommentIDMutation = createMutation ( "setCommentID" , commit ) ; export default SetCommentIDMutation ;