about summary refs log tree commit diff
path: root/app/javascript/mastodon/stream.js
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-03-07 22:17:52 +0100
committerGitHub <noreply@github.com>2019-03-07 22:17:52 +0100
commitbe1c634b2b4372a525d304d2ff830392f04c5cc5 (patch)
tree2070c1a3562652fe0c3e630a97dd77fbb3708ca5 /app/javascript/mastodon/stream.js
parent09c042aa10f2be4824fcb8e96c8a8ae6d324d12f (diff)
Fix public timelines being broken by new toots when they are not mounted (#10131)
Diffstat (limited to 'app/javascript/mastodon/stream.js')
-rw-r--r--app/javascript/mastodon/stream.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/javascript/mastodon/stream.js b/app/javascript/mastodon/stream.js
index 9928d0dd7..306a068b7 100644
--- a/app/javascript/mastodon/stream.js
+++ b/app/javascript/mastodon/stream.js
@@ -2,11 +2,11 @@ import WebSocketClient from 'websocket.js';
 
 const randomIntUpTo = max => Math.floor(Math.random() * Math.floor(max));
 
-export function connectStream(path, pollingRefresh = null, callbacks = () => ({ onDisconnect() {}, onReceive() {} })) {
+export function connectStream(path, pollingRefresh = null, callbacks = () => ({ onConnect() {}, onDisconnect() {}, onReceive() {} })) {
   return (dispatch, getState) => {
     const streamingAPIBaseURL = getState().getIn(['meta', 'streaming_api_base_url']);
     const accessToken = getState().getIn(['meta', 'access_token']);
-    const { onDisconnect, onReceive } = callbacks(dispatch, getState);
+    const { onConnect, onDisconnect, onReceive } = callbacks(dispatch, getState);
 
     let polling = null;
 
@@ -28,6 +28,8 @@ export function connectStream(path, pollingRefresh = null, callbacks = () => ({
         if (pollingRefresh) {
           clearPolling();
         }
+
+        onConnect();
       },
 
       disconnected () {
@@ -47,6 +49,8 @@ export function connectStream(path, pollingRefresh = null, callbacks = () => ({
           clearPolling();
           pollingRefresh(dispatch);
         }
+
+        onConnect();
       },
 
     });