Skip to content

Commit

Permalink
Remove the no-longer-populated removedIds field (#2479)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton authored Nov 22, 2024
1 parent ee74367 commit 5b25778
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 36 deletions.
2 changes: 1 addition & 1 deletion redwood-protocol-guest/api/redwood-protocol-guest.api
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public final class app/cash/redwood/protocol/guest/DefaultGuestProtocolAdapter :
public fun appendPropertyChange-13Ob0Yo (IIILkotlinx/serialization/KSerializer;Ljava/lang/Object;)V
public fun appendPropertyChange-ITsWdOQ (IIIZ)V
public fun appendPropertyChange-hzhmVHk (IIII)V
public fun appendRemove-HpxY78w (IIIILjava/util/List;)V
public fun appendRemove-ARs5Qwk (IIII)V
public fun emitChanges ()V
public fun getJson ()Lkotlinx/serialization/json/Json;
public fun getRoot ()Lapp/cash/redwood/widget/Widget$Children;
Expand Down
2 changes: 1 addition & 1 deletion redwood-protocol-guest/api/redwood-protocol-guest.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ final class app.cash.redwood.protocol.guest/DefaultGuestProtocolAdapter : app.ca
final fun appendMove(app.cash.redwood.protocol/Id, app.cash.redwood.protocol/ChildrenTag, kotlin/Int, kotlin/Int, kotlin/Int) // app.cash.redwood.protocol.guest/DefaultGuestProtocolAdapter.appendMove|appendMove(app.cash.redwood.protocol.Id;app.cash.redwood.protocol.ChildrenTag;kotlin.Int;kotlin.Int;kotlin.Int){}[0]
final fun appendPropertyChange(app.cash.redwood.protocol/Id, app.cash.redwood.protocol/WidgetTag, app.cash.redwood.protocol/PropertyTag, kotlin/Boolean) // app.cash.redwood.protocol.guest/DefaultGuestProtocolAdapter.appendPropertyChange|appendPropertyChange(app.cash.redwood.protocol.Id;app.cash.redwood.protocol.WidgetTag;app.cash.redwood.protocol.PropertyTag;kotlin.Boolean){}[0]
final fun appendPropertyChange(app.cash.redwood.protocol/Id, app.cash.redwood.protocol/WidgetTag, app.cash.redwood.protocol/PropertyTag, kotlin/UInt) // app.cash.redwood.protocol.guest/DefaultGuestProtocolAdapter.appendPropertyChange|appendPropertyChange(app.cash.redwood.protocol.Id;app.cash.redwood.protocol.WidgetTag;app.cash.redwood.protocol.PropertyTag;kotlin.UInt){}[0]
final fun appendRemove(app.cash.redwood.protocol/Id, app.cash.redwood.protocol/ChildrenTag, kotlin/Int, kotlin/Int, kotlin.collections/List<app.cash.redwood.protocol/Id>) // app.cash.redwood.protocol.guest/DefaultGuestProtocolAdapter.appendRemove|appendRemove(app.cash.redwood.protocol.Id;app.cash.redwood.protocol.ChildrenTag;kotlin.Int;kotlin.Int;kotlin.collections.List<app.cash.redwood.protocol.Id>){}[0]
final fun appendRemove(app.cash.redwood.protocol/Id, app.cash.redwood.protocol/ChildrenTag, kotlin/Int, kotlin/Int) // app.cash.redwood.protocol.guest/DefaultGuestProtocolAdapter.appendRemove|appendRemove(app.cash.redwood.protocol.Id;app.cash.redwood.protocol.ChildrenTag;kotlin.Int;kotlin.Int){}[0]
final fun emitChanges() // app.cash.redwood.protocol.guest/DefaultGuestProtocolAdapter.emitChanges|emitChanges(){}[0]
final fun initChangesSink(app.cash.redwood.protocol/ChangesSink) // app.cash.redwood.protocol.guest/DefaultGuestProtocolAdapter.initChangesSink|initChangesSink(app.cash.redwood.protocol.ChangesSink){}[0]
final fun nextId(): app.cash.redwood.protocol/Id // app.cash.redwood.protocol.guest/DefaultGuestProtocolAdapter.nextId|nextId(){}[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,8 @@ public class DefaultGuestProtocolAdapter(
tag: ChildrenTag,
index: Int,
count: Int,
removedIds: List<Id>,
) {
changes.add(ChildrenChange.Remove(id, tag, index, count, removedIds))
changes.add(ChildrenChange.Remove(id, tag, index, count))
}

/** Returns the changes accumulated since the last call to this function. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ public abstract class GuestProtocolAdapter : EventSink {
tag: ChildrenTag,
index: Int,
count: Int,
removedIds: List<Id>,
)

@RedwoodCodegenApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ProtocolWidgetChildren(
guestAdapter.removeWidget(widget.id)
widget.depthFirstWalk(guestAdapter.childrenRemover)
}
guestAdapter.appendRemove(id, tag, index, count, emptyList())
guestAdapter.appendRemove(id, tag, index, count)

_widgets.remove(index, count)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ class HostProtocolAdapterTest {
tag = ChildrenTag.Root,
index = 0,
count = 1,
removedIds = listOf(Id(1)),
),
),
)
Expand Down Expand Up @@ -250,7 +249,7 @@ class HostProtocolAdapterTest {
// Remove root TestRow.
host.sendChanges(
listOf(
Remove(Id.Root, ChildrenTag.Root, 0, 1, listOf(Id(1))),
Remove(Id.Root, ChildrenTag.Root, 0, 1),
),
)

Expand Down
6 changes: 2 additions & 4 deletions redwood-protocol/api/redwood-protocol.api
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,11 @@ public final class app/cash/redwood/protocol/ChildrenChange$Move$Companion {

public final class app/cash/redwood/protocol/ChildrenChange$Remove : app/cash/redwood/protocol/ChildrenChange {
public static final field Companion Lapp/cash/redwood/protocol/ChildrenChange$Remove$Companion;
public synthetic fun <init> (IIIILjava/util/List;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (IIIILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun equals (Ljava/lang/Object;)Z
public final fun getCount ()I
public fun getId-0HhLjSo ()I
public final fun getIndex ()I
public final fun getRemovedIds ()Ljava/util/List;
public fun getTag-b0W0yNk ()I
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
Expand All @@ -102,8 +101,7 @@ public synthetic class app/cash/redwood/protocol/ChildrenChange$Remove$$serializ
}

public final class app/cash/redwood/protocol/ChildrenChange$Remove$Companion {
public final fun invoke-HpxY78w (IIIILjava/util/List;)Lapp/cash/redwood/protocol/ChildrenChange$Remove;
public static synthetic fun invoke-HpxY78w$default (Lapp/cash/redwood/protocol/ChildrenChange$Remove$Companion;IIIILjava/util/List;ILjava/lang/Object;)Lapp/cash/redwood/protocol/ChildrenChange$Remove;
public final fun invoke-ARs5Qwk (IIII)Lapp/cash/redwood/protocol/ChildrenChange$Remove;
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}

Expand Down
6 changes: 1 addition & 5 deletions redwood-protocol/api/redwood-protocol.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ sealed interface app.cash.redwood.protocol/ChildrenChange : app.cash.redwood.pro
final fun <get-id>(): app.cash.redwood.protocol/Id // app.cash.redwood.protocol/ChildrenChange.Remove.id.<get-id>|<get-id>(){}[0]
final val index // app.cash.redwood.protocol/ChildrenChange.Remove.index|{}index[0]
final fun <get-index>(): kotlin/Int // app.cash.redwood.protocol/ChildrenChange.Remove.index.<get-index>|<get-index>(){}[0]
final val removedIds // app.cash.redwood.protocol/ChildrenChange.Remove.removedIds|{}removedIds[0]
final fun <get-removedIds>(): kotlin.collections/List<app.cash.redwood.protocol/Id> // app.cash.redwood.protocol/ChildrenChange.Remove.removedIds.<get-removedIds>|<get-removedIds>(){}[0]
final val tag // app.cash.redwood.protocol/ChildrenChange.Remove.tag|{}tag[0]
final fun <get-tag>(): app.cash.redwood.protocol/ChildrenTag // app.cash.redwood.protocol/ChildrenChange.Remove.tag.<get-tag>|<get-tag>(){}[0]

Expand All @@ -114,9 +112,7 @@ sealed interface app.cash.redwood.protocol/ChildrenChange : app.cash.redwood.pro
}

final object Companion { // app.cash.redwood.protocol/ChildrenChange.Remove.Companion|null[0]
final val $childSerializers // app.cash.redwood.protocol/ChildrenChange.Remove.Companion.$childSerializers|{}$childSerializers[0]

final fun invoke(app.cash.redwood.protocol/Id, app.cash.redwood.protocol/ChildrenTag, kotlin/Int, kotlin/Int, kotlin.collections/List<app.cash.redwood.protocol/Id> = ...): app.cash.redwood.protocol/ChildrenChange.Remove // app.cash.redwood.protocol/ChildrenChange.Remove.Companion.invoke|invoke(app.cash.redwood.protocol.Id;app.cash.redwood.protocol.ChildrenTag;kotlin.Int;kotlin.Int;kotlin.collections.List<app.cash.redwood.protocol.Id>){}[0]
final fun invoke(app.cash.redwood.protocol/Id, app.cash.redwood.protocol/ChildrenTag, kotlin/Int, kotlin/Int): app.cash.redwood.protocol/ChildrenChange.Remove // app.cash.redwood.protocol/ChildrenChange.Remove.Companion.invoke|invoke(app.cash.redwood.protocol.Id;app.cash.redwood.protocol.ChildrenTag;kotlin.Int;kotlin.Int){}[0]
final fun serializer(): kotlinx.serialization/KSerializer<app.cash.redwood.protocol/ChildrenChange.Remove> // app.cash.redwood.protocol/ChildrenChange.Remove.Companion.serializer|serializer(){}[0]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package app.cash.redwood.protocol

import dev.drewhamilton.poko.Poko
import kotlin.DeprecationLevel.ERROR
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down Expand Up @@ -249,9 +248,6 @@ public sealed interface ChildrenChange : Change {
private val _tag: Int,
public val index: Int,
public val count: Int,
// TODO Remove this for Redwood 1.0.0.
@Deprecated("Only sent for compatibility with old hosts. Do not consume.", level = ERROR)
public val removedIds: List<Id> = emptyList(),
) : ChildrenChange {
override val id: Id get() = Id(_id)
override val tag: ChildrenTag get() = ChildrenTag(_tag)
Expand All @@ -262,8 +258,7 @@ public sealed interface ChildrenChange : Change {
tag: ChildrenTag,
index: Int,
count: Int,
removedIds: List<Id> = emptyList(),
): Remove = Remove(id.value, tag.value, index, count, removedIds)
): Remove = Remove(id.value, tag.value, index, count)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ class ProtocolTest {
ChildrenChange.Add(Id(1), ChildrenTag(2), Id(3), 4),
ChildrenChange.Move(Id(1), ChildrenTag(2), 3, 4, 5),
ChildrenChange.Remove(Id(4), ChildrenTag(3), 2, 1),
// We send a list of removed IDs only for old hosts.
ChildrenChange.Remove(Id(1), ChildrenTag(2), 3, 4, listOf(Id(5), Id(6), Id(7), Id(8))),
ModifierChange(
Id(1),
listOf(
Expand Down Expand Up @@ -93,7 +91,6 @@ class ProtocolTest {
"""["add",{"id":1,"tag":2,"childId":3,"index":4}],""" +
"""["move",{"id":1,"tag":2,"fromIndex":3,"toIndex":4,"count":5}],""" +
"""["remove",{"id":4,"tag":3,"index":2,"count":1}],""" +
"""["remove",{"id":1,"tag":2,"index":3,"count":4,"removedIds":[5,6,7,8]}],""" +
"""["modifier",{"id":1,"elements":[[1,{}],[2,3],[3,[]],[4],[5]]}],""" +
"""["property",{"id":1,"widget":2,"tag":2,"value":"hello"}],""" +
"""["property",{"id":1,"widget":2,"tag":2}]""" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class SnapshotChangeListTest {
Move(Id.Root, ChildrenTag.Root, 1, 2, 3),
PropertyChange(Id(1), WidgetTag(1), PropertyTag(1), JsonPrimitive("Hello")),
Add(Id.Root, ChildrenTag.Root, Id(1), 0),
Remove(Id.Root, ChildrenTag.Root, 1, 2, listOf(Id(3), Id(4))),
Remove(Id.Root, ChildrenTag.Root, 1, 2),
),
)
}.hasMessage(
Expand All @@ -71,7 +71,7 @@ class SnapshotChangeListTest {
|
|Found:
| - Move(_id=0, _tag=1, fromIndex=1, toIndex=2, count=3)
| - Remove(_id=0, _tag=1, index=1, count=2, removedIds=[Id(value=3), Id(value=4)])
| - Remove(_id=0, _tag=1, index=1, count=2)
""".trimMargin(),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,12 @@ internal class FastGuestProtocolAdapter(
tag: ChildrenTag,
index: Int,
count: Int,
removedIds: List<Id>,
) {
val id = id
val tag = tag
val index = index
val count = count

val removedIdsArray = js("[]")
for (i in removedIds.indices) {
removedIdsArray.push(removedIds[i].value)
}

changes.push(js("""["remove",{"id":id,"tag":tag,"index":index,"count":count,"removedIds":removedIdsArray}]"""))
changes.push(js("""["remove",{"id":id,"tag":tag,"index":index,"count":count}]"""))
}

override fun emitChanges() {
Expand Down

0 comments on commit 5b25778

Please sign in to comment.