* fix(routes): /map redirects to current challenge * fix(map): Normalize server map building Localize all server code dealing with the map * refactor(server): Remove unused services * feat(Nav): Show Map button when no panes This gives user the ability to quickly return to their challenge using a known feature * fix(server.map): Add caching to nameIdMap Add caching to nameIdMap on the server * fix(services.map): Fix map service Move map building utils to map util. Fix bad import. Normalize challenge lookup
29 lines
707 B
JavaScript
29 lines
707 B
JavaScript
import { Observable } from 'rx';
|
|
import debug from 'debug';
|
|
import {
|
|
cachedMap,
|
|
getChallenge,
|
|
getMapForLang
|
|
} from '../utils/map';
|
|
|
|
const log = debug('fcc:services:map');
|
|
|
|
export default function mapService(app) {
|
|
const challengeMap = cachedMap(app.models);
|
|
return {
|
|
name: 'map',
|
|
read: (req, resource, { lang, block, dashedName } = {}, config, cb) => {
|
|
log(`${lang} language requested`);
|
|
return Observable.if(
|
|
() => !!dashedName,
|
|
getChallenge(dashedName, block, challengeMap, lang),
|
|
challengeMap.map(getMapForLang(lang))
|
|
)
|
|
.subscribe(
|
|
results => cb(null, results),
|
|
err => { log(err); cb(err); }
|
|
);
|
|
}
|
|
};
|
|
}
|