Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
fix(backend): fix panic when editing drafts
Browse files Browse the repository at this point in the history
  • Loading branch information
burdiyan committed Nov 9, 2023
1 parent cd2f082 commit 033de77
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions backend/daemon/api/documents/v1alpha/document_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,14 @@ func (dm *docModel) restoreDraft(c cid.Cid, ch hyper.Change) (err error) {
left = parts[0]
}

if err := dm.MoveBlock(block, parent, left); err != nil {
return fmt.Errorf("failed to replay local moves: %w", err)
if parent == TrashNodeID {
if err := dm.DeleteBlock(block); err != nil {
return fmt.Errorf("failed to replay a delete: %w", err)
}
} else {
if err := dm.MoveBlock(block, parent, left); err != nil {
return fmt.Errorf("failed to replay local moves: %w", err)
}
}
}
}
Expand Down

0 comments on commit 033de77

Please sign in to comment.