aboutsummaryrefslogtreecommitdiff
path: root/src/components/settings_modal/helpers/shared_computed_object.js
blob: e898c8ac62961e6d02e5ea562a704c5528d7028a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { defaultState as configDefaultState } from 'src/modules/config.js'

const SharedComputedObject = () => ({
  user () {
    return this.$store.state.users.currentUser
  },
  // Generating computed values for vuex properties
  ...Object.keys(configDefaultState)
    .map(key => [key, {
      get () { return this.$store.getters.mergedConfig[key] },
      set (value) {
        this.$store.dispatch('setOption', { name: key, value })
      }
    }])
    .reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {})
})

export default SharedComputedObject