feat(tree): close rust family shell cutover
This commit is contained in:
@@ -189,19 +189,6 @@ export function normalizeDocumentMoveWriteOperation(value: unknown): DocumentMov
|
||||
};
|
||||
}
|
||||
|
||||
export function assertDocumentMoveOrderPlanMatches(expected: unknown, actual: DocumentMoveOrderPlan): DocumentMoveOrderPlan {
|
||||
const normalizedExpected = normalizeDocumentMoveOrderPlan(expected);
|
||||
if (!normalizedExpected) {
|
||||
throw new Error("Rust move plan 与 Convex 当前排序状态不一致");
|
||||
}
|
||||
|
||||
if (JSON.stringify(normalizedExpected) !== JSON.stringify(actual)) {
|
||||
throw new Error("Rust move plan 与 Convex 当前排序状态不一致");
|
||||
}
|
||||
|
||||
return normalizedExpected;
|
||||
}
|
||||
|
||||
export function assertDocumentMoveWriteOperationMatches(expected: unknown, actual: DocumentMoveOrderPlan): DocumentMoveOrderPlan {
|
||||
const normalizedExpected = normalizeDocumentMoveWriteOperation(expected);
|
||||
if (!normalizedExpected) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import { requireUserId } from "./_utils/auth";
|
||||
import { nowIso } from "./_utils/time";
|
||||
import { buildParentById, collectSubtree, isAncestorOf } from "./_utils/documentTree";
|
||||
import {
|
||||
assertDocumentMoveOrderPlanMatches,
|
||||
assertDocumentMoveWriteOperationMatches,
|
||||
buildDocumentMoveOrderPlanFromDocuments,
|
||||
} from "./_utils/documentMoveOrder";
|
||||
@@ -1400,8 +1399,7 @@ export const move = mutation({
|
||||
id: v.string(),
|
||||
parentId: v.union(v.string(), v.null()),
|
||||
sortOrder: v.number(),
|
||||
normalizedMove: v.optional(v.any()),
|
||||
treeWriteOperation: v.optional(v.any()),
|
||||
treeWriteOperation: v.any(),
|
||||
},
|
||||
handler: async (ctx, args) => {
|
||||
const userId = await requireUserId(ctx);
|
||||
@@ -1444,12 +1442,7 @@ export const move = mutation({
|
||||
parentId: toParentId,
|
||||
sortOrder: args.sortOrder,
|
||||
});
|
||||
const rustMoveOrderPlan =
|
||||
args.treeWriteOperation != null
|
||||
? assertDocumentMoveWriteOperationMatches(args.treeWriteOperation, currentMoveOrderPlan)
|
||||
: args.normalizedMove != null
|
||||
? assertDocumentMoveOrderPlanMatches(args.normalizedMove, currentMoveOrderPlan)
|
||||
: null;
|
||||
const rustMoveOrderPlan = assertDocumentMoveWriteOperationMatches(args.treeWriteOperation, currentMoveOrderPlan);
|
||||
|
||||
// 说明:仅更新当前节点的 sort_order 会导致兄弟节点出现重复 sort_order,
|
||||
// 前端会按 sort_order + created_at 排序,结果常常表现为“拖拽无效/拖完又回弹”。
|
||||
|
||||
Reference in New Issue
Block a user