Skip to content

Commit 5980ef4

Browse files
committed
Rename contents of xService
1 parent ae19e37 commit 5980ef4

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

site/src/xServices/StateContext.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { useInterpret } from "@xstate/react"
22
import React, { createContext } from "react"
33
import { ActorRefFrom } from "xstate"
4-
import { userMachine } from "./auth/authXService"
4+
import { authMachine } from "./auth/authXService"
55
import { buildInfoMachine } from "./buildInfo/buildInfoXService"
66

77
interface XServiceContextType {
88
buildInfoXService: ActorRefFrom<typeof buildInfoMachine>
9-
authXService: ActorRefFrom<typeof userMachine>
9+
authXService: ActorRefFrom<typeof authMachine>
1010
}
1111

1212
/**
@@ -24,7 +24,7 @@ export const XServiceProvider: React.FC = ({ children }) => {
2424
<XServiceContext.Provider
2525
value={{
2626
buildInfoXService: useInterpret(buildInfoMachine),
27-
authXService: useInterpret(userMachine),
27+
authXService: useInterpret(authMachine),
2828
}}
2929
>
3030
{children}

site/src/xServices/auth/authXService.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ import { assign, createMachine } from "xstate"
22
import * as API from "../../api"
33
import * as Types from "../../api/types"
44

5-
export interface UserContext {
5+
export interface AuthContext {
66
getUserError?: Error | unknown
77
authError?: Error | unknown
88
me?: Types.UserResponse
99
}
1010

11-
export type UserEvent = { type: "SIGN_OUT" } | { type: "SIGN_IN"; email: string; password: string }
11+
export type AuthEvent = { type: "SIGN_OUT" } | { type: "SIGN_IN"; email: string; password: string }
1212

13-
export const userMachine =
13+
export const authMachine =
1414
/** @xstate-layout N4IgpgJg5mDOIC5QFdZgE4GUAuBDbYAdLAJZQB2kA8stgMSYCSA4gHID6jrioADgPalsJfuR4gAHogDM0gJyEATAHYAbNIAscxdunKArKo0AaEAE9EG+YX0BGABz3FD6atsbbc5QF9vp1Bg4+ESkFCTkUIzkdBCiROEAbvwA1iFk5FHiAkIiYkiSiHIADITSOvbSRRqq2m7StqYWCIr2+ja2tvVV+vqaRVW+-mhYeATE6eGR0Rjo-OiEvAA2+ABmcwC24xSZ+dkkwqLiUghlyoRF+opayq4X+sqK+o2Il6qEcq5y+hrfjt+qgxAARGwUIMGwwgiAFVhjE4oREikiOCALJgLKCfa5I4yIyEZTFZQaezFK5lPTPBC2IqKUqKC4EjqqKrFOSA4FBMbgyFQGEYOgzOYLZbYNboTao9G7TEHPKgY7SewlTQ3dRyVQ6GpVSmKMqEIz2ZRKjrKIqqJzs4actIUSBRBgsDhUKEAFQxOUO+WOhvshA0ahualsqnu8kpthUhGplVUIa+rUq9ktgVGNvIkxo9FilAR5CSqS25Ez7qxnvliCMGlK1Tk6vN5p+T3ML0Ub2U7iKXmcGg8tmTILGoXTEUzAvQs3mS1WG0LxelHrlBQQIbasc7aiKtnbV3sOpaUZXBjkwd1A0B5H4EDg4g5qcL1FoJdlOIQdlpH2qhmJzJ+DWbCB7WxSmUIl2wJM0CSTPwgStO8h0mHY+BlbEvReICaSMbQflkU0fkpHtfS3MC3C+aR9ENfR+2tMEwAhSY+XQJ8UPLACziVS5TXKAxPDI8MaSjIojSqPQezNRUqLg9I7UXPZn1Q5dqn1CMNEEi4HAecNIyVGoIweVQDH0tloNvUF4JHR951LRdvQcc4PCcAx12-fDOnOeRTU7C4SXsPtjNg4ImLLJddUIdiVBpOQKJ4psmh0ASQOPRUiI8RRfF8IA */
1515
createMachine(
1616
{
1717
tsTypes: {} as import("./authXService.typegen").Typegen0,
1818
schema: {
19-
context: {} as UserContext,
20-
events: {} as UserEvent,
19+
context: {} as AuthContext,
20+
events: {} as AuthEvent,
2121
services: {} as {
2222
getMe: {
2323
data: Types.UserResponse
@@ -32,13 +32,13 @@ export const userMachine =
3232
getUserError: undefined,
3333
authError: undefined,
3434
},
35-
id: "userState",
35+
id: "authState",
3636
initial: "gettingUser",
3737
states: {
3838
signedOut: {
3939
on: {
4040
SIGN_IN: {
41-
target: "#userState.signingIn",
41+
target: "#authState.signingIn",
4242
},
4343
},
4444
},
@@ -48,14 +48,14 @@ export const userMachine =
4848
id: "signIn",
4949
onDone: [
5050
{
51-
target: "#userState.gettingUser",
51+
target: "#authState.gettingUser",
5252
actions: "clearAuthError",
5353
},
5454
],
5555
onError: [
5656
{
5757
actions: "assignAuthError",
58-
target: "#userState.signedOut",
58+
target: "#authState.signedOut",
5959
},
6060
],
6161
},
@@ -68,13 +68,13 @@ export const userMachine =
6868
onDone: [
6969
{
7070
actions: ["assignMe", "clearGetUserError"],
71-
target: "#userState.signedIn",
71+
target: "#authState.signedIn",
7272
},
7373
],
7474
onError: [
7575
{
7676
actions: "assignGetUserError",
77-
target: "#userState.signedOut",
77+
target: "#authState.signedOut",
7878
},
7979
],
8080
},
@@ -83,7 +83,7 @@ export const userMachine =
8383
signedIn: {
8484
on: {
8585
SIGN_OUT: {
86-
target: "#userState.signingOut",
86+
target: "#authState.signingOut",
8787
},
8888
},
8989
},
@@ -94,13 +94,13 @@ export const userMachine =
9494
onDone: [
9595
{
9696
actions: ["unassignMe", "clearAuthError"],
97-
target: "#userState.signedOut",
97+
target: "#authState.signedOut",
9898
},
9999
],
100100
onError: [
101101
{
102102
actions: "assignAuthError",
103-
target: "#userState.signedIn",
103+
target: "#authState.signedIn",
104104
},
105105
],
106106
},
@@ -120,21 +120,21 @@ export const userMachine =
120120
assignMe: assign({
121121
me: (_, event) => event.data,
122122
}),
123-
unassignMe: assign((context: UserContext) => ({
123+
unassignMe: assign((context: AuthContext) => ({
124124
...context,
125125
me: undefined,
126126
})),
127127
assignGetUserError: assign({
128128
getUserError: (_, event) => event.data,
129129
}),
130-
clearGetUserError: assign((context: UserContext) => ({
130+
clearGetUserError: assign((context: AuthContext) => ({
131131
...context,
132132
getUserError: undefined,
133133
})),
134134
assignAuthError: assign({
135135
authError: (_, event) => event.data,
136136
}),
137-
clearAuthError: assign((context: UserContext) => ({
137+
clearAuthError: assign((context: AuthContext) => ({
138138
...context,
139139
authError: undefined,
140140
})),

0 commit comments

Comments
 (0)