Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved router handlers architecture in Coach - part 1 #11570

Merged
merged 5 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions kolibri/plugins/coach/assets/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { setChannelInfo } from 'kolibri.coreVue.vuex.actions';
import router from 'kolibri.coreVue.router';
import PageRoot from 'kolibri.coreVue.components.PageRoot';
import KolibriApp from 'kolibri_app';
import { PageNames } from './constants';
import routes from './routes';
import pluginModule from './modules/pluginModule';

Expand Down Expand Up @@ -38,18 +39,33 @@ class CoachToolsModule extends KolibriApp {
this.store.commit('SET_PAGE_NAME', to.name);
if (
to.name &&
!to.params.classId &&
!['CoachClassListPage', 'StatusTestPage', 'CoachPrompts', 'AllFacilitiesPage'].includes(
to.name
)
) {
if (to.params.classId)
promises.push(this.store.dispatch('initClassInfo', to.params.classId));
} else {
this.store.dispatch('coachNotifications/stopPolling');
}
if (this.store.getters.isSuperuser && this.store.state.core.facilities.length === 0) {
promises.push(this.store.dispatch('getFacilities').catch(() => {}));
if (to.name !== PageNames.EXAMS) {
ShivangRawat30 marked this conversation as resolved.
Show resolved Hide resolved
if (
to.name &&
to.params.classId &&
!['CoachClassListPage', 'StatusTestPage', 'CoachPrompts', 'AllFacilitiesPage'].includes(
to.name
)
) {
if (to.params.classId) {
promises.push(this.store.dispatch('initClassInfo', to.params.classId));
}
} else {
this.store.dispatch('coachNotifications/stopPolling');
ShivangRawat30 marked this conversation as resolved.
Show resolved Hide resolved
}

if (this.store.getters.isSuperuser && this.store.state.core.facilities.length === 0) {
promises.push(this.store.dispatch('getFacilities').catch(() => {}));
}
}

if (promises.length > 0) {
Promise.all(promises).then(next, error => {
this.store.dispatch('handleApiError', { error });
Expand Down
ShivangRawat30 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export function showExamsPage(store, classId) {
// state.classList needs to be set for Copy Exam modal to work
store.dispatch('setClassList', store.state.classSummary.facility_id),
];
promises.push(store.dispatch('initClassInfo', classId));
ShivangRawat30 marked this conversation as resolved.
Show resolved Hide resolved

if (store.getters.isSuperuser && store.state.core.facilities.length === 0) {
promises.push(store.dispatch('getFacilities').catch(() => {}));
}

const shouldResolve = samePageCheckGenerator(store);

Expand Down
Loading