Skip to content

Refactor editor #396

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
refactor onTutorialContinueConfig
Signed-off-by: shmck <[email protected]>
  • Loading branch information
ShMcK committed Jul 20, 2020
commit 15166d1ac544cf117796fc02cd9a96a0fb29aa2c
1 change: 1 addition & 0 deletions src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { default as onStartup } from './onStartup'
export { default as onTutorialConfig } from './onTutorialConfig'
export { default as onTutorialContinueConfig } from './onTutorialContinueConfig'
export { default as onErrorPage } from './onErrorPage'
export { default as onTestPass } from './onTestPass'
29 changes: 29 additions & 0 deletions src/actions/onTutorialContinueConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as vscode from 'vscode'
import * as T from 'typings'
import * as TT from 'typings/tutorial'
import Context from '../services/context/context'
import tutorialConfig from './utils/tutorialConfig'
import { COMMANDS } from '../commands'

const onTutorialContinueConfig = async (action: T.Action, context: Context, send: any) => {
try {
const tutorialContinue: TT.Tutorial | null = context.tutorial.get()
if (!tutorialContinue) {
throw new Error('Invalid tutorial to continue')
}
await tutorialConfig({
data: tutorialContinue,
alreadyConfigured: true,
})
// update the current stepId on startup
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_POSITION, action.payload.position)
} catch (e) {
const error = {
type: 'UnknownError',
message: `Location: Editor tutorial continue config.\n\n ${e.message}`,
}
send({ type: 'CONTINUE_FAILED', payload: { error } })
}
}

export default onTutorialContinueConfig
20 changes: 1 addition & 19 deletions src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as TT from 'typings/tutorial'
import * as E from 'typings/error'
import * as vscode from 'vscode'
import { setupActions, solutionActions } from './actions/setupActions'
import tutorialConfig from './actions/utils/tutorialConfig'
import { COMMANDS } from './commands'
import Context from './services/context/context'
import logger from './services/logger'
Expand Down Expand Up @@ -60,24 +59,7 @@ class Channel implements Channel {
actions.onTutorialConfig(action, this.context, this.workspaceState, this.send)
return
case 'EDITOR_TUTORIAL_CONTINUE_CONFIG':
try {
const tutorialContinue: TT.Tutorial | null = this.context.tutorial.get()
if (!tutorialContinue) {
throw new Error('Invalid tutorial to continue')
}
await tutorialConfig({
data: tutorialContinue,
alreadyConfigured: true,
})
// update the current stepId on startup
vscode.commands.executeCommand(COMMANDS.SET_CURRENT_POSITION, action.payload.position)
} catch (e) {
const error = {
type: 'UnknownError',
message: `Location: Editor tutorial continue config.\n\n ${e.message}`,
}
this.send({ type: 'CONTINUE_FAILED', payload: { error } })
}
actions.onTutorialContinueConfig(action, this.context, this.send)
return
case 'EDITOR_VALIDATE_SETUP':
try {
Expand Down