Skip to content

Commit

Permalink
Handle concurrent editing and styling in Tree (yorkie-team#854)
Browse files Browse the repository at this point in the history
We will use maxCreatedAtMapByActor until the introduction of
VersionVector. yorkie-team#800
  • Loading branch information
hackerwins authored May 8, 2024
1 parent a82995b commit 5a77d08
Show file tree
Hide file tree
Showing 18 changed files with 1,426 additions and 1,274 deletions.
8 changes: 8 additions & 0 deletions api/converter/from_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,18 @@ func fromTreeStyle(pbTreeStyle *api.Operation_TreeStyle) (*operations.TreeStyle,
), nil
}

createdAtMapByActor, err := fromCreatedAtMapByActor(
pbTreeStyle.CreatedAtMapByActor,
)
if err != nil {
return nil, err
}

return operations.NewTreeStyle(
parentCreatedAt,
from,
to,
createdAtMapByActor,
pbTreeStyle.Attributes,
executedAt,
), nil
Expand Down
19 changes: 10 additions & 9 deletions api/converter/to_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func toEdit(e *operations.Edit) (*api.Operation_Edit_, error) {
ParentCreatedAt: ToTimeTicket(e.ParentCreatedAt()),
From: toTextNodePos(e.From()),
To: toTextNodePos(e.To()),
CreatedAtMapByActor: toCreatedAtMapByActor(e.CreatedAtMapByActor()),
CreatedAtMapByActor: toCreatedAtMapByActor(e.MaxCreatedAtMapByActor()),
Content: e.Content(),
Attributes: e.Attributes(),
ExecutedAt: ToTimeTicket(e.ExecutedAt()),
Expand All @@ -325,7 +325,7 @@ func toStyle(style *operations.Style) (*api.Operation_Style_, error) {
ParentCreatedAt: ToTimeTicket(style.ParentCreatedAt()),
From: toTextNodePos(style.From()),
To: toTextNodePos(style.To()),
CreatedAtMapByActor: toCreatedAtMapByActor(style.CreatedAtMapByActor()),
CreatedAtMapByActor: toCreatedAtMapByActor(style.MaxCreatedAtMapByActor()),
Attributes: style.Attributes(),
ExecutedAt: ToTimeTicket(style.ExecutedAt()),
},
Expand Down Expand Up @@ -355,7 +355,7 @@ func toTreeEdit(e *operations.TreeEdit) (*api.Operation_TreeEdit_, error) {
To: toTreePos(e.ToPos()),
Contents: ToTreeNodesWhenEdit(e.Contents()),
SplitLevel: int32(e.SplitLevel()),
CreatedAtMapByActor: toCreatedAtMapByActor(e.CreatedAtMapByActor()),
CreatedAtMapByActor: toCreatedAtMapByActor(e.MaxCreatedAtMapByActor()),
ExecutedAt: ToTimeTicket(e.ExecutedAt()),
},
}, nil
Expand All @@ -364,12 +364,13 @@ func toTreeEdit(e *operations.TreeEdit) (*api.Operation_TreeEdit_, error) {
func toTreeStyle(style *operations.TreeStyle) (*api.Operation_TreeStyle_, error) {
return &api.Operation_TreeStyle_{
TreeStyle: &api.Operation_TreeStyle{
ParentCreatedAt: ToTimeTicket(style.ParentCreatedAt()),
From: toTreePos(style.FromPos()),
To: toTreePos(style.ToPos()),
Attributes: style.Attributes(),
ExecutedAt: ToTimeTicket(style.ExecutedAt()),
AttributesToRemove: style.AttributesToRemove(),
ParentCreatedAt: ToTimeTicket(style.ParentCreatedAt()),
From: toTreePos(style.FromPos()),
To: toTreePos(style.ToPos()),
Attributes: style.Attributes(),
ExecutedAt: ToTimeTicket(style.ExecutedAt()),
AttributesToRemove: style.AttributesToRemove(),
CreatedAtMapByActor: toCreatedAtMapByActor(style.MaxCreatedAtMapByActor()),
},
}, nil
}
Expand Down
Loading

0 comments on commit 5a77d08

Please sign in to comment.