Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

resolve git async issue#37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 1 commit intomasterfromfix/git-async-setup-issue
Sep 28, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletionsrc/actions/tutorialConfig.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,15 +5,17 @@ import * as git from '../services/git'
interfaceTutorialConfigParams{
tutorial:G.Tutorial,
alreadyConfigured?:boolean
onComplete?():void
}

consttutorialConfig=async({tutorial, alreadyConfigured}:TutorialConfigParams)=>{
consttutorialConfig=async({tutorial, alreadyConfigured, onComplete}:TutorialConfigParams)=>{
if(!alreadyConfigured){
// setup git, add remote
awaitgit.initIfNotExists()

// TODO: if remote not already set
awaitgit.setupRemote(tutorial.repo.uri)
if(onComplete){onComplete()}
}

// TODO: allow multiple coding languages in a tutorial
Expand Down
4 changes: 3 additions & 1 deletionsrc/channel/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -74,7 +74,9 @@ class Channel implements Channel {
consttutorialData=action.payload.tutorial
this.context.setTutorial(this.workspaceState,tutorialData)
tutorialConfig({
tutorial:tutorialData
tutorial:tutorialData,
// must await async git setup or commit loading fails
onComplete:()=>this.send({type:'TUTORIAL_CONFIGURED'})
})
return
case'EDITOR_TUTORIAL_CONTINUE_CONFIG':
Expand Down
3 changes: 3 additions & 0 deletionsweb-app/src/services/channel/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,6 +40,9 @@ class Channel {
case'NEW_TUTORIAL':
this.machineSend(action)
return
case'TUTORIAL_CONFIGURED':
this.machineSend(action)
return
case'CONTINUE_TUTORIAL':
this.machineSend(action)
return
Expand Down
31 changes: 23 additions & 8 deletionsweb-app/src/services/state/actions/editor.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,8 @@ import * as G from 'typings/graphql'
import*asCRfrom'typings'
import*asselectorsfrom'../../selectors'
importchannelfrom'../../channel'
importclientfrom'../../apollo'
importtutorialQueryfrom'../../apollo/queries/tutorial'

exportdefault{
loadStoredTutorial(){
Expand All@@ -23,16 +25,29 @@ export default {
},
initializeTutorial(context:CR.MachineContext,event:CR.MachineEvent){
// setup test runner and git
const{tutorial}=event.data.payload

if(!tutorial){
thrownewError('Invalid tutorial for tutorial config')
if(!context.tutorial){
thrownewError('Tutorial not available to load')
}
console.log('EDITOR: TUTORIAL_CONFIG',tutorial)
channel.editorSend({
type:'EDITOR_TUTORIAL_CONFIG',
payload:{tutorial},

client.query({
query:tutorialQuery,
variables:{
tutorialId:context.tutorial.id,
version:context.tutorial.version.version,
}
}).then((result)=>{
if(!result||!result.data||!result.data.tutorial){
returnPromise.reject('No tutorial returned from tutorial config query')
}

channel.editorSend({
type:'EDITOR_TUTORIAL_CONFIG',
payload:{tutorial:result.data.tutorial},
})
})
.catch((error:Error)=>{
returnPromise.reject(`Failed to load tutorial config${error.message}`)
})
},
continueConfig(){
channel.editorSend({
Expand Down
30 changes: 0 additions & 30 deletionsweb-app/src/services/state/actions/invoke.ts
View file
Open in desktop

This file was deleted.

15 changes: 5 additions & 10 deletionsweb-app/src/services/state/machine.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
import{Machine,MachineOptions}from'xstate'
import*asCRfrom'typings'
importactionsfrom'./actions'
import*asinvokefrom'./actions/invoke'

constoptions:MachineOptions<CR.MachineContext,CR.MachineEvent>={
//@ts-ignore
Expand DownExpand Up@@ -65,15 +64,11 @@ export const machine = Machine<CR.MachineContext, CR.MachineStateSchema, CR.Mach
states:{
// TODO: move Initialize into New Tutorial setup
Initialize:{
invoke:{
id:'loadTutorial',
src:invoke.loadTutorial,
onDone:{
target:'Summary',
actions:['initializeTutorial']
},
onError:'Initialize'// TODO: handle load tutorial error
},
onEntry:['initializeTutorial'],
on:{
TUTORIAL_CONFIGURED:'Summary',
// TUTORIAL_CONFIG_ERROR: 'Start' // TODO: should handle error
}
},
LoadNext:{
id:'tutorial-load-next',
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp