Add UserBox

This commit is contained in:
Chi Vinh Le
2018-08-08 01:04:25 +02:00
parent 34fb53b3b0
commit fe7b734b2c
41 changed files with 773 additions and 84 deletions
@@ -0,0 +1,38 @@
import { commitLocalUpdate, Environment } from "relay-runtime";
import { createMutationContainer } from "talk-framework/lib/relay";
import { AUTH_POPUP_ID } from "../local";
export interface SetAuthPopupStateInput {
open?: boolean;
focus?: boolean;
href?: string;
}
export type SetAuthPopupStateMutation = (
input: SetAuthPopupStateInput
) => Promise<void>;
export async function commit(
environment: Environment,
input: SetAuthPopupStateInput
) {
return commitLocalUpdate(environment, store => {
const record = store.get(AUTH_POPUP_ID)!;
if (input.open !== undefined) {
record.setValue(input.open, "open");
}
if (input.focus !== undefined) {
record.setValue(input.focus, "focus");
}
if (input.href !== undefined) {
record.setValue(input.href, "href");
}
});
}
export const withSetAuthPopupStateMutation = createMutationContainer(
"setAuthPopupState",
commit
);