Skip to content

Commit

Permalink
refactor: changed inner name kActivity to CurrentActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
cnouguier committed Aug 5, 2024
1 parent 5caf713 commit 832e977
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions core/client/composables/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { ref, shallowRef, readonly, onBeforeUnmount } from 'vue'
import { useStore } from './store.js'
import { useSelection } from './selection.js'

const kActivity = shallowRef(null)
const kActivityName = ref(null)
const CurrentActivity = shallowRef(null)
const CurrentActivityName = ref(null)

export function useActivity (name, options = {}) {
_.defaults(options, { selection: true })
Expand All @@ -18,9 +18,9 @@ export function useActivity (name, options = {}) {

// functions
function setCurrentActivity (activity) {
if (kActivity.value === activity) return
kActivityName.value = activity ? name : null
kActivity.value = activity
if (CurrentActivity.value === activity) return
CurrentActivity.value = activity ? name : null
CurrentActivity.value = activity
}

// expose
Expand All @@ -31,7 +31,7 @@ export function useActivity (name, options = {}) {
}
if (options.selection) {
Object.assign(expose, {
...useSelection(kActivityName.value)
...useSelection(CurrentActivityName.value)
})
}

Expand All @@ -46,20 +46,22 @@ export function useCurrentActivity (options = {}) {

// expose
const expose = {
kActivity: readonly(kActivity),
kActivityName: readonly(kActivityName)
CurrentActivity: readonly(CurrentActivity),
kActivity: readonly(CurrentActivity),
CurrentActivityName: readonly(CurrentActivityName),
kActivityName: readonly(CurrentActivityName)
}
if (kActivityName.value) {
const activityState = useStore(`store.${kActivityName.value}.state`)
const activityOptions = useStore(`store.${kActivityName.value}.options`)
if (CurrentActivityName.value) {
const activityState = useStore(`store.${CurrentActivity.value}.state`)
const activityOptions = useStore(`store.${CurrentActivity.value}.options`)

Object.assign(expose, {
state: activityState.store,
options: readonly(activityOptions.store)
})
if (options.selection) {
Object.assign(expose, {
...useSelection(kActivityName.value)
...useSelection(CurrentActivity.value)
})
}
}
Expand Down

0 comments on commit 832e977

Please sign in to comment.