Skip to content

Commit

Permalink
Replace maxCreatedAtMapByActor for Tree.Edit and Tree.Style
Browse files Browse the repository at this point in the history
  • Loading branch information
chacha912 committed Dec 3, 2024
1 parent eed9b46 commit 05d433a
Show file tree
Hide file tree
Showing 14 changed files with 129 additions and 196 deletions.
23 changes: 0 additions & 23 deletions api/converter/from_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,6 @@ func fromEdit(pbEdit *api.Operation_Edit) (*operations.Edit, error) {
if err != nil {
return nil, err
}
if err != nil {
return nil, err
}
executedAt, err := fromTimeTicket(pbEdit.ExecutedAt)
if err != nil {
return nil, err
Expand Down Expand Up @@ -438,9 +435,6 @@ func fromStyle(pbStyle *api.Operation_Style) (*operations.Style, error) {
if err != nil {
return nil, err
}
if err != nil {
return nil, err
}
executedAt, err := fromTimeTicket(pbStyle.ExecutedAt)
if err != nil {
return nil, err
Expand Down Expand Up @@ -495,13 +489,6 @@ func fromTreeEdit(pbTreeEdit *api.Operation_TreeEdit) (*operations.TreeEdit, err
return nil, err
}

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

nodes, err := FromTreeNodesWhenEdit(pbTreeEdit.Contents)
if err != nil {
return nil, err
Expand All @@ -513,7 +500,6 @@ func fromTreeEdit(pbTreeEdit *api.Operation_TreeEdit) (*operations.TreeEdit, err
to,
nodes,
int(pbTreeEdit.SplitLevel),
createdAtMapByActor,
executedAt,
), nil
}
Expand All @@ -539,19 +525,11 @@ func fromTreeStyle(pbTreeStyle *api.Operation_TreeStyle) (*operations.TreeStyle,
return nil, err
}

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

if len(pbTreeStyle.AttributesToRemove) > 0 {
return operations.NewTreeStyleRemove(
parentCreatedAt,
from,
to,
createdAtMapByActor,
pbTreeStyle.AttributesToRemove,
executedAt,
), nil
Expand All @@ -561,7 +539,6 @@ func fromTreeStyle(pbTreeStyle *api.Operation_TreeStyle) (*operations.TreeStyle,
parentCreatedAt,
from,
to,
createdAtMapByActor,
pbTreeStyle.Attributes,
executedAt,
), nil
Expand Down
26 changes: 12 additions & 14 deletions api/converter/to_pb.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,27 +383,25 @@ func toIncrease(increase *operations.Increase) (*api.Operation_Increase_, error)
func toTreeEdit(e *operations.TreeEdit) (*api.Operation_TreeEdit_, error) {
return &api.Operation_TreeEdit_{
TreeEdit: &api.Operation_TreeEdit{
ParentCreatedAt: ToTimeTicket(e.ParentCreatedAt()),
From: toTreePos(e.FromPos()),
To: toTreePos(e.ToPos()),
Contents: ToTreeNodesWhenEdit(e.Contents()),
SplitLevel: int32(e.SplitLevel()),
CreatedAtMapByActor: toCreatedAtMapByActor(e.MaxCreatedAtMapByActor()),
ExecutedAt: ToTimeTicket(e.ExecutedAt()),
ParentCreatedAt: ToTimeTicket(e.ParentCreatedAt()),
From: toTreePos(e.FromPos()),
To: toTreePos(e.ToPos()),
Contents: ToTreeNodesWhenEdit(e.Contents()),
SplitLevel: int32(e.SplitLevel()),
ExecutedAt: ToTimeTicket(e.ExecutedAt()),
},
}, nil
}

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(),
CreatedAtMapByActor: toCreatedAtMapByActor(style.MaxCreatedAtMapByActor()),
ParentCreatedAt: ToTimeTicket(style.ParentCreatedAt()),
From: toTreePos(style.FromPos()),
To: toTreePos(style.ToPos()),
Attributes: style.Attributes(),
ExecutedAt: ToTimeTicket(style.ExecutedAt()),
AttributesToRemove: style.AttributesToRemove(),
},
}, nil
}
Expand Down
Loading

0 comments on commit 05d433a

Please sign in to comment.