Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

Commit

Permalink
Make requests to handle contextual routes as UnwrappedApp does
Browse files Browse the repository at this point in the history
  • Loading branch information
artkravchenko committed Jul 6, 2017
1 parent 237745b commit 01ba256
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
14 changes: 8 additions & 6 deletions src/pages/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ export class UnwrappedAuth extends React.Component {
const isLoggedIn = (currentUserId !== null);

if (!isLoggedIn) {
store.dispatch(attachContextualRoutes(
UnwrappedAuth.displayName,
getRoutesNames(router.routes),
['#login']
));

return null;
}

Expand All @@ -101,6 +95,14 @@ export class UnwrappedAuth extends React.Component {
};
}

componentWillMount() {
this.props.dispatch(attachContextualRoutes(
UnwrappedAuth.displayName,
getRoutesNames(this.props.routes),
['#login']
));
}

componentWillUnmount() {
this.props.dispatch(detachContextualRoutes(
UnwrappedAuth.displayName,
Expand Down
16 changes: 8 additions & 8 deletions src/pages/password-reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ export class PasswordResetPage extends React.Component {
location: { hash: '', pathname: '', search: '' }
};

static fetchData(router, store) {
store.dispatch(attachContextualRoutes(
PasswordResetPage.displayName,
getRoutesNames(router.routes),
['#login']
));
}

constructor(props, ...args) {
super(props, ...args);

Expand All @@ -97,6 +89,14 @@ export class PasswordResetPage extends React.Component {
};
}

componentWillMount() {
this.props.dispatch(attachContextualRoutes(
PasswordResetPage.displayName,
getRoutesNames(this.props.routes),
['#login']
));
}

componentWillUnmount() {
this.props.dispatch(detachContextualRoutes(
PasswordResetPage.displayName,
Expand Down
14 changes: 8 additions & 6 deletions src/pages/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ class Welcome extends React.Component {
return { status: 307, redirectTo: '/' };
}

store.dispatch(attachContextualRoutes(
Welcome.displayName,
getRoutesNames(router.routes),
['#login']
));

return await trigger.setQuotes();
}

Expand All @@ -69,6 +63,14 @@ class Welcome extends React.Component {
};
}

componentWillMount() {
this.props.dispatch(attachContextualRoutes(
Welcome.displayName,
getRoutesNames(this.props.routes),
['#login']
));
}

componentWillUnmount() {
this.props.dispatch(detachContextualRoutes(
Welcome.displayName,
Expand Down

0 comments on commit 01ba256

Please sign in to comment.