( draggedPath: string, targetPath: string, above: boolean, targetGroupKey: string | null, sourceGroupKey: string | null, targetVisiblePaths?: string[] )
| 1322 | } |
| 1323 | |
| 1324 | private async handleSortOrderDrop( |
| 1325 | draggedPath: string, |
| 1326 | targetPath: string, |
| 1327 | above: boolean, |
| 1328 | targetGroupKey: string | null, |
| 1329 | sourceGroupKey: string | null, |
| 1330 | targetVisiblePaths?: string[] |
| 1331 | ): Promise<void> { |
| 1332 | const groupByPropertyId = this.getGroupByPropertyId(); |
| 1333 | const reorderScopeKey = this.getReorderScopeQueueKey(targetGroupKey, groupByPropertyId); |
| 1334 | await this.dropQueue.enqueue(reorderScopeKey, async () => { |
| 1335 | const groupDropPlan = buildTaskListGroupDropPlan({ |
| 1336 | groupByPropertyId, |
| 1337 | sourceGroupKey, |
| 1338 | targetGroupKey, |
| 1339 | lookupMappingKey: (propertyName) => |
| 1340 | this.plugin.fieldMapper.lookupMappingKey(propertyName), |
| 1341 | isListTypeProperty: (propertyName) => this.isListTypeProperty(propertyName), |
| 1342 | }); |
| 1343 | |
| 1344 | if (groupDropPlan.isFormulaGrouping) { |
| 1345 | new Notice( |
| 1346 | this.plugin.i18n.translate("views.taskList.errors.formulaGroupingReadOnly") |
| 1347 | ); |
| 1348 | return; |
| 1349 | } |
| 1350 | |
| 1351 | // Compute sort_order first (read-only — no file writes yet) |
| 1352 | const sortOrderPlan = await prepareSortOrderUpdate( |
| 1353 | targetPath, |
| 1354 | above, |
| 1355 | targetGroupKey, |
| 1356 | groupDropPlan.cleanGroupBy, |
| 1357 | draggedPath, |
| 1358 | this.plugin, |
| 1359 | { |
| 1360 | taskInfoCache: this.taskInfoCache, |
| 1361 | visibleTaskPaths: |
| 1362 | targetVisiblePaths ?? this.getVisibleSortScopePaths(targetGroupKey), |
| 1363 | candidateTaskPaths: this.getCandidateSortScopePaths(targetGroupKey), |
| 1364 | } |
| 1365 | ); |
| 1366 | if (sortOrderPlan.sortOrder === null) return; |
| 1367 | |
| 1368 | const totalEditedNotes = sortOrderPlan.additionalWrites.length + 1; |
| 1369 | if (totalEditedNotes > this.LARGE_REORDER_WARNING_THRESHOLD) { |
| 1370 | const confirmed = await this.confirmLargeReorder(totalEditedNotes, targetGroupKey); |
| 1371 | if (!confirmed) return; |
| 1372 | } |
| 1373 | |
| 1374 | // Determine if we need to write anything |
| 1375 | const needsWrite = groupDropPlan.needsGroupUpdate || sortOrderPlan !== null; |
| 1376 | if (!needsWrite) { |
| 1377 | this.debouncedRefresh(); |
| 1378 | return; |
| 1379 | } |
| 1380 | |
| 1381 | const file = this.plugin.app.vault.getAbstractFileByPath(draggedPath); |
no test coverage detected