1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-29 00:58:03 +02:00
onion/js/third_party/notifications_handler.js

46 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2015-09-04 11:49:55 +02:00
'use strict';
import { altThirdParty } from '../alt';
import history from '../history';
2015-09-04 11:49:55 +02:00
import EventActions from '../actions/event_actions';
import NotificationActions from '../actions/notification_actions';
2016-06-13 17:33:47 +02:00
import { getCurrentSubdomain } from '../utils/url';
2015-09-04 11:49:55 +02:00
class NotificationsHandler {
constructor() {
this.bindActions(EventActions);
this.loaded = false;
}
onUserDidAuthenticate() {
2015-09-04 11:49:55 +02:00
if (this.loaded) {
return;
}
2016-06-13 17:33:47 +02:00
const subdomain = getCurrentSubdomain();
2015-09-04 11:49:55 +02:00
if (subdomain === 'ikonotv') {
NotificationActions.fetchContractAgreementListNotifications().then(
(res) => {
if (res.notifications && res.notifications.length > 0) {
console.log('Contractagreement notifications loaded');
this.loaded = true;
2016-01-11 17:52:32 +01:00
history.push('/contract_notifications');
2015-09-04 11:49:55 +02:00
}
}
);
}
this.loaded = true;
}
onUserDidLogout() {
this.loaded = false;
}
2015-09-04 11:49:55 +02:00
}
export default altThirdParty.createStore(NotificationsHandler, 'NotificationsHandler');