mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-11 18:20:28 +09:00
Update state builder to fix root change
This commit is contained in:
parent
3f17e594ec
commit
831ac5150a
2 changed files with 3 additions and 1 deletions
|
@ -48,7 +48,7 @@ func (s *stateBuilder) Build(tr objecttree.ObjectTree, oldState *State) (state *
|
|||
|
||||
func (s *stateBuilder) processChange(change *objecttree.Change, rootId string, state *State) *State {
|
||||
// ignoring root change which has empty model or startId change
|
||||
if change.Model == nil || state.LastIteratedId == change.Id {
|
||||
if len(change.PreviousIds) == 0 || state.LastIteratedId == change.Id {
|
||||
return state
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ func TestStateBuilder_ProcessChange(t *testing.T) {
|
|||
|
||||
t.Run("changeId is equal to rootId", func(t *testing.T) {
|
||||
ch := &objecttree.Change{}
|
||||
ch.PreviousIds = []string{"someId"}
|
||||
ch.Model = &spacesyncproto.SettingsData{
|
||||
Snapshot: &spacesyncproto.SpaceSettingsSnapshot{
|
||||
DeletedIds: []string{"id1", "id2"},
|
||||
|
@ -56,6 +57,7 @@ func TestStateBuilder_ProcessChange(t *testing.T) {
|
|||
|
||||
t.Run("changeId is not equal to lastIteratedId or rootId", func(t *testing.T) {
|
||||
ch := &objecttree.Change{}
|
||||
ch.PreviousIds = []string{"someId"}
|
||||
ch.Model = &spacesyncproto.SettingsData{
|
||||
Content: []*spacesyncproto.SpaceSettingsContent{
|
||||
{Value: &spacesyncproto.SpaceSettingsContent_ObjectDelete{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue