mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
Fire profileDidLoad event in PR to load intercom
This commit is contained in:
parent
d9615188b0
commit
5aaf02b0b4
@ -16,12 +16,13 @@ import LinkContainer from 'react-router-bootstrap/lib/LinkContainer';
|
|||||||
|
|
||||||
import AclProxy from './acl_proxy';
|
import AclProxy from './acl_proxy';
|
||||||
|
|
||||||
|
import EventActions from '../actions/event_actions';
|
||||||
|
|
||||||
import UserActions from '../actions/user_actions';
|
import UserActions from '../actions/user_actions';
|
||||||
import UserStore from '../stores/user_store';
|
import UserStore from '../stores/user_store';
|
||||||
|
|
||||||
import WhitelabelActions from '../actions/whitelabel_actions';
|
import WhitelabelActions from '../actions/whitelabel_actions';
|
||||||
import WhitelabelStore from '../stores/whitelabel_store';
|
import WhitelabelStore from '../stores/whitelabel_store';
|
||||||
import EventActions from '../actions/event_actions';
|
|
||||||
|
|
||||||
import HeaderNotifications from './header_notification';
|
import HeaderNotifications from './header_notification';
|
||||||
|
|
||||||
@ -58,6 +59,19 @@ let Header = React.createClass({
|
|||||||
// close the mobile expanded navigation after a click by itself.
|
// close the mobile expanded navigation after a click by itself.
|
||||||
// To get rid of this, we set the state of the component ourselves.
|
// To get rid of this, we set the state of the component ourselves.
|
||||||
history.listen(this.onRouteChange);
|
history.listen(this.onRouteChange);
|
||||||
|
|
||||||
|
if (this.state.currentUser && this.state.currentUser.email) {
|
||||||
|
EventActions.profileDidLoad.defer(this.state.currentUser);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillUpdate(nextProps, nextState) {
|
||||||
|
const { currentUser: { email: curEmail } = {} } = this.state;
|
||||||
|
const { currentUser: { email: nextEmail } = {} } = nextState;
|
||||||
|
|
||||||
|
if (nextEmail && curEmail !== nextEmail) {
|
||||||
|
EventActions.profileDidLoad.defer(nextState.currentUser);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
@ -105,10 +119,6 @@ let Header = React.createClass({
|
|||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
|
|
||||||
if(this.state.currentUser && this.state.currentUser.email) {
|
|
||||||
EventActions.profileDidLoad.defer(this.state.currentUser);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onMenuItemClick() {
|
onMenuItemClick() {
|
||||||
|
@ -5,32 +5,18 @@ import { Link } from 'react-router';
|
|||||||
|
|
||||||
import Glyphicon from 'react-bootstrap/lib/Glyphicon';
|
import Glyphicon from 'react-bootstrap/lib/Glyphicon';
|
||||||
|
|
||||||
import UserStore from '../../../../../stores/user_store';
|
|
||||||
import UserActions from '../../../../../actions/user_actions';
|
|
||||||
|
|
||||||
import { getLangText } from '../../../../../utils/lang_utils';
|
import { getLangText } from '../../../../../utils/lang_utils';
|
||||||
|
|
||||||
|
|
||||||
const PRHero = React.createClass({
|
const PRHero = React.createClass({
|
||||||
getInitialState() {
|
propTypes: {
|
||||||
return UserStore.getState();
|
currentUser: React.PropTypes.shape({
|
||||||
},
|
email: React.PropTypes.object
|
||||||
|
})
|
||||||
componentDidMount() {
|
|
||||||
UserStore.listen(this.onChange);
|
|
||||||
UserActions.fetchCurrentUser.defer();
|
|
||||||
},
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
UserStore.unlisten(this.onChange);
|
|
||||||
},
|
|
||||||
|
|
||||||
onChange(state) {
|
|
||||||
this.setState(state);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { currentUser } = this.state;
|
const { currentUser } = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="piece--hero">
|
<div className="piece--hero">
|
||||||
|
@ -6,6 +6,8 @@ import GlobalNotification from '../../../global_notification';
|
|||||||
import Hero from './components/pr_hero';
|
import Hero from './components/pr_hero';
|
||||||
import Header from '../../../header';
|
import Header from '../../../header';
|
||||||
|
|
||||||
|
import EventActions from '../../../../actions/event_actions';
|
||||||
|
|
||||||
import UserStore from '../../../../stores/user_store';
|
import UserStore from '../../../../stores/user_store';
|
||||||
import UserActions from '../../../../actions/user_actions';
|
import UserActions from '../../../../actions/user_actions';
|
||||||
|
|
||||||
@ -30,6 +32,19 @@ let PRApp = React.createClass({
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
UserStore.listen(this.onChange);
|
UserStore.listen(this.onChange);
|
||||||
UserActions.fetchCurrentUser();
|
UserActions.fetchCurrentUser();
|
||||||
|
|
||||||
|
if (this.state.currentUser && this.state.currentUser.email) {
|
||||||
|
EventActions.profileDidLoad.defer(this.state.currentUser);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillUpdate(nextProps, nextState) {
|
||||||
|
const { currentUser: { email: curEmail } = {} } = this.state;
|
||||||
|
const { currentUser: { email: nextEmail } = {} } = nextState;
|
||||||
|
|
||||||
|
if (nextEmail && curEmail !== nextEmail) {
|
||||||
|
EventActions.profileDidLoad.defer(nextState.currentUser);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
@ -49,7 +64,7 @@ let PRApp = React.createClass({
|
|||||||
|
|
||||||
|
|
||||||
if (currentUser && currentUser.email && history.isActive(`/pieces/${getCookie(currentUser.email)}`)) {
|
if (currentUser && currentUser.email && history.isActive(`/pieces/${getCookie(currentUser.email)}`)) {
|
||||||
header = <Hero />;
|
header = <Hero currentUser={currentUser} />;
|
||||||
style = { paddingTop: '0 !important' };
|
style = { paddingTop: '0 !important' };
|
||||||
} else if(currentUser && (currentUser.is_admin || currentUser.is_jury || currentUser.is_judge)) {
|
} else if(currentUser && (currentUser.is_admin || currentUser.is_jury || currentUser.is_judge)) {
|
||||||
header = <Header routes={routes} />;
|
header = <Header routes={routes} />;
|
||||||
|
@ -145,4 +145,10 @@ $pr--button-color: $pr--nav-fg-prim-color;
|
|||||||
text-transform: capitalize;
|
text-transform: capitalize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// intercom
|
||||||
|
#intercom-container .intercom-launcher-button {
|
||||||
|
background-color: $pr--button-color !important;
|
||||||
|
border-color: $pr--button-color !important;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user