mirror of
https://github.com/wassname/talk.git
synced 2026-07-10 11:17:52 +08:00
Use setAuthToken mutation
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
import { commitLocalUpdate } from "react-relay";
|
||||
|
||||
import { TalkContext } from "talk-framework/lib/bootstrap";
|
||||
import { LOCAL_ID } from "talk-framework/lib/relay";
|
||||
|
||||
import { commit as setAuthToken } from "talk-framework/mutations/SetAuthTokenMutation";
|
||||
|
||||
export default function onPostMessageSetAuthToken({
|
||||
relayEnvironment,
|
||||
postMessage,
|
||||
}: TalkContext) {
|
||||
// Auth popup will use this to handle a successful login.
|
||||
postMessage!.on("setAuthToken", token => {
|
||||
commitLocalUpdate(relayEnvironment, s => {
|
||||
s.get(LOCAL_ID)!.setValue(token, "authToken");
|
||||
});
|
||||
postMessage!.on("setAuthToken", (authToken: string) => {
|
||||
setAuthToken(relayEnvironment, { authToken });
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user