You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ngcp-csc-ui/src/store/call-blocking.js

60 lines
1.7 KiB

'use strict';
import _ from 'lodash';
import { enableIncomingCallBlocking,
disableIncomingCallBlocking,
getIncomingCallBlocking
} from '../api/call-blocking';
export default {
namespaced: true,
state: {
incomingEnabled: false,
incomingList: []
},
getters: {},
mutations: {
enableIncoming (state) {
state.incomingEnabled = true;
},
disableIncoming (state) {
state.incomingEnabled = false;
},
loadIncoming(state, options) {
state.incomingEnabled = options.enabled;
}
},
actions: {
toggleIncoming(context, enabled) {
return new Promise((resolve, reject)=>{
if(enabled) {
enableIncomingCallBlocking(localStorage.getItem('subscriberId')).then(()=>{
context.commit('enableIncoming');
resolve();
}).catch((err)=>{
reject(err);
});
} else {
disableIncomingCallBlocking(localStorage.getItem('subscriberId')).then(()=>{
context.commit('disableIncoming');
resolve();
}).catch((err)=>{
reject(err);
});
}
});
},
loadIncoming(context) {
return new Promise((resolve, reject)=>{
getIncomingCallBlocking(localStorage.getItem('subscriberId')).then((result)=>{
context.commit('loadIncoming', result);
resolve();
}).catch((err)=>{
reject(err);
});
});
}
}
};