File tree Expand file tree Collapse file tree 2 files changed +6
-27
lines changed Expand file tree Collapse file tree 2 files changed +6
-27
lines changed Original file line number Diff line number Diff line change @@ -38,39 +38,17 @@ class Channel {
3838 // messages from core
3939 switch ( action . type ) {
4040 case 'ENV_LOAD' :
41- this . machineSend ( action )
42- return
41+ case 'AUTHENTICATED' :
4342 case 'TUTORIAL_LOADED' :
44- // send action to state machine
45- this . machineSend ( 'TUTORIAL_LOADED' )
46- console . log ( 'send action to state machine' )
47- return
4843 case 'NEW_TUTORIAL' :
49- this . machineSend ( action )
50- return
5144 case 'TUTORIAL_CONFIGURED' :
52- this . machineSend ( action )
53- return
5445 case 'CONTINUE_TUTORIAL' :
55- this . machineSend ( action )
56- return
5746 case 'TEST_PASS' :
58- // { type: 'TEST_PASS', payload: { stepId: string }}
59- this . machineSend ( action )
60- return
6147 case 'TEST_FAIL' :
62- this . machineSend ( action )
63- return
6448 case 'TEST_RUNNING' :
65- this . machineSend ( action )
66- return
6749 case 'TEST_ERROR' :
68- console . log ( 'TEST_ERROR' )
6950 this . machineSend ( action )
7051 return
71- case 'ACTIONS_LOADED' :
72- // TODO: use this for verifying completion of stepActions
73- return
7452 default :
7553 if ( action . type ) {
7654 console . warn ( `Unknown received action ${ action . type } ` , action )
Original file line number Diff line number Diff line change @@ -2,10 +2,10 @@ import * as CR from 'typings'
22import client from '../../apollo'
33import authenticateMutation from '../../apollo/mutations/authenticate'
44import { setAuthToken } from '../../apollo/auth'
5- import { send } from 'xstate '
5+ import channel from '../../../services/channel '
66
77export default {
8- authenticate : ( async ( context : CR . MachineContext ) : Promise < CR . Action > => {
8+ authenticate : ( async ( context : CR . MachineContext ) : Promise < void > => {
99 const result = await client . mutate ( {
1010 mutation : authenticateMutation ,
1111 variables : {
@@ -20,9 +20,10 @@ export default {
2020 console . log ( 'unauthenticated' )
2121 }
2222 const { token} = result . data . editorLogin
23- console . log ( token )
23+ // add token to headers
2424 setAuthToken ( token )
25- return send ( { type : 'AUTHENTICATED' } )
25+ // pass authenticated action back to state machine
26+ channel . receive ( { data : { type : 'AUTHENTICATED' } } )
2627 } ) ,
2728 userTutorialComplete ( context : CR . MachineContext ) {
2829 console . log ( 'should update user tutorial as complete' )
You can’t perform that action at this time.
0 commit comments