Client - refactoring workouts (WIP)

separate user workouts from timeline workouts
This commit is contained in:
Sam
2021-11-02 14:02:18 +01:00
parent 288a78e2a0
commit 37596f52f4
8 changed files with 45 additions and 44 deletions

View File

@ -75,7 +75,7 @@
onBeforeMount(() => loadWorkouts())
const workouts: ComputedRef<IWorkout[]> = computed(
() => store.getters[WORKOUTS_STORE.GETTERS.USER_WORKOUTS]
() => store.getters[WORKOUTS_STORE.GETTERS.TIMELINE_WORKOUTS]
)
const moreWorkoutsExist: ComputedRef<boolean> = computed(() =>
workouts.value.length > 0
@ -84,7 +84,7 @@
)
function loadWorkouts() {
store.dispatch(WORKOUTS_STORE.ACTIONS.GET_USER_WORKOUTS, {
store.dispatch(WORKOUTS_STORE.ACTIONS.GET_TIMELINE_WORKOUTS, {
page: page.value,
per_page,
...defaultOrder,
@ -92,7 +92,7 @@
}
function loadMoreWorkouts() {
page.value += 1
store.dispatch(WORKOUTS_STORE.ACTIONS.GET_MORE_USER_WORKOUTS, {
store.dispatch(WORKOUTS_STORE.ACTIONS.GET_MORE_TIMELINE_WORKOUTS, {
page: page.value,
per_page,
...defaultOrder,

View File

@ -92,11 +92,6 @@
</div>
</div>
<NoWorkouts v-if="workouts.length === 0" />
<div v-if="moreWorkoutsExist" class="more-workouts">
<button @click="loadMoreWorkouts">
{{ $t('workouts.LOAD_MORE_WORKOUT') }}
</button>
</div>
<div id="bottom" />
</div>
</template>
@ -150,11 +145,6 @@
)
const per_page = 10
const page = ref(1)
const moreWorkoutsExist: ComputedRef<boolean> = computed(() =>
workouts.value.length > 0
? workouts.value[workouts.value.length - 1].previous_workout !== null
: false
)
onBeforeMount(() => {
loadWorkouts()
@ -169,15 +159,6 @@
...props.params,
})
}
function loadMoreWorkouts() {
page.value += 1
store.dispatch(WORKOUTS_STORE.ACTIONS.GET_MORE_USER_WORKOUTS, {
page: page.value,
per_page,
...defaultOrder,
...props.params,
})
}
watch(
() => props.params,
@ -187,12 +168,10 @@
)
return {
moreWorkoutsExist,
workouts,
capitalize,
format,
getDateWithTZ,
loadMoreWorkouts,
}
},
})