getters.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { buildURI, buildWsURI } 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. getHostWsURI(state, getters) {
  17. if (!state) return
  18. if (getters.isHostConfigured)
  19. return buildWsURI(state.hostConfig.ssl, state.hostConfig.host, state.hostConfig.port)
  20. },
  21. areScenesLoaded(state) {
  22. if (!state) return
  23. return state.scenesList !== null
  24. },
  25. // TODO: Cache scene thumb URI
  26. // areScenesThumbsLoaded(state) {
  27. // return state.scenesList !== null
  28. // }
  29. getExperimentProgress: state => ({ experimentName, sceneName }) => {
  30. if (!state) return
  31. if (state.progression && state.progression[experimentName])
  32. return state.progression[experimentName][sceneName].data
  33. },
  34. isExperimentDone: state => ({ experimentName, sceneName }) => {
  35. if (!state) return
  36. if (state.progression && state.progression[experimentName])
  37. return state.progression[experimentName][sceneName].done
  38. }
  39. }