|
1 | | -import * as CR from 'typings' |
2 | | -import * as vscode from 'vscode' |
3 | | -import * as storage from './storage' |
4 | | - |
5 | | -export async function onSuccess(position: CR.Position) { |
6 | | - console.log('onSuccess', position) |
7 | | - vscode.window.showInformationMessage('SUCCESS') |
8 | | - |
9 | | - // calculate progress changes |
10 | | - const [progress, tutorial] = await Promise.all([storage.getProgress(), storage.getTutorial()]) |
11 | | - |
12 | | - if (!tutorial) { |
13 | | - throw new Error('No tutorial found') |
14 | | - } |
15 | | - |
16 | | - if (!position.stepId) { |
17 | | - throw new Error('No step position found') |
18 | | - } |
19 | | - |
20 | | - const { data } = tutorial |
21 | | - |
22 | | - // step complete |
23 | | - const nextProgress = progress |
24 | | - nextProgress.steps[position.stepId] = true |
25 | | - |
26 | | - // is stage complete |
27 | | - const steps = data.stages[position.stageId].stepList |
28 | | - const isStageComplete = progress.stages[position.stageId] || steps[steps.length - 1] === position.stepId |
29 | | - nextProgress.stages[position.stageId] = isStageComplete |
30 | | - |
31 | | - // is level complete |
32 | | - if (isStageComplete) { |
33 | | - const stages = data.levels[position.levelId].stageList |
34 | | - const isLevelComplete = progress.levels[position.levelId] || stages[stages.length - 1] === position.stageId |
35 | | - nextProgress.levels[position.levelId] = isLevelComplete |
36 | | - |
37 | | - if (isLevelComplete) { |
38 | | - const levels = data.summary.levelList |
39 | | - const isTutorialComplete = progress.complete || levels[levels.length - 1] === position.levelId |
40 | | - nextProgress.complete = isTutorialComplete |
41 | | - } |
42 | | - } |
43 | | - console.log('nextProgress', nextProgress) |
44 | | - |
45 | | - // update ls progress |
46 | | - storage.updateProgress(nextProgress) |
47 | | - // send({ type: 'STEP_COMPLETE', payload: { progress: nextProgress } }) |
48 | | -} |
49 | | - |
50 | | -export async function onFailure() { |
51 | | - // TODO: capture analytics on stepId |
52 | | - vscode.window.showWarningMessage('FAIL') |
53 | | -} |
| 1 | +// import * as CR from 'typings' |
| 2 | +// import * as vscode from 'vscode' |
| 3 | +// import * as storage from './storage' |
| 4 | + |
| 5 | +// export async function onSuccess(position: CR.Position) { |
| 6 | +// console.log('onSuccess', position) |
| 7 | +// vscode.window.showInformationMessage('SUCCESS') |
| 8 | + |
| 9 | +// // calculate progress changes |
| 10 | +// const [progress, tutorial] = await Promise.all([storage.getProgress(), storage.getTutorial()]) |
| 11 | + |
| 12 | +// if (!tutorial) { |
| 13 | +// throw new Error('No tutorial found') |
| 14 | +// } |
| 15 | + |
| 16 | +// if (!position.stepId) { |
| 17 | +// throw new Error('No step position found') |
| 18 | +// } |
| 19 | + |
| 20 | +// const { data } = tutorial |
| 21 | + |
| 22 | +// // step complete |
| 23 | +// const nextProgress = progress |
| 24 | +// nextProgress.steps[position.stepId] = true |
| 25 | + |
| 26 | +// // is stage complete |
| 27 | +// const steps = data.stages[position.stageId].stepList |
| 28 | +// const isStageComplete = progress.stages[position.stageId] || steps[steps.length - 1] === position.stepId |
| 29 | +// nextProgress.stages[position.stageId] = isStageComplete |
| 30 | + |
| 31 | +// // is level complete |
| 32 | +// if (isStageComplete) { |
| 33 | +// const stages = data.levels[position.levelId].stageList |
| 34 | +// const isLevelComplete = progress.levels[position.levelId] || stages[stages.length - 1] === position.stageId |
| 35 | +// nextProgress.levels[position.levelId] = isLevelComplete |
| 36 | + |
| 37 | +// if (isLevelComplete) { |
| 38 | +// const levels = data.summary.levelList |
| 39 | +// const isTutorialComplete = progress.complete || levels[levels.length - 1] === position.levelId |
| 40 | +// nextProgress.complete = isTutorialComplete |
| 41 | +// } |
| 42 | +// } |
| 43 | +// console.log('nextProgress', nextProgress) |
| 44 | + |
| 45 | +// // update ls progress |
| 46 | +// storage.updateProgress(nextProgress) |
| 47 | +// // send({ type: 'STEP_COMPLETE', payload: { progress: nextProgress } }) |
| 48 | +// } |
| 49 | + |
| 50 | +// export async function onFailure() { |
| 51 | +// // TODO: capture analytics on stepId |
| 52 | +// vscode.window.showWarningMessage('FAIL') |
| 53 | +// } |
0 commit comments