imdone-core 1.53.16 → 1.53.18

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.
package/lib/project.js CHANGED
@@ -98,6 +98,14 @@ module.exports = class WorkerProject extends Project {
98
98
 
99
99
  if (!cb) return promise
100
100
  }
101
+
102
+ initIndexes(allLists) {
103
+ allLists.forEach((list) => {
104
+ list.tasks.filter(list => !list.filter).forEach((task, index) => {
105
+ task.index = index
106
+ })
107
+ })
108
+ }
101
109
 
102
110
  // HACK To handle circular dependency issue with file
103
111
  // <!--
@@ -107,17 +115,23 @@ module.exports = class WorkerProject extends Project {
107
115
  return { path: this.path }
108
116
  }
109
117
 
110
- getListsForImdoneJSON(totals) {
111
- return this.allLists.map((list) => {
118
+ getListsForImdoneJSON() {
119
+ this.initIndexes(this.repo.getTasksByList())
120
+ let allLists = this.getLists({
121
+ populateFiltered: true,
122
+ })
123
+ const totals = calculateTotals(allLists)
124
+ allLists = allLists.map((list) => {
112
125
  list = { ...list }
113
126
  list.tasks = list.tasks.map((card, index) => {
114
127
  card.interpretedContent = ''
115
128
  card.totals = totals
116
- card.index = index
117
129
  return card
118
130
  })
119
131
  return list
120
132
  })
133
+
134
+ return { allLists, totals }
121
135
  }
122
136
 
123
137
  getInitializedCards(allLists, totals) {
@@ -133,36 +147,38 @@ module.exports = class WorkerProject extends Project {
133
147
  this.pluginManager.initDevMode()
134
148
  console.time('toJSON time')
135
149
  this._updatedAt = new Date()
136
- const totals = calculateTotals(
137
- this.getLists({
138
- populateFiltered: true,
139
- })
140
- )
141
- const allLists = this.getListsForImdoneJSON(totals)
150
+ const { allLists , totals } = this.getListsForImdoneJSON()
142
151
 
143
- console.time('plugin onBeforeBoardUpdate')
152
+ console.time('plugin onBeforeBoardUpdate time')
144
153
  await this.pluginManager.onBeforeBoardUpdate()
145
- console.timeEnd('plugin onBeforeBoardUpdate')
154
+ console.timeEnd('plugin onBeforeBoardUpdate time')
146
155
 
156
+ console.time('getBoardProperties time')
147
157
  const data = this.data = this.pluginManager.getBoardProperties()
158
+ console.timeEnd('getBoardProperties time')
159
+
160
+ console.time('getDataKeys time')
148
161
  const dataKeys = this.dataKays = this.getDataKeys(data)
162
+ console.timeEnd('getDataKeys time')
149
163
 
150
- console.time('card init')
164
+ console.time('card init time')
151
165
  const cards = this.getInitializedCards(allLists, totals)
152
- console.timeEnd('card init')
166
+ console.timeEnd('card init time')
153
167
 
154
- console.time('plugin onBoardUpdate')
155
- await this.pluginManager.onBoardUpdate(
156
- this.getLists({
157
- tasks: cards,
158
- })
159
- )
160
- console.timeEnd('plugin onBoardUpdate')
168
+ console.time('plugin onBoardUpdate time')
169
+ await this.pluginManager.onBoardUpdate(allLists)
170
+ console.timeEnd('plugin onBoardUpdate time')
171
+
172
+ console.time('getTags time')
173
+ const tags = this.getTags(cards)
174
+ console.timeEnd('getTags time')
161
175
 
162
- const lists = this.getLists({
176
+ console.time('getLists time')
177
+ const lists = this.filter ? this.getLists({
163
178
  tasks: this.getCards(this.filter, cards),
164
179
  populateFiltered: true,
165
- })
180
+ }) : allLists
181
+ console.timeEnd('getLists time')
166
182
 
167
183
  console.timeEnd('toJSON time')
168
184
  return {
@@ -172,7 +188,7 @@ module.exports = class WorkerProject extends Project {
172
188
  files: this.files,
173
189
  totals,
174
190
  totalCards: this.repo.getTasks().length,
175
- tags: this.getTags(),
191
+ tags,
176
192
  allMeta: this.allMeta,
177
193
  allContexts: this.allContexts,
178
194
  allTags: this.allTags,
@@ -186,7 +202,7 @@ module.exports = class WorkerProject extends Project {
186
202
  }
187
203
  }
188
204
 
189
- emit() {}
205
+ emit() {} // This is implemented in imdone UI worker
190
206
 
191
207
  emitUpdate() {
192
208
  this.emit('file.update')
@@ -263,8 +279,8 @@ module.exports = class WorkerProject extends Project {
263
279
  getLists(opts) {
264
280
  const {tasks = this.getDefaultFilteredCards(), populateFiltered = false} = opts || {}
265
281
  return Repository.getTasksByList(this.repo, tasks, true, populateFiltered)
266
- }
267
-
282
+ }
283
+
268
284
  getTaskQueryProps(props) {
269
285
  const queryProps = []
270
286
  if (props) {
@@ -328,15 +344,15 @@ module.exports = class WorkerProject extends Project {
328
344
  return this.getCards(filter, allTasks)
329
345
  }
330
346
 
331
- getCards(filter, tasks = this.getDefaultFilteredCards()) {
332
- tasks = filter ? this.filterCards(tasks, filter) : tasks
333
- return tasks
347
+ getCards(filter, cards = this.getDefaultFilteredCards()) {
348
+ cards = filter ? this.filterCards(cards, filter) : cards
349
+ return cards
334
350
  }
335
351
 
336
- filterCards(tasks, filter) {
352
+ filterCards(cards, filter) {
337
353
  const {
338
354
  result,
339
- } = Repository.filterCards(tasks, filter)
355
+ } = Repository.filterCards(cards, filter)
340
356
  return result
341
357
  }
342
358
 
package/lib/task.js CHANGED
@@ -70,7 +70,7 @@ class Task {
70
70
  this.content = obj.content
71
71
  this.lastLine = this.getLastLine()
72
72
  this.orderModified = obj.orderModified
73
- this.index = undefined
73
+ this.index = obj.index
74
74
  if (dontParse || !this.text) return
75
75
  this.parse()
76
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imdone-core",
3
- "version": "1.53.16",
3
+ "version": "1.53.18",
4
4
  "description": "imdone-core",
5
5
  "main": "index.js",
6
6
  "scripts": {