imdone-core 1.54.2 → 1.54.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -135,7 +135,7 @@ module.exports = function (repo, defaultSettings = defaultSettingsObject) {
135
135
  }
136
136
 
137
137
  // Remove settings.filteredLists
138
- if (config.settings.filteredLists && config.settings.filteredLists.length > 0) {
138
+ if (config.settings.filteredLists) {
139
139
  delete config.settings.filteredLists
140
140
  }
141
141
 
package/lib/project.js CHANGED
@@ -363,6 +363,7 @@ module.exports = class WorkerProject extends Project {
363
363
  }
364
364
 
365
365
  filterCards(cards, filter) {
366
+ this.hideLists = []
366
367
  const {
367
368
  result,
368
369
  hideLists
@@ -415,7 +416,6 @@ module.exports = class WorkerProject extends Project {
415
416
 
416
417
  set filter(filter) {
417
418
  this.innerFilter = filter
418
- this.hideLists = []
419
419
  }
420
420
 
421
421
  async addMetadata(task, key, value) {
package/lib/repository.js CHANGED
@@ -34,12 +34,10 @@ var _isFunction = require('lodash.isfunction'),
34
34
  newCard = require('./card'),
35
35
  { replaceDateLanguage } = require('./adapters/parsers/DateLanguageParser'),
36
36
  { getRawTask, isNumber, LIST_NAME_PATTERN } = require('./adapters/parsers/task/CardContentParser'),
37
- XRegExp = require('xregexp')
38
-
39
-
37
+ XRegExp = require('xregexp'),
38
+ promisify = require('util').promisify
40
39
 
41
40
  const appContext = require('./context/ApplicationContext')
42
- const get = require('lodash.get')
43
41
 
44
42
  var ERRORS = constants.ERRORS,
45
43
  DEFAULT_FILE_PATTERN = constants.DEFAULT_FILE_PATTERN,
@@ -212,24 +210,28 @@ Repository.prototype.addAllMeta = function (meta) {
212
210
  * @param {} list
213
211
  * @return
214
212
  */
215
- Repository.prototype.addList = function (list, cb) {
216
- cb = tools.cb(cb)
217
- if (this.listExists(list.name)) return cb()
218
- var self = this
219
- var fn = function (err) {
220
- if (!err) self.emit('list.modified', list)
221
- cb(err)
222
- }
223
- list = _omit(list, 'tasks')
224
- this.config.lists.push(new List(list))
225
- if (!list.filter && !/[a-z]/.test(list.name)) {
226
- const codeList = list.name.replace(/\s+/g, '-').toUpperCase()
227
- if (!this.config.code.include_lists.find((name) => name === codeList)) {
228
- this.config.code.include_lists.push(codeList)
213
+ Repository.prototype.addList = async function (list, cb) {
214
+ cb = tools.cb(cb);
215
+ if (this.listExists(list.name)) return cb();
216
+
217
+ try {
218
+ list = _omit(list, 'tasks');
219
+ this.config.lists.push(new List(list));
220
+
221
+ if (!list.filter && !/[a-z]/.test(list.name)) {
222
+ const codeList = list.name.replace(/\s+/g, '-').toUpperCase();
223
+ if (!this.config.code.include_lists.find((name) => name === codeList)) {
224
+ this.config.code.include_lists.push(codeList);
225
+ }
229
226
  }
227
+
228
+ await promisify(this.saveConfig).bind(this)();
229
+ this.emit('list.modified', list);
230
+ cb();
231
+ } catch (err) {
232
+ cb(err);
230
233
  }
231
- this.saveConfig(fn)
232
- }
234
+ };
233
235
 
234
236
  Repository.prototype.removeList = function (list, cb) {
235
237
  return new Promise((resolve, reject) => {
@@ -273,7 +275,7 @@ Repository.prototype.getConfig = function () {
273
275
  * @return MemberExpression
274
276
  */
275
277
  Repository.prototype.getLists = function () {
276
- return this.getConfig().lists
278
+ return this.getConfig().lists.map(obj => ({...obj}));
277
279
  }
278
280
 
279
281
  Repository.prototype.getVisibleLists = function () {
@@ -771,8 +773,8 @@ Repository.prototype.getList = function (name) {
771
773
  }
772
774
 
773
775
 
774
- Repository.prototype.getListById = function(id) {
775
- return this.getLists().find((list) => list.id === id)
776
+ Repository.prototype.getListById = function(id, lists = this.getLists()) {
777
+ return lists.find((list) => list.id === id)
776
778
  }
777
779
 
778
780
  Repository.prototype.hideList = function (name, cb) {
@@ -867,11 +869,11 @@ Repository.prototype.updateList = function(id, {name, filter}) {
867
869
  if (!filter && this.listExists(name)) return resolve()
868
870
 
869
871
  const lists = this.getLists()
870
- const list = this.getListById(id)
872
+ const list = this.getListById(id, lists)
871
873
  const oldName = list.name
872
874
  const oldFilter = list.filter
873
875
  list.name = name
874
- if (oldFilter) list.filter = filter
876
+ if (oldFilter) list.filter = filter
875
877
  this.setLists(lists)
876
878
 
877
879
  if (oldName === name || oldFilter) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imdone-core",
3
- "version": "1.54.2",
3
+ "version": "1.54.3",
4
4
  "description": "imdone-core",
5
5
  "main": "index.js",
6
6
  "bin": {