]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Better manage subscriptionCounters
authorDaigo 3 Dango <zunda@users.noreply.github.com>
Mon, 24 Aug 2020 12:06:45 +0000 (12:06 +0000)
committerThibaut Girka <thib@sitedethib.com>
Sun, 30 Aug 2020 14:35:33 +0000 (16:35 +0200)
Port 9669557be1d9c8577564242861bdbad9b821906a to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
app/javascript/flavours/glitch/util/stream.js

index 640455b33d12ab2354c93c2983ca3c24118c1ce9..cf1388aed2556d536278caec9319137c919e2790 100644 (file)
@@ -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 => {