Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle concurrent editing and styling in Tree #854

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading