Skip to content
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
6 changes: 6 additions & 0 deletions .changeset/green-groups-unite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"github.com/livekit/protocol": minor
"@livekit/protocol": minor
---

rename ListUpdate "del" field to "rename"
18 changes: 9 additions & 9 deletions livekit/livekit_models.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions livekit/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ func (p *ListUpdate) Validate() error {
if p == nil {
return nil
}
change := len(p.Set)+len(p.Add)+len(p.Del) > 0
change := len(p.Set)+len(p.Add)+len(p.Remove) > 0
if !p.Clear && !change {
return fmt.Errorf("unsupported list update operation")
}
if p.Clear && change {
return fmt.Errorf("cannot clear and change the list at the same time")
}
if len(p.Set) > 0 && len(p.Add)+len(p.Del) > 0 {
if len(p.Set) > 0 && len(p.Add)+len(p.Remove) > 0 {
return fmt.Errorf("cannot set and change the list at the same time")
}
for _, v := range p.Set {
Expand All @@ -247,7 +247,7 @@ func (p *ListUpdate) Validate() error {
return fmt.Errorf("empty element in the list")
}
}
for _, v := range p.Del {
for _, v := range p.Remove {
if v == "" {
return fmt.Errorf("empty element in the list")
}
Expand Down Expand Up @@ -292,7 +292,7 @@ func applyListUpdate[T ~string](dst *[]T, u *ListUpdate) {
return
}
arr := slices.Clone(*dst)
for _, v := range u.Del {
for _, v := range u.Remove {
if i := slices.Index(arr, T(v)); i >= 0 {
arr = slices.Delete(arr, i, i+1)
}
Expand Down
12 changes: 6 additions & 6 deletions livekit/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ func TestListUpdate(t *testing.T) {
Err: true,
},
{
Name: "set and del",
Update: &ListUpdate{Set: []string{"a"}, Del: []string{"b"}},
Name: "set and remove",
Update: &ListUpdate{Set: []string{"a"}, Remove: []string{"b"}},
Err: true,
},
{
Expand All @@ -292,15 +292,15 @@ func TestListUpdate(t *testing.T) {
Exp: []string{"a", "b", "c"},
},
{
Name: "del",
Name: "remove",
Arr: []string{"a", "b"},
Update: &ListUpdate{Del: []string{"b", "c"}},
Update: &ListUpdate{Remove: []string{"b", "c"}},
Exp: []string{"a"},
},
{
Name: "add and del",
Name: "add and remove",
Arr: []string{"a", "b", "c"},
Update: &ListUpdate{Add: []string{"b", "d"}, Del: []string{"c", "e"}},
Update: &ListUpdate{Add: []string{"b", "d"}, Remove: []string{"c", "e"}},
Exp: []string{"a", "b", "d"},
},
}
Expand Down
2 changes: 1 addition & 1 deletion protobufs/livekit_models.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ message TokenPagination {
message ListUpdate {
repeated string set = 1; // set the field to a new list
repeated string add = 2; // append items to a list, avoiding duplicates
repeated string del = 3; // delete items from a list
repeated string remove = 3; // delete items from a list
bool clear = 4; // sets the list to an empty list
}

Expand Down
Loading