8000 reset to position · ShaunSHamilton/coderoad-vscode@c30e11d · GitHub
[go: up one dir, main page]

Skip to content

Commit c30e11d

Browse files
committed
reset to position
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent a4418b1 commit c30e11d

File tree

4 files changed

+17
-9
lines changed
  • src
  • web-app/src/services/state/actions
  • 4 files changed

    +17
    -9
    lines changed

    src/actions/index.ts

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -2,7 +2,7 @@ export { default as onStartup } from './onStartup'
    22
    export { default as onTutorialConfig } from './onTutorialConfig'
    33
    export { default as onTutorialContinueConfig } from './onTutorialContinueConfig'
    44
    export { default as onValidateSetup } from './onValidateSetup'
    8000 5-
    export { default as onRunLatestReset } from './onRunLatestReset'
    5+
    export { default as onRunReset } from './onRunReset'
    66
    export { default as onErrorPage } from './onErrorPage'
    77
    export { onRunTest, onTestPass } from './onTest'
    88
    export { onSetupActions, onSolutionActions } from './onActions'

    src/actions/onRunLatestReset.ts renamed to src/actions/onRunReset.ts

    Lines changed: 10 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -3,16 +3,21 @@ import * as TT from 'typings/tutorial'
    33
    import Context from '../services/context/context'
    44
    import { exec } from '../services/node'
    55
    import reset from '../services/reset'
    6-
    import getLastCommitHash from '../services/reset/lastHash'
    6+
    import getCommitHashByPosition from '../services/reset/lastHash'
    7+
    8+
    type ResetAction = {
    9+
    type: 'LATEST' | 'POSITION'
    10+
    position?: T.Position
    11+
    }
    712

    813
    // reset to the start of the last test
    9-
    const onRunLatestReset = async (context: Context) => {
    14+
    const onRunReset = async (action: ResetAction, context: Context) => {
    1015
    // reset to timeline
    1116
    const tutorial: TT.Tutorial | null = context.tutorial.get()
    12-
    const position: T.Position = context.position.get()
    17+
    const position: T.Position = action.position ? action.position : context.position.get()
    1318

    1419
    // get last pass commit
    15-
    const hash = getLastCommitHash(position, tutorial?.levels || [])
    20+
    const hash: string = getCommitHashByPosition(position, tutorial?.levels || [])
    1621

    1722
    const branch = tutorial?.config.repo.branch
    1823

    @@ -30,4 +35,4 @@ const onRunLatestReset = async (context: Context) => {
    3035
    }
    3136
    }
    3237

    33-
    export default onRunLatestReset
    38+
    export default onRunReset

    src/channel.ts

    Lines changed: 5 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -79,8 +79,11 @@ class Channel implements Channel {
    7979
    case 'EDITOR_RUN_TEST':
    8080
    actions.onRunTest(action)
    8181
    return
    82-
    case 'EDITOR_RUN_RESET':
    83-
    actions.onRunLatestReset(this.context)
    82+
    case 'EDITOR_RUN_RESET_LATEST':
    83+
    actions.onRunReset({ type: 'LATEST' }, this.context)
    84+
    return
    85+
    case 'EDITOR_RUN_RESET_POSITION':
    86+
    actions.onRunReset({ type: 'POSITION', position: action.payload.position }, this.context)
    8487
    return
    8588
    default:
    8689
    logger(`No match for action type: ${actionType}`)

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

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    5CFE
    @@ -119,7 +119,7 @@ export default (editorSend: any) => ({
    119119
    },
    120120
    runReset() {
    121121
    editorSend({
    122-
    type: 'EDITOR_RUN_RESET',
    122+
    type: 'EDITOR_RUN_RESET_LATEST',
    123123
    })
    124124
    },
    125125
    })

    0 commit comments

    Comments
     (0)
    0