mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 09:35:10 +01:00
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
import alt from '../alt';
|
|
|
|
import GlobalNotificationActions from '../actions/global_notification_actions';
|
|
|
|
class GlobalNotificationStore {
|
|
constructor() {
|
|
this.notificationQue = [];
|
|
|
|
this.bindActions(GlobalNotificationActions);
|
|
}
|
|
|
|
onAppendGlobalNotification(newNotification) {
|
|
let notificationDelay = 0;
|
|
for(let i = 0; i < this.notificationQue.length; i++) {
|
|
notificationDelay += this.notificationQue[i].dismissAfter;
|
|
}
|
|
|
|
this.notificationQue.push(newNotification);
|
|
setTimeout(GlobalNotificationActions.emulateEmptyStore, notificationDelay + newNotification.dismissAfter);
|
|
}
|
|
|
|
onEmulateEmptyStore() {
|
|
let actualNotificitionQue = this.notificationQue.slice();
|
|
|
|
this.notificationQue = [];
|
|
|
|
setTimeout(() => {
|
|
this.notificationQue = actualNotificitionQue.slice();
|
|
GlobalNotificationActions.shiftGlobalNotification();
|
|
}, 400);
|
|
}
|
|
|
|
onShiftGlobalNotification() {
|
|
this.notificationQue.shift();
|
|
}
|
|
}
|
|
|
|
export default alt.createStore(GlobalNotificationStore, 'GlobalNotificationStore');
|