Fix change challenge model to POJO
This commit is contained in:
@ -191,7 +191,7 @@ gulp.task('serve', ['build-manifest'], function(cb) {
|
|||||||
ignore: paths.serverIgnore,
|
ignore: paths.serverIgnore,
|
||||||
exec: path.join(__dirname, 'node_modules/.bin/babel-node'),
|
exec: path.join(__dirname, 'node_modules/.bin/babel-node'),
|
||||||
env: {
|
env: {
|
||||||
'NODE_ENV': 'development',
|
'NODE_ENV': process.env.NODE_ENV || 'development',
|
||||||
'DEBUG': process.env.DEBUG || 'freecc:*'
|
'DEBUG': process.env.DEBUG || 'freecc:*'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -125,6 +125,7 @@ function getRenderData$(user, challenge$, origChallengeName, solution) {
|
|||||||
debug('looking for %s', testChallengeName);
|
debug('looking for %s', testChallengeName);
|
||||||
|
|
||||||
return challenge$
|
return challenge$
|
||||||
|
.map(challenge => challenge.toJSON())
|
||||||
.filter((challenge) => {
|
.filter((challenge) => {
|
||||||
return testChallengeName.test(challenge.name) &&
|
return testChallengeName.test(challenge.name) &&
|
||||||
shouldNotFilterComingSoon(challenge);
|
shouldNotFilterComingSoon(challenge);
|
||||||
@ -164,7 +165,6 @@ function getRenderData$(user, challenge$, origChallengeName, solution) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(challenge.helpRoom);
|
|
||||||
// save user does nothing if user does not exist
|
// save user does nothing if user does not exist
|
||||||
return Observable.just({
|
return Observable.just({
|
||||||
data: {
|
data: {
|
||||||
@ -414,7 +414,11 @@ module.exports = function(app) {
|
|||||||
app.use(router);
|
app.use(router);
|
||||||
|
|
||||||
function redirectToCurrentChallenge(req, res, next) {
|
function redirectToCurrentChallenge(req, res, next) {
|
||||||
const challengeId = req.query.id || req.cookies.currentChallengeId;
|
let challengeId = req.query.id || req.cookies.currentChallengeId;
|
||||||
|
// prevent serialized null/undefined from breaking things
|
||||||
|
if (challengeId === 'undefined' || challengeId === 'null') {
|
||||||
|
challengeId = null;
|
||||||
|
}
|
||||||
getChallengeById$(challenge$, challengeId)
|
getChallengeById$(challenge$, challengeId)
|
||||||
.doOnNext(({ dashedName })=> {
|
.doOnNext(({ dashedName })=> {
|
||||||
if (!dashedName) {
|
if (!dashedName) {
|
||||||
@ -430,7 +434,10 @@ module.exports = function(app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function redirectToNextChallenge(req, res, next) {
|
function redirectToNextChallenge(req, res, next) {
|
||||||
const challengeId = req.query.id || req.cookies.currentChallengeId;
|
let challengeId = req.query.id || req.cookies.currentChallengeId;
|
||||||
|
if (challengeId === 'undefined' || challengeId === 'null') {
|
||||||
|
challengeId = null;
|
||||||
|
}
|
||||||
|
|
||||||
Observable.combineLatest(
|
Observable.combineLatest(
|
||||||
firstChallenge$,
|
firstChallenge$,
|
||||||
@ -485,8 +492,9 @@ module.exports = function(app) {
|
|||||||
return res.redirect(redirectUrl);
|
return res.redirect(redirectUrl);
|
||||||
}
|
}
|
||||||
var view = challengeView[data.challengeType];
|
var view = challengeView[data.challengeType];
|
||||||
res.cookie('currentChallengeId', data.id);
|
if (data.id) {
|
||||||
console.log(data.helpRoom);
|
res.cookie('currentChallengeId', data.id);
|
||||||
|
}
|
||||||
res.render(view, data);
|
res.render(view, data);
|
||||||
},
|
},
|
||||||
next,
|
next,
|
||||||
|
@ -29,7 +29,7 @@ export default function prodErrorHandler() {
|
|||||||
msg: message
|
msg: message
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return res.redirect('/');
|
return res.redirect('/map');
|
||||||
// json
|
// json
|
||||||
} else if (type === 'json') {
|
} else if (type === 'json') {
|
||||||
res.setHeader('Content-Type', 'application/json');
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
Reference in New Issue
Block a user