1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 13:41:57 +02:00
onion/js/stores/global_notification_store.js

41 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-06-08 18:14:25 +02:00
'use strict';
import alt from '../alt';
import GlobalNotificationActions from '../actions/global_notification_actions';
class GlobalNotificationStore {
constructor() {
this.notificationQue = [];
2015-06-08 18:14:25 +02:00
this.bindActions(GlobalNotificationActions);
}
onAppendGlobalNotification(newNotification) {
let notificationDelay = 0;
for(let i = 0; i < this.notificationQue.length; i++) {
notificationDelay += this.notificationQue[i].dismissAfter;
2015-06-08 18:14:25 +02:00
}
this.notificationQue.push(newNotification);
setTimeout(GlobalNotificationActions.emulateEmptyStore, notificationDelay + newNotification.dismissAfter);
2015-06-08 18:14:25 +02:00
}
onEmulateEmptyStore() {
let actualNotificitionQue = this.notificationQue.slice();
this.notificationQue = [];
setTimeout(() => {
this.notificationQue = actualNotificitionQue.slice();
GlobalNotificationActions.shiftGlobalNotification();
}, 400);
}
onShiftGlobalNotification() {
this.notificationQue.shift();
2015-06-08 18:14:25 +02:00
}
}
2015-06-15 08:44:44 +02:00
export default alt.createStore(GlobalNotificationStore, 'GlobalNotificationStore');