mirror of
https://github.com/wassname/talk.git
synced 2026-09-11 12:51:33 +08:00
Support rest and implement SignIn and SignUp Rest + Mutations
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Environment, RecordSource } from "relay-runtime";
|
||||
|
||||
import { LOCAL_ID } from "talk-framework/lib/relay";
|
||||
import { createInMemoryStorage } from "talk-framework/lib/storage";
|
||||
import { createRelayEnvironment } from "talk-framework/testHelpers";
|
||||
|
||||
import onPostMessageSetAuthToken from "./onPostMessageSetAuthToken";
|
||||
@@ -24,6 +25,7 @@ it("Sets auth token", () => {
|
||||
},
|
||||
},
|
||||
relayEnvironment,
|
||||
localStorage: createInMemoryStorage(),
|
||||
};
|
||||
onPostMessageSetAuthToken(context as any);
|
||||
expect(source.get(LOCAL_ID)!.authToken).toEqual(token);
|
||||
|
||||
@@ -2,12 +2,10 @@ import { TalkContext } from "talk-framework/lib/bootstrap";
|
||||
|
||||
import { commit as setAuthToken } from "talk-framework/mutations/SetAuthTokenMutation";
|
||||
|
||||
export default function onPostMessageSetAuthToken({
|
||||
relayEnvironment,
|
||||
postMessage,
|
||||
}: TalkContext) {
|
||||
export default function onPostMessageSetAuthToken(ctx: TalkContext) {
|
||||
const { relayEnvironment, postMessage } = ctx;
|
||||
// Auth popup will use this to handle a successful login.
|
||||
postMessage!.on("setAuthToken", (authToken: string) => {
|
||||
setAuthToken(relayEnvironment, { authToken });
|
||||
setAuthToken(relayEnvironment, { authToken }, ctx);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ export default async function initLocalState(
|
||||
{ localStorage }: TalkContext
|
||||
) {
|
||||
commitLocalUpdate(environment, s => {
|
||||
// TODO: (cvle) move local, auth token and network initialization to framework.
|
||||
const root = s.getRoot();
|
||||
|
||||
// Create the Local Record which is the Root for the client states.
|
||||
|
||||
Reference in New Issue
Block a user