diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-02-07 14:37:12 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-02-07 14:39:08 +0100 |
commit | 02e91a96ddded6f6d2505f80b45705fcfb77ed74 (patch) | |
tree | dfdd4be3ce21869fa6611e41f763b6fab3ca7a95 /app | |
parent | 9d5fb49cd80ee31f83bf5364338bd829e3eae1d6 (diff) |
Make streaming API use one pattern-matching redis pubsub connection
Refresh timelines when streaming API reconnects in the UI
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/components/containers/mastodon.jsx | 7 | ||||
-rw-r--r-- | app/assets/javascripts/components/stream.jsx | 9 |
2 files changed, 11 insertions, 5 deletions
diff --git a/app/assets/javascripts/components/containers/mastodon.jsx b/app/assets/javascripts/components/containers/mastodon.jsx index 3b36ce3ef..e23c65121 100644 --- a/app/assets/javascripts/components/containers/mastodon.jsx +++ b/app/assets/javascripts/components/containers/mastodon.jsx @@ -6,7 +6,7 @@ import { deleteFromTimelines, refreshTimeline } from '../actions/timelines'; -import { updateNotifications } from '../actions/notifications'; +import { updateNotifications, refreshNotifications } from '../actions/notifications'; import createBrowserHistory from 'history/lib/createBrowserHistory'; import { applyRouterMiddleware, @@ -80,6 +80,11 @@ const Mastodon = React.createClass({ store.dispatch(updateNotifications(JSON.parse(data.payload), getMessagesForLocale(locale), locale)); break; } + }, + + reconnected () { + store.dispatch(refreshTimeline('home')); + store.dispatch(refreshNotifications()); } }); 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; }; |