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

merge env_get and load_tutorial steps#253

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/simplify-states
Apr 12, 2020
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
28 changes: 12 additions & 16 deletionssrc/channel/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,7 +48,7 @@ class Channel implements Channel {
// console.log(`ACTION: ${actionType}`)

switch (actionType) {
case 'EDITOR_ENV_GET':
case 'EDITOR_STARTUP':
// check if a workspace is open, otherwise nothing works
const noActiveWorksapce = !environment.WORKSPACE_ROOT.length
if (noActiveWorksapce) {
Expand All@@ -65,23 +65,18 @@ class Channel implements Channel {
this.send({ type: 'NO_WORKSPACE', payload: { error } })
return
}
this.send({
type: 'ENV_LOAD',
payload: {
env: {
machineId: vscode.env.machineId,
sessionId: vscode.env.sessionId,
},
},
})
return
// continue from tutorial from local storage
case 'EDITOR_TUTORIAL_LOAD':

const env = {
machineId: vscode.env.machineId,
sessionId: vscode.env.sessionId,
}

// continue from tutorial from local storage
const tutorial: TT.Tutorial | null = this.context.tutorial.get()

// new tutorial
if (!tutorial || !tutorial.id) {
this.send({ type: 'START_NEW_TUTORIAL' })
this.send({ type: 'START_NEW_TUTORIAL', payload: { env } })
return
}

Expand All@@ -90,13 +85,14 @@ class Channel implements Channel {

if (progress.complete) {
// tutorial is already complete
this.send({ type: 'START_NEW_TUTORIAL' })
this.send({ type: 'TUTORIAL_ALREADY_COMPLETE', payload: { env } })
return
}
// communicate to client the tutorial & stepProgress state
this.send({ type: 'LOAD_STORED_TUTORIAL', payload: { tutorial, progress, position } })
this.send({ type: 'LOAD_STORED_TUTORIAL', payload: {env,tutorial, progress, position } })

return

// clear tutorial local storage
case 'TUTORIAL_CLEAR':
// clear current progress/position/tutorial
Expand Down
1 change: 0 additions & 1 deletiontypings/index.d.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,7 +65,6 @@ export interface MachineStateSchema {
Setup: {
states: {
Startup: {}
LoadStoredTutorial: {}
Start: {}
ValidateSetup: {}
SelectTutorial: {}
Expand Down
2 changes: 1 addition & 1 deletionweb-app/src/Routes.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ const Routes = () => {
<Workspace>
<Router>
{/* Setup */}
<Route path={['Setup.Startup', 'Setup.LoadStoredTutorial', 'Setup.ValidateSetup']}>
<Route path={['Setup.Startup', 'Setup.ValidateSetup']}>
<LoadingPage text="Launching..." />
</Route>
<Route path="Setup.Start">
Expand Down
8 changes: 7 additions & 1 deletionweb-app/src/services/state/actions/context.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@ import onError from '../../../services/sentry/onError'

const contextActions: ActionFunctionMap<T.MachineContext, T.MachineEvent> = {
// @ts-ignore
setEnv: assign({
setStart: assign({
env: (context: T.MachineContext, event: T.MachineEvent) => {
return {
...context.env,
Expand All@@ -16,6 +16,12 @@ const contextActions: ActionFunctionMap<T.MachineContext, T.MachineEvent> = {
}),
// @ts-ignore
storeContinuedTutorial: assign({
env: (context: T.MachineContext, event: T.MachineEvent) => {
return {
...context.env,
...event.payload.env,
}
},
tutorial: (context: T.MachineContext, event: T.MachineEvent) => {
return event.payload.tutorial
},
Expand Down
11 changes: 2 additions & 9 deletionsweb-app/src/services/state/actions/editor.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,16 +3,9 @@ import * as TT from 'typings/tutorial'
import * as selectors from '../../selectors'

export default (editorSend: any) => ({
loadEnv(): void {
startup(): void {
editorSend({
type: 'EDITOR_ENV_GET',
})
},
loadStoredTutorial(): void {
// send message to editor to see if there is existing tutorial progress
// in local storage on the editor
editorSend({
type: 'EDITOR_TUTORIAL_LOAD',
type: 'EDITOR_STARTUP',
})
},
configureNewTutorial(context: CR.MachineContext) {
Expand Down
37 changes: 18 additions & 19 deletionsweb-app/src/services/state/machine.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,37 +34,27 @@ export const createMachine = (options: any) => {
initial:'Startup',
states:{
Startup:{
onEntry:['loadEnv'],
onEntry:['startup'],
onExit:['clearError'],
on:{
ENV_LOAD:{
target:'LoadStoredTutorial',
actions:['setEnv'],
},
NO_WORKSPACE:{
actions:['setError'],
},
REQUEST_WORKSPACE:{
actions:'requestWorkspaceSelect',
},
},
},
LoadStoredTutorial:{
onEntry:['loadStoredTutorial'],
on:{
LOAD_STORED_TUTORIAL:{
target:'Start',
actions:['storeContinuedTutorial'],
},
START_NEW_TUTORIAL:'Start',
},
},
Start:{
on:{
NEW_TUTORIAL:'ValidateSetup',
CONTINUE_TUTORIAL:{
target:'#tutorial-level',
actions:['continueConfig'],
START_NEW_TUTORIAL:{
target:'Start',
actions:['setStart'],
},
// TODO: handle completed tutorial differently
TUTORIAL_ALREADY_COMPLETE:{
target:'Start',
actions:['setStart'],
},
},
},
Expand All@@ -83,6 +73,15 @@ export const createMachine = (options: any) => {
SETUP_VALIDATED:'SelectTutorial',
},
},
Start:{
on:{
NEW_TUTORIAL:'ValidateSetup',
CONTINUE_TUTORIAL:{
target:'#tutorial-level',
actions:['continueConfig'],
},
},
},
SelectTutorial:{
onEntry:['clearStorage'],
id:'select-new-tutorial',
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp