1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

include intercom

This commit is contained in:
Tim Daubenschütz 2015-07-14 21:47:14 +02:00
parent 5ae80efaa7
commit d183b9ba1c
2 changed files with 22 additions and 0 deletions

View File

@ -40,6 +40,15 @@
</head>
<body>
<div id="main"></div>
<!-- Intercom library -->
<script>
(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;
s.src='https://widget.intercom.io/widget/{app_id}';
var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()
</script>
<!-- actual app -->
<script src="<%= BASE_URL %>static/js/app.js"></script>
</body>
</html>

View File

@ -58,6 +58,8 @@ let Header = React.createClass({
handleLogout(){
UserActions.logoutCurrentUser();
Alt.flush();
// kill intercom (with fire)
window.Intercom('shutdown');
this.transitionTo('login');
},
@ -89,6 +91,17 @@ let Header = React.createClass({
},
onChange(state) {
this.setState(state);
if(this.state.currentUser && this.state.currentUser.email) {
// bootup intercom if the user is logged in
window.Intercom('boot', {
app_id: 'oboxh5w1',
email: this.state.currentUser.email,
widget: {
activator: '#IntercomDefaultWidget'
}
});
}
},
render() {