@marcoappio/marco-config 2.0.480 → 2.0.482

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.
@@ -1 +1 @@
1
- {"version":3,"file":"threadMutators.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/threadMutators/threadMutators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,KAAK,KAAK,CAAC,MAAM,SAAS,CAAA;AAEjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC9E,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAiB,MAAM,qBAAqB,CAAA;AAEnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAEhE,MAAM,MAAM,sBAAsB,GAAG;KAClC,CAAC,IAAI,MAAM,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAC1C,IAAI,EAAE,CAAC,CAAC,WAAW,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,KAC1D,OAAO,CAAC,IAAI,CAAC;CACnB,CAAA;AAKD,eAAO,MAAM,cAAc,OACrB,WAAW,CAAC,eAAe,CAAC,YACtB,MAAM,oBACE,eAAe,KAChC,OAAO,CAAC,kBAAkB,EAAE,CA0G9B,CAAA;AAED,eAAO,MAAM,oBAAoB,cACpB,QAAQ,GAAG,SAAS,cACnB,sBAAsB,KACjC,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAkQxC,CAAA"}
1
+ {"version":3,"file":"threadMutators.d.ts","sourceRoot":"","sources":["../../../../src/zero/mutators/threadMutators/threadMutators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,KAAK,KAAK,CAAC,MAAM,SAAS,CAAA;AAEjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC9E,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAiB,MAAM,qBAAqB,CAAA;AAEnF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAC3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAEhE,MAAM,MAAM,sBAAsB,GAAG;KAClC,CAAC,IAAI,MAAM,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAC1C,IAAI,EAAE,CAAC,CAAC,WAAW,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,KAC1D,OAAO,CAAC,IAAI,CAAC;CACnB,CAAA;AAKD,eAAO,MAAM,cAAc,OACrB,WAAW,CAAC,eAAe,CAAC,YACtB,MAAM,oBACE,eAAe,KAChC,OAAO,CAAC,kBAAkB,EAAE,CAsG9B,CAAA;AAED,eAAO,MAAM,oBAAoB,cACpB,QAAQ,GAAG,SAAS,cACnB,sBAAsB,KACjC,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAoQxC,CAAA"}
@@ -6,26 +6,22 @@ export const setSystemLabel = async (tx, threadId, targetSpecialUse) => {
6
6
  if (!thread) {
7
7
  throw new Error(MutationError.ENTITY_NOT_FOUND);
8
8
  }
9
- const targetLabel = await tx.query.accountLabel
10
- .where('accountId', thread.accountId)
11
- .where('specialUse', targetSpecialUse)
12
- .one()
13
- .run();
9
+ const [targetLabel, threadLabels] = await Promise.all([
10
+ tx.query.accountLabel.where('accountId', thread.accountId).where('specialUse', targetSpecialUse).one().run(),
11
+ tx.query.threadLabel.where('threadId', threadId).run(),
12
+ ]);
14
13
  if (!targetLabel) {
15
14
  throw new Error(MutationError.ENTITY_NOT_FOUND);
16
15
  }
17
- const threadLabels = await tx.query.threadLabel.where('threadId', threadId).run();
16
+ const currentLabelIds = new Set(threadsUtils.parseLabelIdList(thread.labelIdList));
17
+ const hasTarget = currentLabelIds.has(targetLabel.id);
18
+ const labelIdsToRemove = new Set(currentLabelIds);
19
+ labelIdsToRemove.delete(targetLabel.id);
18
20
  const sourceLocations = [];
19
- const labelsToDelete = [];
20
- const labelIdsToRemove = new Set();
21
- let hasTarget = false;
21
+ const threadLabelDeletePromises = [];
22
22
  for (const label of threadLabels) {
23
- if (label.labelId === targetLabel.id) {
24
- hasTarget = true;
23
+ if (label.labelId === targetLabel.id)
25
24
  continue;
26
- }
27
- labelsToDelete.push(label);
28
- labelIdsToRemove.add(label.labelId);
29
25
  if (label.uid > 0 && label.uidValidity > 0) {
30
26
  sourceLocations.push({
31
27
  labelId: label.labelId,
@@ -34,35 +30,28 @@ export const setSystemLabel = async (tx, threadId, targetSpecialUse) => {
34
30
  uidValidity: label.uidValidity,
35
31
  });
36
32
  }
37
- }
38
- for (const label of labelsToDelete) {
39
- await tx.mutate.threadLabel.delete({
33
+ threadLabelDeletePromises.push(tx.mutate.threadLabel.delete({
40
34
  accountId: thread.accountId,
41
35
  labelId: label.labelId,
42
36
  threadMessageId: label.threadMessageId,
43
- });
44
- }
45
- for (const labelId of labelIdsToRemove) {
46
- await tx.mutate.threadByLabel.delete({
47
- labelId,
48
- threadId,
49
- });
37
+ }));
50
38
  }
39
+ await Promise.all([
40
+ ...threadLabelDeletePromises,
41
+ ...[...labelIdsToRemove].map(labelId => tx.mutate.threadByLabel.delete({ labelId, threadId })),
42
+ ]);
51
43
  if (thread.seen === false && labelIdsToRemove.size > 0) {
52
44
  const labelsToUpdate = await tx.query.accountLabel.where('id', 'IN', [...labelIdsToRemove]).run();
53
- for (const label of labelsToUpdate) {
54
- await tx.mutate.accountLabel.update({
55
- id: label.id,
56
- unreadCount: Math.max(0, (label.unreadCount ?? 0) - 1),
57
- });
58
- }
45
+ await Promise.all(labelsToUpdate.map(label => tx.mutate.accountLabel.update({
46
+ id: label.id,
47
+ unreadCount: Math.max(0, (label.unreadCount ?? 0) - 1),
48
+ })));
59
49
  }
60
50
  if (!hasTarget) {
61
51
  const messages = await tx.query.threadMessage.where('threadId', threadId).run();
62
52
  const baseTimestamp = Date.now();
63
- for (let i = 0; i < messages.length; i++) {
64
- const message = messages[i];
65
- await tx.mutate.threadLabel.insert({
53
+ await Promise.all([
54
+ ...messages.map((message, i) => tx.mutate.threadLabel.insert({
66
55
  accountId: thread.accountId,
67
56
  labelId: targetLabel.id,
68
57
  lastSyncedAt: 0,
@@ -70,19 +59,21 @@ export const setSystemLabel = async (tx, threadId, targetSpecialUse) => {
70
59
  threadMessageId: message.id,
71
60
  uid: -(baseTimestamp + i),
72
61
  uidValidity: targetLabel.uidValidity ?? 0,
73
- });
74
- }
75
- await tx.mutate.threadByLabel.insert({
76
- labelId: targetLabel.id,
77
- latestMessageDate: thread.latestMessageDate,
78
- threadId,
79
- });
80
- if (thread.seen === false) {
81
- await tx.mutate.accountLabel.update({
82
- id: targetLabel.id,
83
- unreadCount: (targetLabel.unreadCount ?? 0) + 1,
84
- });
85
- }
62
+ })),
63
+ tx.mutate.threadByLabel.insert({
64
+ labelId: targetLabel.id,
65
+ latestMessageDate: thread.latestMessageDate,
66
+ threadId,
67
+ }),
68
+ ...(thread.seen === false
69
+ ? [
70
+ tx.mutate.accountLabel.update({
71
+ id: targetLabel.id,
72
+ unreadCount: (targetLabel.unreadCount ?? 0) + 1,
73
+ }),
74
+ ]
75
+ : []),
76
+ ]);
86
77
  }
87
78
  await tx.mutate.thread.update({
88
79
  id: threadId,
@@ -97,53 +88,45 @@ export const createThreadMutators = (_authData, callbacks) => ({
97
88
  if (!thread) {
98
89
  throw new Error(MutationError.ENTITY_NOT_FOUND);
99
90
  }
100
- const label = await tx.query.accountLabel
101
- .where('accountId', thread.accountId)
102
- .where('path', args.labelPath)
103
- .one()
104
- .run();
91
+ const [label, existingThreadByLabel, messages] = await Promise.all([
92
+ tx.query.accountLabel.where('accountId', thread.accountId).where('path', args.labelPath).one().run(),
93
+ tx.query.threadByLabel.where('labelId', args.labelPath).where('threadId', threadId).one().run(),
94
+ tx.query.threadMessage.where('threadId', threadId).run(),
95
+ ]);
105
96
  if (!label) {
106
97
  throw new Error(MutationError.ENTITY_NOT_FOUND);
107
98
  }
108
- const existingThreadByLabel = await tx.query.threadByLabel
109
- .where('labelId', label.id)
110
- .where('threadId', threadId)
111
- .one()
112
- .run();
113
- if (!existingThreadByLabel) {
114
- await tx.mutate.threadByLabel.insert({
115
- labelId: label.id,
116
- latestMessageDate: thread.latestMessageDate,
117
- threadId,
118
- });
119
- if (thread.seen === false) {
120
- await tx.mutate.accountLabel.update({
121
- id: label.id,
122
- unreadCount: (label.unreadCount ?? 0) + 1,
123
- });
124
- }
125
- }
126
- const messages = await tx.query.threadMessage.where('threadId', threadId).run();
127
- const baseTimestamp = Date.now();
128
- let insertIndex = 0;
129
- for (const message of messages) {
130
- const existing = await tx.query.threadLabel
131
- .where('threadMessageId', message.id)
132
- .where('labelId', label.id)
133
- .one()
134
- .run();
135
- if (!existing) {
136
- await tx.mutate.threadLabel.insert({
137
- accountId: thread.accountId,
99
+ const currentLabelIds = new Set(threadsUtils.parseLabelIdList(thread.labelIdList));
100
+ if (!existingThreadByLabel && !currentLabelIds.has(label.id)) {
101
+ await Promise.all([
102
+ tx.mutate.threadByLabel.insert({
138
103
  labelId: label.id,
139
- lastSyncedAt: 0,
104
+ latestMessageDate: thread.latestMessageDate,
140
105
  threadId,
141
- threadMessageId: message.id,
142
- uid: -(baseTimestamp + insertIndex),
143
- uidValidity: label.uidValidity ?? 0,
144
- });
145
- insertIndex++;
146
- }
106
+ }),
107
+ ...(thread.seen === false
108
+ ? [
109
+ tx.mutate.accountLabel.update({
110
+ id: label.id,
111
+ unreadCount: (label.unreadCount ?? 0) + 1,
112
+ }),
113
+ ]
114
+ : []),
115
+ ]);
116
+ }
117
+ const existingChecks = await Promise.all(messages.map(message => tx.query.threadLabel.where('threadMessageId', message.id).where('labelId', label.id).one().run()));
118
+ const messagesToInsert = messages.filter((_, i) => !existingChecks[i]);
119
+ const baseTimestamp = Date.now();
120
+ if (messagesToInsert.length > 0) {
121
+ await Promise.all(messagesToInsert.map((message, i) => tx.mutate.threadLabel.insert({
122
+ accountId: thread.accountId,
123
+ labelId: label.id,
124
+ lastSyncedAt: 0,
125
+ threadId,
126
+ threadMessageId: message.id,
127
+ uid: -(baseTimestamp + i),
128
+ uidValidity: label.uidValidity ?? 0,
129
+ })));
147
130
  }
148
131
  const allLabels = await tx.query.threadLabel.where('threadId', threadId).run();
149
132
  await tx.mutate.thread.update({
@@ -161,12 +144,10 @@ export const createThreadMutators = (_authData, callbacks) => ({
161
144
  const labelIds = threadsUtils.parseLabelIdList(thread.labelIdList);
162
145
  if (labelIds.length > 0) {
163
146
  const labels = await tx.query.accountLabel.where('id', 'IN', labelIds).run();
164
- for (const label of labels) {
165
- await tx.mutate.accountLabel.update({
166
- id: label.id,
167
- unreadCount: Math.max(0, (label.unreadCount ?? 0) - 1),
168
- });
169
- }
147
+ await Promise.all(labels.map(label => tx.mutate.accountLabel.update({
148
+ id: label.id,
149
+ unreadCount: Math.max(0, (label.unreadCount ?? 0) - 1),
150
+ })));
170
151
  }
171
152
  }
172
153
  await tx.mutate.thread.delete({
@@ -183,19 +164,18 @@ export const createThreadMutators = (_authData, callbacks) => ({
183
164
  if (!thread) {
184
165
  throw new Error(MutationError.ENTITY_NOT_FOUND);
185
166
  }
186
- const label = await tx.query.accountLabel
187
- .where('accountId', thread.accountId)
188
- .where('path', args.labelPath)
189
- .one()
190
- .run();
167
+ const [label, existingLabels] = await Promise.all([
168
+ tx.query.accountLabel.where('accountId', thread.accountId).where('path', args.labelPath).one().run(),
169
+ tx.query.threadLabel.where('threadId', threadId).run(),
170
+ ]);
191
171
  if (!label) {
192
172
  throw new Error(MutationError.ENTITY_NOT_FOUND);
193
173
  }
194
- const existingLabels = await tx.query.threadLabel.where('threadId', threadId).where('labelId', label.id).run();
195
- if (existingLabels.length === 0) {
174
+ const labelsForThisLabel = existingLabels.filter(x => x.labelId === label.id);
175
+ if (labelsForThisLabel.length === 0) {
196
176
  throw new Error(MutationError.ENTITY_NOT_FOUND);
197
177
  }
198
- for (const existing of existingLabels) {
178
+ for (const existing of labelsForThisLabel) {
199
179
  if (existing.uid > 0 && existing.uidValidity > 0) {
200
180
  allSourceLocations.push({
201
181
  labelId: existing.labelId,
@@ -204,52 +184,53 @@ export const createThreadMutators = (_authData, callbacks) => ({
204
184
  uidValidity: existing.uidValidity,
205
185
  });
206
186
  }
207
- await tx.mutate.threadLabel.delete({
187
+ }
188
+ const currentLabelIds = new Set(threadsUtils.parseLabelIdList(thread.labelIdList));
189
+ currentLabelIds.delete(label.id);
190
+ await Promise.all([
191
+ ...labelsForThisLabel.map(existing => tx.mutate.threadLabel.delete({
208
192
  accountId: thread.accountId,
209
193
  labelId: label.id,
210
194
  threadMessageId: existing.threadMessageId,
211
- });
212
- }
213
- await tx.mutate.threadByLabel.delete({
214
- labelId: label.id,
215
- threadId,
216
- });
217
- if (thread.seen === false) {
218
- await tx.mutate.accountLabel.update({
219
- id: label.id,
220
- unreadCount: Math.max(0, (label.unreadCount ?? 0) - 1),
221
- });
222
- }
223
- const remainingLabels = await tx.query.threadLabel.where('threadId', threadId).run();
224
- await tx.mutate.thread.update({
225
- id: threadId,
226
- labelIdList: buildLabelIdList([...new Set(remainingLabels.map(x => x.labelId))]),
227
- });
195
+ })),
196
+ tx.mutate.threadByLabel.delete({
197
+ labelId: label.id,
198
+ threadId,
199
+ }),
200
+ ...(thread.seen === false
201
+ ? [
202
+ tx.mutate.accountLabel.update({
203
+ id: label.id,
204
+ unreadCount: Math.max(0, (label.unreadCount ?? 0) - 1),
205
+ }),
206
+ ]
207
+ : []),
208
+ tx.mutate.thread.update({
209
+ id: threadId,
210
+ labelIdList: buildLabelIdList([...currentLabelIds]),
211
+ }),
212
+ ]);
228
213
  }
229
214
  callbacks?.removeLabel?.({ ...args, sourceLocations: allSourceLocations });
230
215
  },
231
216
  setArchive: async (tx, args) => {
232
217
  const allSourceLocations = [];
233
218
  for (const threadId of args.threadIds) {
234
- const sourceLocations = await setSystemLabel(tx, threadId, 'ARCHIVE');
235
- allSourceLocations.push(...sourceLocations);
219
+ allSourceLocations.push(...(await setSystemLabel(tx, threadId, 'ARCHIVE')));
236
220
  }
237
221
  callbacks?.setArchive?.({ ...args, sourceLocations: allSourceLocations });
238
222
  },
239
223
  setFlagged: async (tx, args) => {
240
- for (const threadId of args.threadIds) {
241
- await tx.mutate.thread.update({
242
- flagged: args.flagged,
243
- id: threadId,
244
- });
245
- }
224
+ await Promise.all(args.threadIds.map(threadId => tx.mutate.thread.update({
225
+ flagged: args.flagged,
226
+ id: threadId,
227
+ })));
246
228
  callbacks?.setFlagged?.(args);
247
229
  },
248
230
  setInbox: async (tx, args) => {
249
231
  const allSourceLocations = [];
250
232
  for (const threadId of args.threadIds) {
251
- const sourceLocations = await setSystemLabel(tx, threadId, 'INBOX');
252
- allSourceLocations.push(...sourceLocations);
233
+ allSourceLocations.push(...(await setSystemLabel(tx, threadId, 'INBOX')));
253
234
  }
254
235
  callbacks?.setInbox?.({ ...args, sourceLocations: allSourceLocations });
255
236
  },
@@ -266,37 +247,30 @@ export const createThreadMutators = (_authData, callbacks) => ({
266
247
  if (labelCounts.size > 0) {
267
248
  const labels = await tx.query.accountLabel.where('id', 'IN', [...labelCounts.keys()]).run();
268
249
  const delta = args.seen ? -1 : 1;
269
- for (const label of labels) {
270
- const threadCount = labelCounts.get(label.id);
271
- if (threadCount) {
272
- await tx.mutate.accountLabel.update({
273
- id: label.id,
274
- unreadCount: Math.max(0, (label.unreadCount ?? 0) + delta * threadCount),
275
- });
276
- }
277
- }
278
- }
279
- for (const threadId of args.threadIds) {
280
- await tx.mutate.thread.update({
281
- id: threadId,
282
- seen: args.seen,
283
- });
250
+ await Promise.all(labels
251
+ .filter(label => labelCounts.has(label.id))
252
+ .map(label => tx.mutate.accountLabel.update({
253
+ id: label.id,
254
+ unreadCount: Math.max(0, (label.unreadCount ?? 0) + delta * (labelCounts.get(label.id) ?? 0)),
255
+ })));
284
256
  }
257
+ await Promise.all(args.threadIds.map(threadId => tx.mutate.thread.update({
258
+ id: threadId,
259
+ seen: args.seen,
260
+ })));
285
261
  callbacks?.setSeen?.(args);
286
262
  },
287
263
  setSpam: async (tx, args) => {
288
264
  const allSourceLocations = [];
289
265
  for (const threadId of args.threadIds) {
290
- const sourceLocations = await setSystemLabel(tx, threadId, 'SPAM');
291
- allSourceLocations.push(...sourceLocations);
266
+ allSourceLocations.push(...(await setSystemLabel(tx, threadId, 'SPAM')));
292
267
  }
293
268
  callbacks?.setSpam?.({ ...args, sourceLocations: allSourceLocations });
294
269
  },
295
270
  setTrash: async (tx, args) => {
296
271
  const allSourceLocations = [];
297
272
  for (const threadId of args.threadIds) {
298
- const sourceLocations = await setSystemLabel(tx, threadId, 'TRASH');
299
- allSourceLocations.push(...sourceLocations);
273
+ allSourceLocations.push(...(await setSystemLabel(tx, threadId, 'TRASH')));
300
274
  }
301
275
  callbacks?.setTrash?.({ ...args, sourceLocations: allSourceLocations });
302
276
  },
@@ -30,6 +30,9 @@ describe('threadMutators', () => {
30
30
  if (field === 'threadId') {
31
31
  return { run: runAllThreadLabels, where: whereLabelId };
32
32
  }
33
+ if (field === 'threadMessageId') {
34
+ return { where: whereLabelId };
35
+ }
33
36
  return { where: whereLabelId };
34
37
  });
35
38
  const threadLabelInsert = mock(async () => { });
@@ -232,11 +235,10 @@ describe('threadMutators', () => {
232
235
  const whereLabelPath = mock(() => ({ one: oneLabel }));
233
236
  const whereLabelAccount = mock(() => ({ where: whereLabelPath }));
234
237
  const runExisting = mock(async () => existingRecords);
235
- const runRemainingLabels = mock(async () => []);
236
238
  const whereLabelId = mock(() => ({ run: runExisting }));
237
239
  const whereThreadLabel = mock((field) => {
238
240
  if (field === 'threadId') {
239
- return { run: runRemainingLabels, where: whereLabelId };
241
+ return { run: runExisting, where: whereLabelId };
240
242
  }
241
243
  return { where: whereLabelId };
242
244
  });
@@ -1 +1 @@
1
- {"version":3,"file":"getThreadList.d.ts","sourceRoot":"","sources":["../../../src/zero/queries/getThreadList.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAOlE,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE;QACN,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;QACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;QACvB,IAAI,CAAC,EAAE,OAAO,CAAA;KACf,CAAA;CACF,CAAA;AAoBD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
  };
22
22
  export const getThreadList = syncedQueryWithContext('getThreadList', parseArgs, ({ userId }, { labelIds, search, limit, where }) => {
23
- const [primaryLabelId, ...additionalLabelIds] = labelIds;
24
- let query = z.threadByLabel
25
- .where('labelId', primaryLabelId)
23
+ const query = z.threadByLabel
24
+ .where('labelId', 'IN', labelIds)
26
25
  .orderBy('latestMessageDate', 'desc')
27
26
  .limit(limit)
28
27
  .related('thread', t => {
@@ -56,8 +55,5 @@ export const getThreadList = syncedQueryWithContext('getThreadList', parseArgs,
56
55
  }
57
56
  return threadQuery;
58
57
  });
59
- for (const additionalLabelId of additionalLabelIds) {
60
- query = query.whereExists('thread', x => x.whereExists('threadByLabel', y => y.where('labelId', additionalLabelId)));
61
- }
62
58
  return query;
63
59
  });
@@ -1 +1 @@
1
- {"version":3,"file":"getThreads.d.ts","sourceRoot":"","sources":["../../../src/zero/queries/getThreads.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAA;AAOlE,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE;QACN,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;QACrB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;QACvB,IAAI,CAAC,EAAE,OAAO,CAAA;KACf,CAAA;CACF,CAAA;AAoBD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDtB,CAAA"}
@@ -20,9 +20,8 @@ const parseArgs = (args) => {
20
20
  return [v.parse(schema, args[0])];
21
21
  };
22
22
  export const getThreads = syncedQueryWithContext('getThreads', parseArgs, ({ userId }, { labelIds, search, limit, where }) => {
23
- const [primaryLabelId, ...additionalLabelIds] = labelIds;
24
- let query = z.threadByLabel
25
- .where('labelId', primaryLabelId)
23
+ const query = z.threadByLabel
24
+ .where('labelId', 'IN', labelIds)
26
25
  .orderBy('latestMessageDate', 'desc')
27
26
  .limit(limit)
28
27
  .related('thread', t => {
@@ -56,8 +55,5 @@ export const getThreads = syncedQueryWithContext('getThreads', parseArgs, ({ use
56
55
  }
57
56
  return threadQuery;
58
57
  });
59
- for (const additionalLabelId of additionalLabelIds) {
60
- query = query.whereExists('thread', x => x.whereExists('threadByLabel', y => y.where('labelId', additionalLabelId)));
61
- }
62
58
  return query;
63
59
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marcoappio/marco-config",
3
- "version": "2.0.480",
3
+ "version": "2.0.482",
4
4
  "author": "team@marcoapp.io",
5
5
  "main": "dist/index.js",
6
6
  "repository": "git@github.com:marcoappio/marco-config.git",