getters.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { buildURI } from '../functions'
  2. export default {
  3. isGdprValidated(state) {
  4. if (!state) return
  5. return state.gdprConsent
  6. },
  7. isHostConfigured(state) {
  8. if (!state) return
  9. return !!(state.hostConfig.ssl !== null && state.hostConfig.host && state.hostConfig.port)
  10. },
  11. getHostURI(state, getters) {
  12. if (!state) return
  13. if (getters.isHostConfigured)
  14. return buildURI(state.hostConfig.ssl, state.hostConfig.host, state.hostConfig.port)
  15. },
  16. areScenesLoaded(state) {
  17. if (!state) return
  18. return state.scenesList !== null
  19. },
  20. // TODO: Cache scene thumb URI
  21. // areScenesThumbsLoaded(state) {
  22. // return state.scenesList !== null
  23. // }
  24. getExperimentProgress: state => ({ experimentName, sceneName }) => {
  25. if (!state) return
  26. if (state.progression && state.progression[experimentName])
  27. return state.progression[experimentName][sceneName].data
  28. },
  29. isExperimentDone: state => ({ experimentName, sceneName }) => {
  30. if (!state) return
  31. if (state.progression && state.progression[experimentName])
  32. return state.progression[experimentName][sceneName].done
  33. }
  34. }