These redirects are already in place for the courseware, and will redirect to the outline page, or the dashboard, or wherever, based on the type of access error (unenrolled, access expired, survey needed, etc). This commit stops the course home tabs from paying attention to the 401 error messages coming from the backend - course_access in the metadata API handles that now. This commit also changes our useModel hook to more gracefully handle not being able to find the model - it is a valid case we want to allow (still will cause problems if you actually try to use the data, but will at least provide an object you can inspect).
18 lines
415 B
JavaScript
18 lines
415 B
JavaScript
import { useSelector, shallowEqual } from 'react-redux';
|
|
|
|
export function useModel(type, id) {
|
|
return useSelector(
|
|
state => (state.models[type] !== undefined ? state.models[type][id] : {}),
|
|
shallowEqual,
|
|
);
|
|
}
|
|
|
|
export function useModels(type, ids) {
|
|
return useSelector(
|
|
state => ids.map(
|
|
id => (state.models[type] !== undefined ? state.models[type][id] : {}),
|
|
),
|
|
shallowEqual,
|
|
);
|
|
}
|