mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
40 lines
903 B
JavaScript
40 lines
903 B
JavaScript
'use strict';
|
|
|
|
import { altThirdParty } from '../alt';
|
|
import EventActions from '../actions/event_actions';
|
|
|
|
import { getSubdomain } from '../utils/general_utils';
|
|
|
|
|
|
class IntercomHandler {
|
|
constructor() {
|
|
this.bindActions(EventActions);
|
|
this.loaded = false;
|
|
}
|
|
|
|
onUserDidAuthenticate(user) {
|
|
if (this.loaded) {
|
|
return;
|
|
}
|
|
|
|
window.Intercom('boot', {
|
|
app_id: 'oboxh5w1',
|
|
email: user.email,
|
|
subdomain: getSubdomain(),
|
|
widget: {
|
|
activator: '#IntercomDefaultWidget'
|
|
}
|
|
});
|
|
console.log('Intercom loaded');
|
|
this.loaded = true;
|
|
}
|
|
|
|
onUserDidLogout() {
|
|
// kill intercom (with fire)
|
|
window.Intercom('shutdown');
|
|
this.loaded = false;
|
|
}
|
|
}
|
|
|
|
export default altThirdParty.createStore(IntercomHandler, 'IntercomHandler');
|