Skip to content

Commit fd11759

Browse files
committed
refactor: inject view getter into StudySession
rather than depend directly on `courses`. Preparation for moving `StudySession` to `common-ui`
1 parent 8d7f1b9 commit fd11759

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/platform-ui/src/views/Study.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
:session-time-limit="sessionTimeLimit"
3636
:user="user as User"
3737
:session-config="studySessionConfig"
38+
:get-view-component="getViewComponent"
3839
@session-finished="handleSessionFinished"
3940
/>
4041
</div>
@@ -50,6 +51,7 @@ import { Router } from 'vue-router';
5051
import { CourseConfig } from '@vue-skuilder/common';
5152
import { useConfigStore } from '@/stores/useConfigStore';
5253
import { useDataInputFormStore } from '@/stores/useDataInputFormStore';
54+
import Courses from '@vue-skuilder/courses';
5355
5456
function randomInt(min: number, max: number): number {
5557
return Math.floor(Math.random() * (max - min + 1)) + min;
@@ -107,6 +109,7 @@ export default defineComponent({
107109
sessionPrepared: false,
108110
sessionContentSources: [] as ContentSourceID[],
109111
dataInputFormStore: useDataInputFormStore(),
112+
getViewComponent: (view_id: string) => Courses.getView(view_id),
110113
};
111114
},
112115

packages/platform-ui/src/views/StudySession.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ import {
7979
HeatMap,
8080
CardViewer,
8181
} from '@vue-skuilder/common-ui';
82-
import Courses from '@vue-skuilder/courses';
8382
import {
8483
getCourseDoc,
8584
removeScheduledCardReview,
@@ -159,6 +158,10 @@ export default defineComponent({
159158
type: Object as PropType<StudySessionConfig>,
160159
default: () => ({ likesConfetti: false }),
161160
},
161+
getViewComponent: {
162+
type: Function as PropType<(viewId: string) => ViewComponent>,
163+
required: true,
164+
},
162165
},
163166
164167
emits: ['session-finished', 'session-started', 'card-loaded', 'card-response', 'time-changed'],
@@ -522,7 +525,7 @@ export default defineComponent({
522525
tmpCardData.elo = toCourseElo(tmpCardData.elo);
523526
}
524527
525-
const tmpView: ViewComponent = Courses.getView(tmpCardData.id_view);
528+
const tmpView: ViewComponent = this.getViewComponent(tmpCardData.id_view);
526529
const tmpDataDocs = tmpCardData.id_displayable_data.map((id) => {
527530
return getCourseDoc<DisplayableData>(_courseID, id, {
528531
attachments: true,

0 commit comments

Comments
 (0)