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

Fix global loading state on root Coach pages #11218

Merged
merged 2 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions kolibri/plugins/coach/assets/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class CoachToolsModule extends KolibriApp {
redirectBrowser();
return;
}
this.store.dispatch('loading');
const promises = [];
// Clear the snackbar at every navigation to prevent it from re-appearing
// when the next page component mounts.
Expand Down
4 changes: 2 additions & 2 deletions kolibri/plugins/coach/assets/src/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export default [
path: '/classes',
component: CoachClassListPage,
handler(toRoute) {
store.dispatch('loading');
// loading state is handled locally
store.dispatch('notLoading');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This accords with my general sense that we can reduce the role of the core loading state to be about toggling the linear loader when the navigation is still resolving. In this frame, we could handle it entirely within our core routing setup, where we toggle it on before route enter, and toggle it after after the route has resolved.

// if user only has access to one facility, facility_id will not be accessible from URL,
// but always defaulting to userFacilityId would cause problems for multi-facility admins
const facilityId = toRoute.query.facility_id || store.getters.userFacilityId;
Expand All @@ -41,7 +42,6 @@ export default [
});
return;
}
store.dispatch('notLoading');
},
error => store.dispatch('handleApiError', { error, reloadOnReconnect: true })
);
Expand Down