about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/util/stream.js
diff options
context:
space:
mode:
authorDaigo 3 Dango <zunda@users.noreply.github.com>2020-08-24 12:06:45 +0000
committerThibaut Girka <thib@sitedethib.com>2020-08-30 16:35:33 +0200
commit72b1d5fdc547f575ce10e61b4e523dc3d9d7d036 (patch)
treeebad3912fd3cf67fd22731d0b24a16b01e4b8e15 /app/javascript/flavours/glitch/util/stream.js
parent3bbf6b15190a361b7f826ad2b519ea2c7a202d05 (diff)
[Glitch] Better manage subscriptionCounters
Port 9669557be1d9c8577564242861bdbad9b821906a to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
Diffstat (limited to 'app/javascript/flavours/glitch/util/stream.js')
-rw-r--r--app/javascript/flavours/glitch/util/stream.js12
1 files changed, 2 insertions, 10 deletions
diff --git a/app/javascript/flavours/glitch/util/stream.js b/app/javascript/flavours/glitch/util/stream.js
index 640455b33..cf1388aed 100644
--- a/app/javascript/flavours/glitch/util/stream.js
+++ b/app/javascript/flavours/glitch/util/stream.js
@@ -112,11 +112,10 @@ const sharedCallbacks = {
   },
 
   disconnected () {
-    subscriptions.forEach(({ onDisconnect }) => onDisconnect());
+    subscriptions.forEach(subscription => unsubscribe(subscription));
   },
 
   reconnected () {
-    subscriptions.forEach(subscription => subscribe(subscription));
   },
 };
 
@@ -252,15 +251,8 @@ const createConnection = (streamingAPIBaseURL, accessToken, channelName, { conne
 
   const es = new EventSource(`${streamingAPIBaseURL}/api/v1/streaming/${channelName}?${params.join('&')}`);
 
-  let firstConnect = true;
-
   es.onopen = () => {
-    if (firstConnect) {
-      firstConnect = false;
-      connected();
-    } else {
-      reconnected();
-    }
+    connected();
   };
 
   KNOWN_EVENT_TYPES.forEach(type => {