Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
At the moment, when subscribing a `Presence` multiple times, multiple PubSub `Stream`s are created per-subscription. However, unsubscribing will only destroy the [last created][1], resulting in streams that are never destroyed. This change updates our subscription logic to check if we already have an existing stream. If we already have a stream, then we just re-request presence from other clients (which is needed by our [`DocPresence` logic][2]), and return. Note that we also tweak our unsubscribe logic to eagerly remove the stream after calling destroy (so that subsequent subscribes don't try to reuse a stream that is currently being destroyed). We also remove a check against `seq`, which is currently not covered by tests (and actually never calls the `callback`), so is clearly broken and unneeded anyway. [1]: https://github.com/share/sharedb/blob/62e4ec5d46c0dcb097931e9dae60240aaba6b2b3/lib/agent.js#L829-L830 [2]: https://github.com/share/sharedb/blob/62e4ec5d46c0dcb097931e9dae60240aaba6b2b3/lib/client/presence/remote-doc-presence.js#L108-L110
- Loading branch information