Skip to content

Commit aae3fa5

Browse files
committed
load page position progress
1 parent 8e96307 commit aae3fa5

File tree

6 files changed

+30
-3
lines changed

6 files changed

+30
-3
lines changed

lib/modules/page/page-position/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ function pagePosition(pagePosition, action) {
55
switch (action.type) {
66
case types_1.PAGE_SET:
77
return action.payload.pagePosition;
8+
case 'PROGRESS_PAGE_POSITION':
9+
var pages = action.payload.progress.pages;
10+
var firstFail = pages.indexOf(false);
11+
return firstFail < 0 ? pages.length - 1 : firstFail;
812
default:
913
return pagePosition;
1014
}

lib/modules/progress/actions.js

+7
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ function progressLoad() {
55
return function (dispatch, getState) {
66
var tutorial = getState().tutorial;
77
dispatch({ type: types_1.PROGRESS_LOAD, payload: { tutorial: tutorial } });
8+
dispatch(_progressPagePosition());
89
dispatch(actions_1.testRun());
910
};
1011
}
1112
exports.progressLoad = progressLoad;
13+
function _progressPagePosition() {
14+
return function (dispatch, getState) {
15+
var progress = getState().progress;
16+
dispatch({ type: types_1.PROGRESS_PAGE_POSITION, payload: { progress: progress } });
17+
};
18+
}
1219
function progressCompletePage(completed) {
1320
if (completed === void 0) { completed = true; }
1421
return function (dispatch, getState) {

lib/modules/progress/types.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2-
exports.PROGRESS_LOAD = 'PROGRESS_LOAD';
32
exports.PROGRESS_COMPLETE_PAGE = 'PROGRESS_COMPLETE_PAGE';
43
exports.PROGRESS_COMPLETE_TUTORIAL = 'PROGRESS_COMPLETE_TUTORIAL';
4+
exports.PROGRESS_LOAD = 'PROGRESS_LOAD';
5+
exports.PROGRESS_PAGE_POSITION = 'PROGRESS_PAGE_POSITION';

src/modules/page/page-position/index.ts

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ export default function pagePosition(
88
case PAGE_SET:
99
return action.payload.pagePosition;
1010

11+
// allow access until before first incomplete tutorial
12+
case 'PROGRESS_PAGE_POSITION':
13+
const pages = action.payload.progress.pages;
14+
const firstFail = pages.indexOf(false);
15+
return firstFail < 0 ? pages.length - 1 : firstFail;
16+
1117
default:
1218
return pagePosition;
1319
}

src/modules/progress/actions.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
PROGRESS_LOAD, PROGRESS_COMPLETE_PAGE, PROGRESS_COMPLETE_TUTORIAL
2+
PROGRESS_LOAD, PROGRESS_COMPLETE_PAGE, PROGRESS_PAGE_POSITION, PROGRESS_COMPLETE_TUTORIAL
33
} from './types';
44
import {alertOpen, testRun} from '../../actions';
55

@@ -8,10 +8,18 @@ export function progressLoad(): ReduxThunk.ThunkInterface {
88
return (dispatch, getState) => {
99
const {tutorial} = getState();
1010
dispatch({ type: PROGRESS_LOAD, payload: { tutorial } });
11+
dispatch(_progressPagePosition());
1112
dispatch(testRun());
1213
};
1314
}
1415

16+
function _progressPagePosition() {
17+
return function(dispatch, getState) {
18+
const {progress} = getState();
19+
dispatch({ type: PROGRESS_PAGE_POSITION, payload: { progress } });
20+
};
21+
}
22+
1523
export function progressCompletePage(completed = true): ReduxThunk.ThunkInterface {
1624
return (dispatch, getState) => {
1725
const {pagePosition, progress, tutorial} = getState();

src/modules/progress/types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
export const PROGRESS_LOAD = 'PROGRESS_LOAD';
21
export const PROGRESS_COMPLETE_PAGE = 'PROGRESS_COMPLETE_PAGE';
32
export const PROGRESS_COMPLETE_TUTORIAL = 'PROGRESS_COMPLETE_TUTORIAL';
3+
export const PROGRESS_LOAD = 'PROGRESS_LOAD';
4+
export const PROGRESS_PAGE_POSITION = 'PROGRESS_PAGE_POSITION';

0 commit comments

Comments
 (0)