Skip to content

Commit

Permalink
prevent stream from flickering, fixed double websocket caused by mult…
Browse files Browse the repository at this point in the history
…iple subscriptions
  • Loading branch information
SamiCharfeddine committed Feb 18, 2021
1 parent e4b64fe commit 736f370
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wappsto-blanket",
"version": "1.2.2",
"version": "1.2.3",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
4 changes: 3 additions & 1 deletion util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,13 @@ export function updateStream(dispatch, subscription, type, options=defaultOption
return;
}
timeout = setTimeout(() => {
dispatch(closeStream(secondaryStream));
const ws = dispatch(openStream({ name: secondaryStream, subscription: newSubscriptions, full: options.full || false }, null, options));
ws.addEventListener('open', () => {
dispatch(updateReduxStream(secondaryStream, status.CLOSED, null, null, null));
dispatch(closeStream(mainStream, true));
dispatch(updateReduxStream(mainStream, status.OPEN, null, ws, { subscription: newSubscriptions, name: mainStream, full: options.full || false }));
subscriptions.old = subscriptions.new;
subscriptions.old = newSubscriptions;
subscriptions.new = null;
});
}, 500);
Expand Down

0 comments on commit 736f370

Please sign in to comment.