From 02e91a96ddded6f6d2505f80b45705fcfb77ed74 Mon Sep 17 00:00:00 2001
From: Eugen Rochko <eugen@zeonfederated.com>
Date: Tue, 7 Feb 2017 14:37:12 +0100
Subject: Make streaming API use one pattern-matching redis pubsub connection
 Refresh timelines when streaming API reconnects in the UI

---
 app/assets/javascripts/components/stream.jsx | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

(limited to 'app/assets/javascripts/components/stream.jsx')

diff --git a/app/assets/javascripts/components/stream.jsx b/app/assets/javascripts/components/stream.jsx
index 0787399f6..392268b23 100644
--- a/app/assets/javascripts/components/stream.jsx
+++ b/app/assets/javascripts/components/stream.jsx
@@ -10,12 +10,13 @@ const createWebSocketURL = (url) => {
   return a.href;
 };
 
-export default function getStream(accessToken, stream, { connected, received, disconnected }) {
+export default function getStream(accessToken, stream, { connected, received, disconnected, reconnected }) {
   const ws = new WebSocketClient(`${createWebSocketURL(STREAMING_API_BASE_URL)}/api/v1/streaming/?access_token=${accessToken}&stream=${stream}`);
 
-  ws.onopen    = connected;
-  ws.onmessage = e => received(JSON.parse(e.data));
-  ws.onclose   = disconnected;
+  ws.onopen      = connected;
+  ws.onmessage   = e => received(JSON.parse(e.data));
+  ws.onclose     = disconnected;
+  ws.onreconnect = reconnected;
 
   return ws;
 };
-- 
cgit 

