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

Commitcb9f82e

Browse files
committed
setup continue path
1 parent314e71b commitcb9f82e

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

‎src/editor/commands/index.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import tutorial from '../../state/context/tutorials/basic'
99

1010
constCOMMANDS={
1111
START:'coderoad.start',
12-
NEW_OR_CONTINUE:'coderoad.new_or_continue',
1312
TUTORIAL_LAUNCH:'coderoad.tutorial_launch',
1413
OPEN_WEBVIEW:'coderoad.open_webview',
1514
SEND_STATE:'coderoad.send_state',
@@ -45,23 +44,8 @@ export const createCommands = ({ context, machine, storage, git, position }: Cre
4544
[COMMANDS.OPEN_WEBVIEW]:(column:number=vscode.ViewColumn.One)=>{
4645
webview.createOrShow(column);
4746
},
48-
// launch with continue or new
49-
[COMMANDS.NEW_OR_CONTINUE]:async()=>{
50-
// verify that the user has a tutorial & progress
51-
// verify git is setup with a coderoad remote
52-
const[tutorial,progress,hasGit,hasGitRemote]=awaitPromise.all([
53-
storage.getTutorial(),
54-
storage.getProgress(),
55-
git.gitVersion(),
56-
git.gitCheckRemoteExists(),
57-
])
58-
constcanContinue=!!(tutorial&&progress&&hasGit&&hasGitRemote)
59-
console.log('canContinue',canContinue)
60-
// if a tutorial exists, 'CONTINUE'
61-
// otherwise start from 'NEW'
62-
machine.send(canContinue ?'CONTINUE' :'NEW')
63-
},
6447
// launch a new tutorial
48+
// NOTE: may be better to move into action as logic is primarily non-vscode
6549
[COMMANDS.TUTORIAL_LAUNCH]:async()=>{
6650
console.log('launch tutorial')
6751

‎src/state/actions/index.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import{assign}from'xstate'
2+
// NOTE: codesmell - importing machine
3+
import{machine}from'../../extension'
24
import*asCRfrom'typings'
35
import*asvscodefrom'vscode'
6+
import*asstoragefrom'../../services/storage'
7+
import*asgitfrom'../../services/git'
48

59
letinitialTutorial:CR.Tutorial|undefined
610
letinitialProgress:CR.Progress={
@@ -15,8 +19,23 @@ export default {
1519
console.log('execute coderoad.open_webview')
1620
vscode.commands.executeCommand('coderoad.open_webview')
1721
},
18-
newOrContinue(){
19-
vscode.commands.executeCommand('coderoad.new_or_continue')
22+
asyncnewOrContinue(){
23+
// verify that the user has a tutorial & progress
24+
// verify git is setup with a coderoad remote
25+
const[tutorial,progress,hasGit,hasGitRemote]=awaitPromise.all([
26+
storage.getTutorial(),
27+
storage.getProgress(),
28+
git.gitVersion(),
29+
git.gitCheckRemoteExists(),
30+
])
31+
constcanContinue=!!(tutorial&&progress&&hasGit&&hasGitRemote)
32+
33+
if(canContinue){
34+
initialTutorial=tutorial
35+
initialProgress=progress
36+
}
37+
38+
machine.send(canContinue ?'CONTINUE' :'NEW')
2039
},
2140
tutorialLaunch(){
2241
vscode.commands.executeCommand('coderoad.tutorial_launch')

‎src/state/machine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const machine = Machine<
4949

5050
},
5151
ContinueTutorial:{
52-
onEntry:'tutorialContinue',
52+
onEntry:['tutorialContinue'],
5353
on:{
5454
TUTORIAL_START:{
5555
target:'Tutorial.LoadNext',

‎web-app/src/Routes.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ const Routes = ({ state }: Props) => {
1515
return(
1616
<div>
1717
<Condstate={state}path="SelectTutorial.Startup">
18-
<divstyle={{backgroundColor:'red'}}>
18+
<div>
1919
<h3>Starting...</h3>
2020
</div>
2121
</Cond>
2222
<Condstate={state}path="SelectTutorial.NewTutorial">
2323
<NewPage/>
2424
</Cond>
2525
<Condstate={state}path="SelectTutorial.ContinueTutorial">
26-
<ContinuePage/>
26+
<ContinuePage/>
2727
</Cond>
2828
<Condstate={state}path="Tutorial">
2929
<TutorialPage/>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp