pub fn collapse(ops: &mut Vec<PlanOp>)Expand description
Drop every removal of an element that is also added in the same transition.
One pass, three jobs, because in all three the right answer is the same:
an element that has an Add somewhere still exists, so the Remove is
wrong. A full AddUser/CreateChannel carries the complete state, and the
client merges UserState/ChannelState rather than replacing, so re-sending
the element whole simply updates it.
| situation | operations produced | after collapse |
|---|---|---|
| the element changes scope | Remove(old) + Add(new) | Add alone |
| vanish to unvanish | Remove(overlay) + Add(shared) | Add alone, it changes channel |
| unvanish to vanish | Remove(shared) + Add(overlay) | Add alone |
| dropped from the overlay, absent from the shared view | Remove alone | Remove kept |
| gone everywhere | Remove alone | Remove kept |
Three problems that looked distinct, one function: that is the sign it sits at the right level.