浏览代码

chore: move row into other block

ascarbek 2 年之前
父节点
当前提交
fa427fe650

+ 9 - 3
frontend/appflowy_tauri/src/appflowy_app/components/_shared/database-hooks/useDatabase.ts

@@ -82,12 +82,18 @@ export const useDatabase = (viewId: string, type?: ViewLayoutTypePB) => {
   };
 
   const onDragEnd: OnDragEndResponder = async (result) => {
+    if (!controller) return;
     const { source, destination } = result;
-    // move inside the block (group)
+    const group = groups.find((g) => g.groupId === source.droppableId);
+    if (!group) return;
+
     if (source.droppableId === destination?.droppableId) {
-      const group = groups.find((g) => g.groupId === source.droppableId);
-      if (!group || !controller) return;
+      // move inside the block (group)
       await controller.exchangeRow(group.rows[source.index].id, group.rows[destination.index].id);
+    } else {
+      // move to different block (group)
+      if (!destination?.droppableId) return;
+      await controller.moveRow(group.rows[source.index].id, destination.droppableId);
     }
   };