Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to dark mode for the Museum Experience! #280

Open
wants to merge 11 commits into
base: master
from

Determine at fetch time whether projects should be in museum mode.

  • Loading branch information...
chelseatroy committed Aug 27, 2019
commit 3a50c156c7d771edd03da2d993653888ed4e3fb9
@@ -5,9 +5,6 @@ import * as R from 'ramda'
import * as ActionConstants from '../constants/actions'
import {isValidMobileWorkflow} from '../utils/workflow-utils'

import * as theme from '../theme'
import * as colorModes from './colorModes';

const productionParams = {
mobile_friendly: true,
launch_approved: true,
@@ -63,6 +60,7 @@ export function fetchProjects() {
})
}


projectCalls.push(fetchPaginatedProjects(productionParams));
projectCalls.push(fetchPaginatedProjects(betaParams));

@@ -85,10 +83,18 @@ export function fetchProjects() {
let projectDetailCalls = []
projectDetailCalls.push(getWorkflowsForProjects(allProjects))
const avatarCall = getAvatarsForProjects(allProjects)
const museumModeCall = getMuseumRoleForProjects(allProjects)

projectDetailCalls = projectDetailCalls.concat(avatarCall)
projectDetailCalls = projectDetailCalls.concat(museumModeCall)
// Then load the avatars and workflows
Promise.all(projectDetailCalls)
.then(() => {
allProjects.forEach(project => {
console.log(project.display_name)
console.log(project.inMuseumMode)
console.log(project.avatar_src)
})
dispatch(addProjects(allProjects))
dispatch(addProjectsSuccess);
resolve(allProjects)
@@ -109,7 +115,8 @@ export function fetchProjects() {

const getAvatarsForProjects = projects => {
return projects.map(project => {
return apiClient.type('avatars').get(project.links.avatar.id)
return apiClient.type('avatars')
.get(project.links.avatar.id)
.then((avatar) => {
project.avatar_src = avatar.src
})
@@ -119,6 +126,18 @@ const getAvatarsForProjects = projects => {
})
}

const getMuseumRoleForProjects = projects => {
return projects.map(project => {
return apiClient.type('project_roles')
.get({id: project.links.project_roles})
.then((roles) => {
roles.forEach(role => {
project.in_museum_mode = project.in_museum_mode || role.roles.includes('museum')
})
})
})
}

const getWorkflowsForProjects = projects => {
const projectIds = projects.map((project) => project.id)

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.