diff --git a/kernel/api/block_op.go b/kernel/api/block_op.go index 97261bee3..c88bdb50e 100644 --- a/kernel/api/block_op.go +++ b/kernel/api/block_op.go @@ -319,6 +319,13 @@ func moveBlock(c *gin.Context) { return } + currentBt := treenode.GetBlockTree(id) + if nil == currentBt { + ret.Code = -1 + ret.Msg = "block not found [id=" + id + "]" + return + } + var parentID, previousID string if nil != arg["parentID"] { parentID = arg["parentID"].(string) @@ -340,6 +347,19 @@ func moveBlock(c *gin.Context) { } } + var targetBt *treenode.BlockTree + if "" != previousID { + targetBt = treenode.GetBlockTree(previousID) + } else if "" != parentID { + targetBt = treenode.GetBlockTree(parentID) + } + + if nil == targetBt { + ret.Code = -1 + ret.Msg = "target block not found [id=" + parentID + "]" + return + } + transactions := []*model.Transaction{ { DoOperations: []*model.Operation{ @@ -356,8 +376,10 @@ func moveBlock(c *gin.Context) { model.PerformTransactions(&transactions) model.FlushTxQueue() - ret.Data = transactions - broadcastTransactions(transactions) + model.ReloadProtyle(currentBt.RootID) + if currentBt.RootID != targetBt.RootID { + model.ReloadProtyle(targetBt.RootID) + } } func appendBlock(c *gin.Context) {