add challengeId to localStorage

remove unneeded current challenge route
This commit is contained in:
Berkeley Martinez
2015-09-08 22:18:25 -07:00
parent f0a4924671
commit 184ba1fa37
2 changed files with 3 additions and 34 deletions

View File

@ -131,12 +131,6 @@ module.exports = function(app) {
router.get('/challenges/:challengeName', returnIndividualChallenge);
router.get(
'/challenges/',
redirectNonUser,
returnCurrentChallenge
);
app.use(router);
function returnNextChallenge(req, res, next) {
@ -218,34 +212,6 @@ module.exports = function(app) {
);
}
function returnCurrentChallenge(req, res, next) {
Observable.just(req.user)
.flatMap(user => {
if (!req.user.currentChallenge) {
return challenge$
.first()
.flatMap(challenge => {
user.currentChallenge = {
challengeId: challenge.id,
challengeName: challenge.name,
dashedName: challenge.dashedName
};
return saveUser(user);
});
}
return Observable.just(user);
})
.map(user => user.currentChallenge.dashedName)
.subscribe(
function(challengeName) {
res.redirect('/challenges/' + challengeName);
},
next,
function() {
}
);
}
function returnIndividualChallenge(req, res, next) {
const origChallengeName = req.params.challengeName;
const unDashedName = unDasherize(origChallengeName);

View File

@ -48,3 +48,6 @@
a.btn.btn-lg.btn-info.btn-block#reset-button(href='#', data-dismiss='modal', aria-hidden='true') Clear my code
a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Cancel
script.
if (typeof localStorage !== 'undefined') {
localStorage.setItem('currentChallenge', challenge_Id);
}