signal-desktop/js/models/blockedNumbers.js

31 lines
766 B
JavaScript
Raw Normal View History

/* global storage, _ */
// eslint-disable-next-line func-names
2018-04-27 21:25:04 +00:00
(function() {
'use strict';
storage.isBlocked = number => {
const numbers = storage.get('blocked', []);
2018-04-27 21:25:04 +00:00
return _.include(numbers, number);
};
storage.addBlockedNumber = number => {
const numbers = storage.get('blocked', []);
2018-04-27 21:25:04 +00:00
if (_.include(numbers, number)) {
return;
}
window.log.info('adding', number, 'to blocked list');
2018-04-27 21:25:04 +00:00
storage.put('blocked', numbers.concat(number));
};
storage.removeBlockedNumber = number => {
const numbers = storage.get('blocked', []);
2018-04-27 21:25:04 +00:00
if (!_.include(numbers, number)) {
return;
}
window.log.info('removing', number, 'from blocked list');
2018-04-27 21:25:04 +00:00
storage.put('blocked', _.without(numbers, number));
};
})();