antares/src/renderer/store/modules/notifications.store.js

31 lines
741 B
JavaScript

'use strict';
import { uidGen } from 'common/libs/utilities';
export default {
namespaced: true,
strict: true,
state: {
notifications: []
},
getters: {
getNotifications: state => state.notifications
},
mutations: {
ADD_NOTIFICATION (state, payload) {
state.notifications.unshift(payload);
},
REMOVE_NOTIFICATION (state, uid) {
state.notifications = state.notifications.filter(item => item.uid !== uid);
}
},
actions: {
addNotification ({ commit }, payload) {
payload.uid = uidGen();
commit('ADD_NOTIFICATION', payload);
},
removeNotification ({ commit }, uid) {
commit('REMOVE_NOTIFICATION', uid);
}
}
};