Use componentWillMount() as a before hook
This commit is contained in:
parent
614c39aab0
commit
5470c77a33
|
@ -19,15 +19,13 @@ export const attachAppToDom: Callback = () => {
|
|||
};
|
||||
|
||||
export class RootComponent extends React.Component<RootComponentProps, {}> {
|
||||
render() {
|
||||
// ==== TEMPORARY HACK. TODO: Add a before hook, if such a thing exists in
|
||||
// React Router. Or switch routing libs.
|
||||
componentWillMount() {
|
||||
const notLoggedIn = !Session.fetchStoredToken();
|
||||
const restrictedArea = window.location.pathname.includes("/app");
|
||||
if (notLoggedIn && restrictedArea) {
|
||||
Session.clear();
|
||||
}
|
||||
// ==== END HACK ====
|
||||
(notLoggedIn && restrictedArea && Session.clear());
|
||||
}
|
||||
|
||||
render() {
|
||||
return <Provider store={_store}>
|
||||
<Router history={history}>
|
||||
{topLevelRoutes}
|
||||
|
|
|
@ -20,14 +20,7 @@ export function mapStateToProps(props: Everything): Props {
|
|||
const tools = selectAllTools(props.resources.index);
|
||||
|
||||
/** Returns sorted tool slots specific to the tool bay id passed. */
|
||||
const getToolSlots = (/** uuid: string */) => {
|
||||
// TODO: three things:
|
||||
// 1. We don't support multiple bays. Therefore, no need to filter.
|
||||
// 2. If we add an index to this resource, we don't need to perform
|
||||
// filtering.
|
||||
// 3. Once we do support multiple bays, re-add the slot's UUID param.
|
||||
return toolSlots;
|
||||
};
|
||||
const getToolSlots = () => toolSlots;
|
||||
|
||||
/** Returns all tools in an <FBSelect /> compatible format. */
|
||||
const getToolOptions = () => {
|
||||
|
|
Loading…
Reference in a new issue