Use reactive course query to be able to work with cache
This commit is contained in:
parent
c32520548c
commit
6a827ae0ae
|
|
@ -14,8 +14,9 @@ import {
|
|||
useCurrentCourseSession,
|
||||
} from "@/composables";
|
||||
import CourseSessionDueDatesList from "@/components/dueDates/CourseSessionDueDatesList.vue";
|
||||
import { useMutation } from "@urql/vue";
|
||||
import { useMutation, useQuery } from "@urql/vue";
|
||||
import { UPDATE_COURSE_PROFILE_MUTATION } from "@/graphql/mutations";
|
||||
import { COURSE_QUERY } from "@/graphql/queries";
|
||||
|
||||
const props = defineProps<{
|
||||
courseSlug: string;
|
||||
|
|
@ -36,7 +37,21 @@ const course = computed(() => lpQueryResult.course.value);
|
|||
|
||||
const courseSession = useCurrentCourseSession();
|
||||
|
||||
const filter = ref("");
|
||||
// todo: we do not use the courseStore, because the returned object has lost its reactivity and does not reflect cache changes. maybe this could be fixed in there, then we can use the same object here
|
||||
// todo: this could maybe go somewhere else, but useQuery must be used inside of a setup function. is there a better place?
|
||||
const courseReactiveResult = useQuery({
|
||||
query: COURSE_QUERY,
|
||||
variables: { slug: props.courseSlug },
|
||||
});
|
||||
const courseReactive = computed(() => courseReactiveResult.data.value?.course);
|
||||
const courseSessionUser = computed(() => {
|
||||
return courseReactive.value?.course_session_users.find(
|
||||
(e) => e?.course_session.id === courseSession.value.id
|
||||
);
|
||||
});
|
||||
const filter = computed(() => {
|
||||
return courseSessionUser.value?.chosen_profile || "";
|
||||
});
|
||||
|
||||
const { inProgressCirclesCount, circlesCount } = useCourseCircleProgress(
|
||||
lpQueryResult.circles
|
||||
|
|
|
|||
Loading…
Reference in New Issue