Skip to content

Commit 4044c7f

Browse files
committed
fix bug with continue loading init commits
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent 89c5289 commit 4044c7f

File tree

6 files changed

+34
-24
lines changed

6 files changed

+34
-24
lines changed

src/actions/onStartup.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ const onStartup = async (context: Context): Promise<void> => {
3333
// continue from tutorial from local storage
3434
const tutorial: TT.Tutorial | null = context.tutorial.get()
3535

36-
// no stored tutorial, must start new tutorial
36+
// NEW: no stored tutorial, must start new tutorial
3737
if (!tutorial || !tutorial.id) {
38-
if (TUTORIAL_URL) {
38+
if (!!TUTORIAL_URL) {
3939
// NEW_FROM_URL
4040
try {
4141
const tutorialRes = await fetch(TUTORIAL_URL)
@@ -47,7 +47,7 @@ const onStartup = async (context: Context): Promise<void> => {
4747
console.log(`Failed to load tutorial from url ${TUTORIAL_URL} with error "${e.message}"`)
4848
}
4949
}
50-
// NEW
50+
// NEW from start click
5151
send({ type: 'START_NEW_TUTORIAL', payload: { env } })
5252
return
5353
}

src/actions/onTutorialConfigContinue.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ import * as TT from 'typings/tutorial'
44
import Context from '../services/context/context'
55
import tutorialConfig from './utils/tutorialConfig'
66
import { COMMANDS, send } from '../commands'
7+
import logger from '../services/logger'
78

89
const onTutorialConfigContinue = async (action: T.Action, context: Context): Promise<void> => {
10+
logger('onTutorialConfigContinue', action)
911
try {
10-
const tutorialContinue: TT.Tutorial | null = context.tutorial.get()
11-
if (!tutorialContinue) {
12+
const tutorialToContinue: TT.Tutorial | null = context.tutorial.get()
13+
if (!tutorialToContinue) {
1214
throw new Error('Invalid tutorial to continue')
1315
}
16+
// update the current stepId on startup
17+
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_POSITION, action.payload.position)
1418
await tutorialConfig({
15-
data: tutorialContinue,
19+
data: tutorialToContinue,
1620
alreadyConfigured: true,
1721
})
18-
// update the current stepId on startup
19-
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_POSITION, action.payload.position)
2022
} catch (e) {
2123
const error = {
2224
type: 'UnknownError',

src/actions/utils/tutorialConfig.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const tutorialConfig = async ({ data, alreadyConfigured }: TutorialConfigParams)
5252
}
5353
}
5454

55-
await vscode.commands.executeCommand(COMMANDS.CONFIG_TEST_RUNNER, data)
55+
await vscode.commands.executeCommand(COMMANDS.CONFIG_TEST_RUNNER, { data, alreadyConfigured })
5656

5757
if (!DISABLE_RUN_ON_SAVE) {
5858
// verify if file test should run based on document saved

src/commands.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,18 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
5959
sendToClient = webview.send
6060
}
6161
},
62-
[COMMANDS.CONFIG_TEST_RUNNER]: async (data: TT.Tutorial) => {
63-
const setupActions = data.config.setup
64-
if (setupActions) {
65-
hooks.onInit(setupActions)
62+
[COMMANDS.CONFIG_TEST_RUNNER]: async ({
63+
data,
64+
alreadyConfigured,
65+
}: {
66+
data: TT.Tutorial
67+
alreadyConfigured: boolean
68+
}) => {
69+
if (!alreadyConfigured) {
70+
const setupActions = data.config.setup
71+
if (setupActions) {
72+
hooks.onInit(setupActions)
73+
}
6674
}
6775
testRunner = createTestRunner(data, {
6876
onSuccess: (position: T.Position) => {

src/extension.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import * as vscode from 'vscode'
22
import { createCommands } from './commands'
33
import * as telemetry from './services/telemetry'
44

5-
let onDeactivate = () => {}
5+
let onDeactivate = () => {
6+
/* placeholder for unsubscribing fn */
7+
}
68

79
// activate run on vscode extension initialization
810
export const activate = (vscodeExt: vscode.ExtensionContext): void => {

web-app/src/services/state/actions/context.ts

+8-10
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@ export const setStart = assign({
1515
},
1616
})
1717

18-
export const loadContinuedTutorial = assign((context: T.MachineContext, event: T.MachineEvent): any => {
19-
return {
20-
env: {
21-
...context.env,
22-
...event.payload.env,
23-
},
24-
tutorial: event.payload.tutorial,
25-
position: event.payload.position,
26-
}
27-
})
18+
export const loadContinuedTutorial = assign((context: T.MachineContext, event: T.MachineEvent): any => ({
19+
env: {
20+
...context.env,
21+
...event.payload.env,
22+
},
23+
tutorial: event.payload.tutorial,
24+
position: event.payload.position,
25+
}))
2826

2927
export const initPosition = assign({
3028
position: (context: T.MachineContext, event: T.MachineEvent): any => {

0 commit comments

Comments
 (0)