Fix: map should redirect to current challenge (#15723)
* 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
This commit is contained in:
committed by
Quincy Larson
parent
f92294bbda
commit
c547c26bba
@@ -22,8 +22,7 @@ import {
|
||||
calcLongestStreak
|
||||
} from '../utils/user-stats';
|
||||
import supportedLanguages from '../../common/utils/supported-languages';
|
||||
import createNameIdMap from '../../common/utils/create-name-id-map';
|
||||
import { cachedMap } from '../utils/map';
|
||||
import { getChallengeInfo, cachedMap } from '../utils/map';
|
||||
|
||||
const debug = debugFactory('fcc:boot:user');
|
||||
const sendNonUserToMap = ifNoUserRedirectTo('/map');
|
||||
@@ -97,7 +96,7 @@ function getChallengeGroup(challenge) {
|
||||
// challenges: Array
|
||||
// }]
|
||||
function buildDisplayChallenges(
|
||||
{ challenge: challengeMap = {}, challengeIdToName },
|
||||
{ challengeMap, challengeIdToName },
|
||||
userChallengeMap = {},
|
||||
timezone
|
||||
) {
|
||||
@@ -139,10 +138,8 @@ function buildDisplayChallenges(
|
||||
module.exports = function(app) {
|
||||
const router = app.loopback.Router();
|
||||
const api = app.loopback.Router();
|
||||
const User = app.models.User;
|
||||
const Block = app.models.Block;
|
||||
const { Email } = app.models;
|
||||
const map$ = cachedMap(Block);
|
||||
const { User, Email } = app.models;
|
||||
const map$ = cachedMap(app.models);
|
||||
function findUserByUsername$(username, fields) {
|
||||
return observeQuery(
|
||||
User,
|
||||
@@ -436,9 +433,9 @@ module.exports = function(app) {
|
||||
userPortfolio.bio = emoji.emojify(userPortfolio.bio);
|
||||
}
|
||||
|
||||
return map$.map(({ entities }) => createNameIdMap(entities))
|
||||
.flatMap(entities => buildDisplayChallenges(
|
||||
entities,
|
||||
return getChallengeInfo(map$)
|
||||
.flatMap(challengeInfo => buildDisplayChallenges(
|
||||
challengeInfo,
|
||||
userPortfolio.challengeMap,
|
||||
timezone
|
||||
))
|
||||
|
Reference in New Issue
Block a user